Esempio n. 1
0
        public void DestroyEntity(Entity entity)
        {
            int index = GetIndexOfEntityInBuffer(entity);

            if (index != -1)
            {
                this.entitiesInBuffer[index].command = EntityCommand.Destroy;
                ComponentDataInBuffer.Free(this.entitiesInBuffer[index].componentData);
                return;
            }

            Add(new EntityInBuffer(entity, EntityCommand.Destroy));
        }
Esempio n. 2
0
        public bool AddOrSetComponentData <T>(Entity entity, T value) where T : unmanaged
        {
            int index = GetIndexOfEntityInBuffer(entity);

            if (index == -1)
            {
                index = Add(new EntityInBuffer(entity, EntityCommand.Modify));
            }

            var entityInBuffer = this.entitiesInBuffer[index];

            if (entityInBuffer.command == EntityCommand.Destroy)
            {
                return(false);
            }

            ComponentDataInBuffer.WriteToBuffer(entityInBuffer.componentData, value);

            return(true);
        }