Empires Callbacks

From Archon Wiki
Revision as of 22:37, 10 January 2017 by Andrewg (Talk | contribs)

Jump to: navigation, search

Map.bsf callbacks

InitMap

Called when a new game is started. Also called each time the scenario is opened in the editor.

InitFinal

Called when a new game is started, immediately after InitScenario.

StartMap

Called each time the scenario is opened (new game, loading a saved game, loading the scenario in the editor).

StartTurn

Called at the beginning of the planning phase of each turn.

EndTurn

Called at the end of the resolution phase of each turn. Happens during the TurnResolveComplete command.

UpdateMap(tick)

Called each frame. If the tick parameter is 0, it means that this is an 'extra' frame because the game is rendering faster than its 'logical' framerate (30 fps). Things that should happen at a constant speed (such turn resolution) should only happen if tick is 1, things that should happen as fast as possible (such as UI handling) should happen regardless of tick. In practice, there should be very few places you need to look at the tick parameter.

UpdateAI(faction)

Called for each AI controlled faction until it returns a non-zero value. It is expected to run a small slice AI planning each call. Called after UpdateScenario.

RenderMap

Called each frame after all of the update callbacks. Primarily used for drawing UI elements over the map

StartGroup(id)

Expected to set up the visuals for a group (including call SetGroupAsset). Called at various points during game flow (expect it to be called multiple times as needed for the same group).

StartStructure(id)

Expected to set up the visuals for a structure (including call SetStructureAsset). Called at various points during game flow (expect it to be called multiple times as needed for the same structure).

PathfindingData(region, group, ...)

Request for connection info for a group leaving a region. For each region the group can enter from the requested region, the script must call SetPathfindingData.

Scenario.bsf callbacks

InitScenario

Called when a new game is started, immediately after InitMap.

StartScenario

Called each time the scenario is opened (new game, loading a saved game), immediately after StartMap

StartTurn

Call each turn, immediately after Map.bsf StartTurn

EndTurn

Called each turn, immediately before Map.bsf EndTurn. Happens during the TurnResolveComplete command.

UpdateScenario

Called each frame, immediately after UpdateMap

RenderScenario

Called each frame after, immediately after RenderMap

Callback sequence

New Game Example

  1. InitMap
  2. InitScenario
  3. InitFinal
  4. StartMap
  5. StartScenario
  6. StartStructure x X
  7. StartGroup x X
  8. StartTurn in Map.bsf
  9. StartTurn in Scenario.bsf
  10. UpdateMap
  11. UpdateScenario
  12. RenderMap
  13. RenderScenario
  14. UpdateMap
  15. ...
  16. UpdateMap
  17. UpdateScenario
  18. UpdateAI
  19. ...
  20. EndTurn in Scenario.bsf
  21. EndTurn in Map.bsf
  22. StartTurn in Map.bsf
  23. StartTurn in Scenario.bsf
  24. UpdateMap
  25. ...

Loading Saved Game Example

  1. StartMap
  2. StartScenario
  3. StartStructure x X
  4. StartGroup x X
  5. UpdateMap
  6. UpdateScenario
  7. RenderMap
  8. RenderScenario
  9. UpdateMap
  10. ...