void AddEntity(Entity <T> entity, Type type, T component) { if (AddEntitySilently(entity)) { OnEntityAdded?.Invoke(this, entity, type, component); } }
public int AddEntity(NetEntity entity, bool setIndex = true) { if (Entities.Contains(entity)) { return(-1); } if (entity.Started) { return(-1); } Entities.Add(entity); if (setIndex) { entity.EntityId = NextEntityIndex; // do this so clients can create their own client-side entities // and its id wont overlap with server-side entities if (!Game.IsHost) { entity.EntityId *= -1; } } entity.Start(); OnEntityAdded?.Invoke(entity); return(entity.EntityId); }
public Entity CreateEntity(string entityName) { //Entity newEnt = Factory.CreateEntityFromTemplate(entityName); Entity newEnt = Factory.CreateEntityFromPool(entityName); OnEntityAdded?.Invoke(newEnt); return(newEnt); }
/// This is used by the pool to manage the group. public void UpdateEntity(Entity <T> entity, Type type, T previousComponent, T newComponent) { if (_entities.Contains(entity)) { OnEntityRemoved?.Invoke(this, entity, type, previousComponent); OnEntityAdded?.Invoke(this, entity, type, newComponent); OnEntityUpdated?.Invoke(this, entity, type, previousComponent, newComponent); } }
/// This is used by the context to manage the group. public void UpdateEntity(TEntity entity, int index, IComponent previousComponent, IComponent newComponent) { if (_entities.Contains(entity)) { OnEntityRemoved?.Invoke(this, entity, index, previousComponent); OnEntityAdded?.Invoke(this, entity, index, newComponent); OnEntityUpdated?.Invoke(this, entity, index, previousComponent, newComponent); } }
private void AddEntity(TEntity entity, int index, IComponent component) { if (AddEntitySilently(entity)) { OnEntityAdded?.Invoke( this, entity, index, component); } }
public Entity CreateEntity(string name, HashSet <Type> set) // where each Type obj : is typeof(IComponent) { Entity e = new Entity(name, set); entities.Add(name, e); OnEntityAdded?.Invoke(e); return(e); }
/// <summary> /// Dispatches entity adding logic /// </summary> internal void ProcessEntitiesForAdding() { while (EntitiesForAdding.Count != 0) { Entity entity = EntitiesForAdding.Dequeue(); Entities[entity.Id] = entity; OnEntityAdded?.Invoke(entity); } }
public void AddEntity(ECSEntity entity) { if (!entities.Contains(entity)) { entities.Add(entity); OnEntityAdded?.Invoke(entity); entity.OnComponentAdded += cmp => { OnComponentAddedToEntity?.Invoke(entity, cmp); }; entity.OnComponentRemoved += cmp => OnComponentRemovedToEntity?.Invoke(entity, cmp); } }
public void Add <T>(T t) where T : IDbEntity { AddType <T>(); Type type = typeof(T); int id = ++IndexTracker[type]; t.EntityId = id; Database[type].Add(t); ApplyChanges(); OnDatabaseChanged?.Invoke(this); OnEntityAdded?.Invoke(t); }
public DecentralandEntity CreateEntity(string id) { SceneController.i.OnMessageDecodeStart?.Invoke("CreateEntity"); tmpCreateEntityMessage.id = id; SceneController.i.OnMessageDecodeEnds?.Invoke("CreateEntity"); if (entities.ContainsKey(tmpCreateEntityMessage.id)) { return(entities[tmpCreateEntityMessage.id]); } var newEntity = new DecentralandEntity(); newEntity.entityId = tmpCreateEntityMessage.id; // We need to manually create the Pool for empty game objects if it doesn't exist if (!PoolManager.i.ContainsPool(EMPTY_GO_POOL_NAME)) { GameObject go = new GameObject(); Pool pool = PoolManager.i.AddPool(EMPTY_GO_POOL_NAME, go, maxPrewarmCount: ENTITY_POOL_PREWARM_COUNT); pool.ForcePrewarm(); } // As we know that the pool already exists, we just get one gameobject from it PoolableObject po = PoolManager.i.Get(EMPTY_GO_POOL_NAME); newEntity.gameObject = po.gameObject; newEntity.gameObject.name = "ENTITY_" + tmpCreateEntityMessage.id; newEntity.gameObject.transform.SetParent(gameObject.transform, false); newEntity.gameObject.SetActive(true); newEntity.scene = this; newEntity.OnCleanupEvent += po.OnCleanup; if (SceneController.i.useBoundariesChecker) { newEntity.OnShapeUpdated += SceneController.i.boundariesChecker.AddEntityToBeChecked; } entities.Add(tmpCreateEntityMessage.id, newEntity); OnEntityAdded?.Invoke(newEntity); return(newEntity); }
public DecentralandEntity CreateEntity(string id) { SceneController.i.OnMessageDecodeStart?.Invoke("CreateEntity"); SceneController.i.OnMessageDecodeEnds?.Invoke("CreateEntity"); if (entities.ContainsKey(id)) { return(entities[id]); } var newEntity = new DecentralandEntity(); newEntity.entityId = id; SceneController.i.EnsureEntityPool(); // As we know that the pool already exists, we just get one gameobject from it PoolableObject po = PoolManager.i.Get(SceneController.EMPTY_GO_POOL_NAME); newEntity.gameObject = po.gameObject; #if UNITY_EDITOR newEntity.gameObject.name = "ENTITY_" + id; #endif newEntity.gameObject.transform.SetParent(gameObject.transform, false); newEntity.gameObject.SetActive(true); newEntity.scene = this; newEntity.OnCleanupEvent += po.OnCleanup; if (SceneController.i.useBoundariesChecker) { newEntity.OnShapeUpdated += SceneController.i.boundariesChecker.AddEntityToBeChecked; } entities.Add(id, newEntity); OnEntityAdded?.Invoke(newEntity); return(newEntity); }
public IDCLEntity CreateEntity(string id) { if (entities.ContainsKey(id)) { return(entities[id]); } var newEntity = new DecentralandEntity(); newEntity.entityId = id; Environment.i.world.sceneController.EnsureEntityPool(); // As we know that the pool already exists, we just get one gameobject from it PoolableObject po = PoolManager.i.Get(SceneController.EMPTY_GO_POOL_NAME); newEntity.meshesInfo.innerGameObject = po.gameObject; newEntity.gameObject = po.gameObject; newEntity.transform = po.gameObject.transform; #if UNITY_EDITOR newEntity.gameObject.name = "ENTITY_" + id; #endif newEntity.gameObject.transform.SetParent(gameObject.transform, false); newEntity.gameObject.SetActive(true); newEntity.scene = this; newEntity.OnCleanupEvent += po.OnCleanup; if (Environment.i.world.sceneBoundsChecker.enabled) { newEntity.OnShapeUpdated += Environment.i.world.sceneBoundsChecker.AddEntityToBeChecked; } entities.Add(id, newEntity); OnEntityAdded?.Invoke(newEntity); return(newEntity); }
/// <summary> /// Adds an entity to this pool /// </summary> public void Add(Entity entity) { entities.Add(entity); OnEntityAdded?.Invoke(this, entity); }
public void TriggerEntityAdded(Entity entity) { OnEntityAdded?.Invoke(entity); }
public void AddNewEntity(Entity entity) { entities.Add(entity.Name, entity); OnEntityAdded?.Invoke(entity); }
internal static void RaiseEntityAdded(Entity entity) { OnEntityAdded?.Invoke(entity); }