Programming‎ > ‎

Game System

The system that make up the Stuff in the world. Every codebase should have a Stuff class

The Entity
The game system is the part of the game that keep track of the entities in the game. A entity can be a tank, a player, a weapon or anything else. Entity is the name I use but there are a number of other names. They are called Game Object in Unity, Actor in Unreal and Entity by CryEngine and Source. The basic things a game system need to do with entity's is to create, update, communicate, render and destroy.

The Life
The life of a entity is marked by the following major stages.

Create / Construction
Memory is allocated for the entity, default values are set and pointers are cleared.

Configuration data is used to specify how the entity should setup itself. Position, physical properties and what visual assets to use. Often loaded from the level.

This setp is done when all entities has been initalized. It allows for the setup of inter-entity relationships. For examaple trigger regions might link to the doors they open.


Render / Draw

Release any used assets.

Destroy / Destruction
Return the memory the entity used.

The Form

A simple struct that is the same for all entity's and that contain all the data needed. The struct need a data field to tell you what it is and then the Update(entity*) function can check what it is and do what is needed. It will be one big switch case.

In a Inheritance game system there is some form of base entity that everything is based. Then one derives new entity types from that one and add the code and data needed. It all turns into a tree of entity types that depend on each other. A bit hard to change when one started to get a big tree and someone would like to move one branch from one side to the next.
Component - 2002
In a component system the basic entity does not do much besides existing. To make it do more one add components to it where each component do something specific. One component can make it render a model and another can make it try to shoot at the player.

Entities-Parts I: Game Objects - 2014: Part 1, Part 2 and Part 3.
Hacking the monolithic entity system - 2014
Building a Data-Oriented Entity System (Bitsquid engine) - 2014 - Party1, Part2, Part3 and Part4.

Entity Systems are the future of MMOG development - 2007: Part 1, Part 2, Part 3, Part 4, Part 5

Object Systems by Doug Church - 2002