Skip to content
This repository has been archived by the owner on Oct 22, 2023. It is now read-only.

Workflow: Spawning an entity

proepkes edited this page Feb 19, 2019 · 3 revisions

In the Unity project there is an entity-database which contains all spawnable prefabs that exist in the simulation. The following steps are made when a spawn-command is issued by an actor:

  1. the spawn command sets which entity should be spawned by calling AddDatabaseEntityID on the inputEntity

`

public class SpawnCommand : ICommand
{
  public void Execute(InputEntity e)
  {
    e.AddCoordinate(Position);
    e.AddDatabaseEntityId(DatabaseEntityId);  
}
  1. the framework receives the command and creates a new game-entitiy 3.1) some necessary components are added to the game-entity (e.g. ID-fields and position)
  2. the game-entity gets passed to Unity in addition to the provided database-entity-id
  3. Unity looks up the database-entity-id and instantiates a new gameobject
  4. additional MonoBehaviours on the gameObject add components to the game-entity
Clone this wiki locally