mission_task_store_entity¶
Source: base/tealdef/mission/tasks/utility/mission_task_store_entity.d.tl
Notes
Task that stores an entity as a snapshot for other tasks to read.
MissionTaskStoreEntity¶
record global base/tealdef/mission/tasks/utility/mission_task_store_entity.d.tl:3
global record MissionTaskStoreEntity is MissionInterface.TaskScript<MissionTaskStoreEntity.State, MissionTaskStoreEntity.Params>
Load: local store_entity = ug_require "::/mission/tasks/utility/store_entity.tl" as MissionTaskStoreEntity
Notes
Task (store_entity) that stores an entity as a snapshot (id and revision) in its state and then completes. The base-game tutorial stores its capital (store_capital) and second town (store_town2) this way and reads them with TutorialStoryUtil.getCapital and TutorialStoryUtil.getSecondTown.
Details
Each update calls storeFn until it returns an entity. The snapshot is nil when the entity no longer exists
or isExpectedFn rejects it; resolved is true in both cases and the task completes with an error in the
log. Completion waits one more update (waitForEngineSwap). Saves from before this task existed, which kept
the entity id in a store_any task, are converted by handleLegacy; if the stored entity no longer passes
isExpectedFn, it looks for a replacement among all entities.
MissionTaskStoreEntity.Params¶
record base/tealdef/mission/tasks/utility/mission_task_store_entity.d.tl:4
record Params
Notes
Params of the task.
Used in the base game: 8 times in 3 files
base/content/mission/mission/tasks/utility/store_entity.tl:4
base/content/mission/mission/tutorial/tutorial_story.tl:224
base/content/mission/mission/tutorial/tutorial_story_util.tl:52
Functions
storeFn(readOnlyApi : MissionInterface.MissionTaskReadOnlyApi) : Engine.Entity base/tealdef/mission/tasks/utility/mission_task_store_entity.d.tl:5
Notes
Finds the entity to store; called every update until it returns an entity.
| Parameter | Type | Description |
|---|---|---|
readOnlyApi |
MissionInterface.MissionTaskReadOnlyApi |
Read-only mission API. |
Returns Engine.Entity: Entity to store, or nil to try again.
isExpectedFn(entity : Engine.Entity) : boolean base/tealdef/mission/tasks/utility/mission_task_store_entity.d.tl:6
Notes
Optional check of the found entity, for example whether it is a town. A rejected entity is logged and no snapshot is stored.
| Parameter | Type | Description |
|---|---|---|
entity |
Engine.Entity |
The entity returned by storeFn. |
Returns boolean: true if the entity is the expected kind.
MissionTaskStoreEntity.State¶
record base/tealdef/mission/tasks/utility/mission_task_store_entity.d.tl:8
record State
Notes
State of the task.
Used in the base game: 2 times in 2 files
base/content/mission/mission/tasks/utility/store_entity.tl:3
base/content/mission/mission/tutorial/tutorial_story_util.tl:52
Fields
| Name | Type | Description |
|---|---|---|
snapshot |
EntityUtil.EntityAndRevision |
nil if storeFn yielded no valid entity Stored entity with its revision, or nil if storeFn yielded no valid entity. |
resolved |
boolean |
true once storeFn returned an entity, whether or not the snapshot is valid. |
waitForEngineSwap |
boolean |
Delays completion by one update after the entity was stored. |