Skip to content

Call Event Patterns

John Pan edited this page Oct 9, 2017 · 2 revisions

In Lockstep Framework, there are call events used for global and unit behaviors. Most of these calls are guaranteed to be deterministic and are called in a specific order in the game loop.

Note: The overideable version of calls is OnCallName. This allows custom logic to be added to events while not replacing built-in logic. For example, overriding the Setup() call on Ability:

using Lockstep;
public class ExampleAbil : Ability {
    protected override void OnSetup() {
        //Custom setup logic here
    }     
}

The Late prefix makes the event called before it is normally called on all objects. For example, Ability.LateSimulate is called after Ability.Simulate is called on every ability of every unit.

Similarly, the Early prefix makes the event called before it is normally called on all objects.

The following are the call events and their details.


Setup()

Deterministically called when an object is first created and used. Use this event for setting up data that only needs to be initialized once on an item.


Initialize()

Deterministically called when an object is created or unpooled. Reset variables for pooled objects in here.


GameStart()

Indeterministically called when the game first starts. Use this for communicating with systems that don't require determinism like UI and select server communication.


Execute(Command com)

Deterministically called when Commands are received. Commands are encapsulated data that is deterministically injected into the game. Apply custom logic to them here.


Simulate()

Deterministically called every lockstep frame. With the default framerate, this is called 32 times a second. Use this event for any actions for any continuous logic.


Visualize()

Indeterministically called every Unity Update frame. Communicate with rendering and other Unity features here.


Deactivate()

Deterministically called when an object is destroyed or pooled, i.e. when the game ends or when a unit dies. Use this event for custom logic for dying units or un-allocating/resetting resources when the game ends.

Clone this wiki locally