public void RemoveEntity(ECSEntityHandle entity) { foreach (Tuple <Type, int> i in entity.Components) { poolHandler.RemoveComponent(i.Item1, entity); } entityHandler.RemoveEntity(entity); }
public void RemoveComponent(Type type, ECSEntityHandle entity) { if (valuePairs.ContainsKey(type)) { int ComponentPoolID = valuePairs[type]; ((ECSComponentPool)EcsComponentPools[ComponentPoolID]).RemoveFromEntity(entity); } }
public void AddComponent(object component, ECSEntityHandle entity) { Type componentType = component.GetType(); if (valuePairs.ContainsKey(componentType)) { int ComponentPoolID = valuePairs[component.GetType()]; ((ECSComponentPool)EcsComponentPools[ComponentPoolID]).AddToEntity(component, entity); } }
public object GetComponent(Type type, ECSEntityHandle entity) { if (!entityHandler.HasKey(entity.ID)) { throw new Exception("Cannot Find component from entity: Invalid Entity ID"); } if (!entity.HasComponent(type)) { throw new Exception("Entity does not have that component type:" + type.Name); } return(poolHandler.GetPool(type).GetFromEntity(entity)); }
public void RemoveComponent(Type type, ECSEntityHandle entity) { if (entityHandler.HasKey(entity.ID)) { throw new Exception("Cannot remove component from entity: Invalid Entity ID"); } if (!entity.HasComponent(type)) { throw new Exception("Cannot remove component from entity: Entity does not have component of type: " + type.Name); } poolHandler.RemoveComponent(type, entity); }
public void AddComponent(object component, ECSEntityHandle entity) { if (!entityHandler.HasKey(entity.ID)) { throw new Exception("Cannot add component from entity: Invalid Entity ID"); } if (entity.HasComponent(component)) { throw new Exception("Cannot add component from entity: Entity already has component of type: " + component.GetType().Name); } poolHandler.AddComponent(component, entity); }
public void RemoveFromEntity(ECSEntityHandle entity) { Tuple <Type, int> componentIDPair = entity.Components.Find(x => x.Item1 == ComponentType); Components.Recycle(componentIDPair.Item2); }
public object GetFromEntity(ECSEntityHandle entity) { return(Components.Find(x => x.Item2 == entity)); }
public void AddToEntity(object Component, ECSEntityHandle entity) { int Index = Components.Add(Tuple.Create(Component, entity)); entity.Components.Add(new Tuple <Type, int>(ComponentType, Index)); }