Example #1
0
        public Entity CreateEntity()
        {
            var    index = _entities.Peek();
            Entity e;

            if (index.HasValue)
            {
                e = new Entity(index.Value, _entities.Buffer[index.Value].Version + 1);
            }
            else
            {
                e = new Entity(_entities.Count, 0);
            }

            _entities.Add(e);
            return(e);
        }
Example #2
0
        public int Add(Entity e, T value)
        {
            if (!typeof(T).Equals(Type))
            {
                throw new Exception("Tried to add component to list with different type");
            }

            int?exists = _sparsedEntities[e.Index];

            if (exists.HasValue)
            {
                return(exists.Value);
            }

            int pos = _components.Add(value);

            _sparsedEntities[e.Index] = pos;
            _packedEntities[pos]      = e.Index;

            return(pos);
        }
Example #3
0
 public void AddEntity(Entity entity)
 {
     Entities.Add(entity);
 }