// Generates a Universe component within the scene // Returns a reference to the generated component public UniverseComponent Hook(string label, Universe reference) { foreach (UniverseComponent c in universes) { if (c.reference == reference) { return(null); } } UniverseComponent component = Instantiate( defaultUniverse, Vector3.zero, Quaternion.identity, transform ); component.gameObject.name = label; component.manager = this; component.reference = reference; universes.Add(component); return(component); }
// Generate Entity components within the scene public void GenerateEntities( UniverseComponent parent, ICollection <IEntity> latest ) { foreach (EntityComponent target in parent.entities) { Destroy(target.gameObject); } parent.entities.Clear(); foreach (IEntity target in latest) { GameObject o = new GameObject(); EntityComponent component = o.AddComponent <EntityComponent>(); component.reference = new UnityEntity(target); // Decorate component.debug = verboseMode; o.name = target.GetDebugLabel(); o.transform.parent = parent.transform; parent.entities.Add(component); } }