Esempio n. 1
0
        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));
        }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
        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);
        }