dot big bang

Developer API
Menu
All
  • Public
  • Public/Protected
  • All

This article gives an overview of the current Entity Lifecycle in dot big bang. It’s an area under active development at the moment and we will post regular updates as things change.

In general you shouldn’t rely on the order of calling a callback to remain consistent for entities and components within an entity. As such you shouldn’t write code that requires an implicit ordering. For example relying on the Troll entity to always be updated before the Player entity without that being enforced.

Lifecycle Callbacks

General

start is a catch-all initialization function, it is called whenever a component is added to an Entity. It should not be assumed that any other part of the Entity has been initialized when it is called.
tick is called once per game update. You can get the elapsed time since the last tick with this.game.frameDeltaTime.
postCollisionTick is called once per game update after tick and after our collision system has run for this frame. All the collision callbacks below are guarenteed to have run before this gets called. You can get the elapsed time since the last tick with this.game.frameDeltaTime.
dispose is called at the end of the frame if the Entity is to be removed or when a component is removed from the Entity.
onMessage is called at the beginning of the frame for every message that is sent to an Entity. Passes through the message name, a payload data object and information about the Peer that sent the message.

Collision

Collision callbacks are only called on Entities with at least one Collision component that has a Static or Dynamic response type. All callbacks are symmetrical and both Entities involved will be notified of the contact.

onCollisionCorrection is called when the collision system moves an Entity with the Dynamic response type. It passes a Vector3 representing the movement the collision system made.
onCollisionEnter is called when an Entity pair make contact. Passes through the other Entity involved as well as details of the contact.
onCollisionStay is called every game tick that an Entity pair is in contact. Passes through the other Entity involved as well as details of the contact.
onCollisionExit is called when an Entity pair leave contact. Passes through the other Entity involved.

Trigger

Trigger callbacks are only called on Entities with at least one Collision component. Note the response type is unimportant and all types will get trigger callbacks. All callbacks are symmetrical and both Entities involved will be notified of the contact.

onTriggerEnter is called when an Entity pair make contact. Passes through the other Entity involved.
onTriggerStay is called every game tick that an Entity pair is in contact. Passes through the other Entity involved.
onTriggerExit is called when an Entity pair leave contact. Passes through the other Entity involved.

Signatures


start ()

tick ()

postCollisionTick ()

dispose ()

onMessage (name : string, data : any, sender : Peer)



onTriggerEnter (other : Entity)

onTriggerStay (other : Entity)

onTriggerExit (other : Entity)



onCollisionEnter (other : Entity, contact : CollisionContact)

onCollisionStay (other : Entity, contact : CollisionContact)

onCollisionExit (other : Entity)

Lifecycle Timing

Game Loading

  • If the game is single-player or starting a new multiplayer game.
  • The serialized game is loaded in and all the entities in it are instantiated. start is called as each entity and component is instantiated.
  • The game ticks for one frame.
  • The Player Template defined for the game is spawned in. start is called for the entity and components created.
  • The game continues to tick.

Tick Loop

For every entity and component in the game:

  • onMessage is called for each message directed at each Entity.
  • tick is called.
  • Collision and Trigger callbacks will be called.
  • postCollisionTick is called.
  • dispose is called for each Entity being removed before they are removed.