Skip to content

Implement AddEntityAction

This MR intends to add the implementation for AddEntityAction.

Additional work beyond original scope

When starting this work, there was a wrong assumption that we could simply call Add(name) from IEntityRepository, but the actual MantleAPI interface doesn't have an Add(name) that recreates a previously defined entity. Only Create(name, properties) exists, which requires the full entity properties (bounding box, performance, axles, etc.) at call time.

This means AddEntityAction can't just "add" an entity by name — it needs to defer the full creation that normally happens at scenario initialization. This required the following additional work:

  1. Entity registration and deferred creation — Extended EntityCreator with RegisterScenarioObjects() (stores all scenario object blueprints by name) and CreateEntityByName() (creates an entity from a stored blueprint at runtime). Also added GetScenarioObject() so controllers can be created for the entity later.
  2. Init-time filtering via ScenarioObjectCreationNode — Added a new YASE ActionNode (ScenarioObjectCreationNode) as the first child of RootNode. On first tick, it creates all entities and controllers except those flagged by AddEntityAction nodes. During tree construction (lookupAndRegisterData), each AddEntityAction inserts its entity name into a shared AddEntityActionEntityNames set on the blackboard. ResetAndCreateEntities() was simplified to ResetAndRegisterEntities() (only resets repositories and registers scenario objects), and ResetAndCreateControllers() was removed entirely.
  3. Controller creation at trigger time — When AddEntityAction fires, it needs to not only create the entity and set its position, but also create and assign controllers (default controller at minimum). This required wiring ControllerCreator through the blackboard alongside EntityCreator, and calling CreateControllers() in EntityUtils::AddEntity().
  4. EntityUtils::AddEntity() — Encapsulates the full add flow (create entity → set position → create controllers) as a static method, symmetric with the existing EntityUtils::RemoveEntity() used by DeleteEntityAction.
Edited by Jorge Sousa

Merge request reports

Loading