Skip to content
Darius Grauslys edited this page Jun 3, 2024 · 2 revisions

Essential headers

defines.h

All struct, macro, and typedefs are defined here.

defines_weak.h

All forward declarations of defines.h are declared here.

game_action.h

See Game Actions below.

Any substantial game event which should be relayed over multiplayer must be performed through this interface.

Entity Allocation

Entities can be allocated in one of two ways: allocate_entity_in__entity_manager(...) allocate_entity_into__world(...) invoke_action__allocate_entity(...)

Note the difference with "in" and "into" as it explains what the difference here is. The first simply allocates an entity in the game without registering them to any other system. The second will call the first, then use the entity pointer to register that entity to each sub system with world, such as the collision system. The difference in naming, "in" and "into" aims to show that in the first invocation, the entity is allocated in the array list found within entity_manager, while the third suggests the entity is allocated elsewhere, but "placed" into world afterwards.

The third invocation is used in instances which the allocated entity should be sent to client instances. It will make an invocation ot allocate_entity_into__world. When in doubt, use the third invocation.

When to use one invocation over the other:

The bold entry is what you should use in most cases.

  1. Use the first invocation for logical entities that are "server-side" only, and don't interact with other entities via sub-systems.
  2. Use the second invocation for entities that behave like physical objects in the game space, but only exist server side. 3) Use the third invocation for most things. It will relay the allocation to clients, so everyone will see the entity.

Game Actions

All significant events that occur during gameplay which should be consistent between clients should be executed via Game Actions.

The Game struct contains a member m_game_action_handler which manages such game actions. The types of game actions are found within the enum Game_Action_Kind. For each such enum type, there is a helper function in game_actions.h prefixed with invoke_action__ and followed by the corresponding enum Game_Action_Kind. These function helpers should be used for the dispatching of every game action.

TLDR; If you write code that interacts with the game world, use functions defined in game_action.h to do this.

Clone this wiki locally