Empires Callbacks: Difference between revisions
No edit summary |
No edit summary |
||
Line 33: | Line 33: | ||
=== PathfindingData(region, group, ...) === | === 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. | 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. | ||
=== UI_UPDATE_GROUP(groupID, zoom, mouseX, mouseY, buttons) === | |||
Called once per frame for each group visible on the map to update the UIGroup layout for the current frame. zoom is the height of the camera above the ground. Return <= 0 if there is nothing to be drawn. If the mouse is over any visible component of the UI, GetMouseGroup will return that group ID as it would if the mouse was over the group's on-map 3d object. The root of the UI is automatically placed to draw immediately below the base of the group's on-map 3d object. | |||
=== UI_UPDATE_CITYSCAPE(regionID, zoom, mouseX, mouseY, buttons) === | |||
Called once per frame for each region visible on the map to update the UICity layout for the current frame. zoom is the height of the camera above the ground. Return <= 0 if there is nothing to be drawn. If the mouse is over any visible component of the UI, GetMouseStructure will return the ID of structure in that region as it would if the mouse was over the structure's on-map 3d object. The root of the UI is automatically placed to draw immediately below anchor 0 of the region. | |||
== Scenario.bsf callbacks == | == Scenario.bsf callbacks == |
Revision as of 23:03, 16 February 2017
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. AI factions which have the INACTIVE attribute set to non-zero will be skipped.
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.
UI_UPDATE_GROUP(groupID, zoom, mouseX, mouseY, buttons)
Called once per frame for each group visible on the map to update the UIGroup layout for the current frame. zoom is the height of the camera above the ground. Return <= 0 if there is nothing to be drawn. If the mouse is over any visible component of the UI, GetMouseGroup will return that group ID as it would if the mouse was over the group's on-map 3d object. The root of the UI is automatically placed to draw immediately below the base of the group's on-map 3d object.
UI_UPDATE_CITYSCAPE(regionID, zoom, mouseX, mouseY, buttons)
Called once per frame for each region visible on the map to update the UICity layout for the current frame. zoom is the height of the camera above the ground. Return <= 0 if there is nothing to be drawn. If the mouse is over any visible component of the UI, GetMouseStructure will return the ID of structure in that region as it would if the mouse was over the structure's on-map 3d object. The root of the UI is automatically placed to draw immediately below anchor 0 of the region.
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
- InitMap
- InitScenario
- InitFinal
- StartMap
- StartScenario
- StartStructure x X
- StartGroup x X
- StartTurn in Map.bsf
- StartTurn in Scenario.bsf
- UpdateMap
- UpdateScenario
- RenderMap
- RenderScenario
- UpdateMap
- ...
- UpdateMap
- UpdateScenario
- UpdateAI
- ...
- EndTurn in Scenario.bsf
- EndTurn in Map.bsf
- StartTurn in Map.bsf
- StartTurn in Scenario.bsf
- UpdateMap
- ...
Loading Saved Game Example
- StartMap
- StartScenario
- StartStructure x X
- StartGroup x X
- UpdateMap
- UpdateScenario
- RenderMap
- RenderScenario
- UpdateMap
- ...