Beispiel #1
0
        public void SetName(Entity entity, string name)
        {
            switch (Type)
            {
            case EntityManagerType.ENTITY_MANAGER:
#if UNITY_EDITOR
                EntityManager.SetName(entity, name);
#else
                EntityManager.AddComponentData(entity, new SetName {
                    Value = new FixedString64(name)
                });
#endif
                return;

            case EntityManagerType.ENTITY_COMMAND_BUFFER:
            case EntityManagerType.ENTITY_MANAGER_AND_COMMAND_BUFFER:
                EntityCommandBuffer.AddComponent(entity, new SetName {
                    Value = new FixedString64(name)
                });
                return;

            case EntityManagerType.ENTITY_COMMAND_BUFFER_CONCURRENT:
                EntityCommandBufferConcurrent.AddComponent(EntityCommandBufferJobIndex, entity, new SetName {
                    Value = new FixedString64(name)
                });
                return;
            }

            throw new NotImplementedException();
        }
Beispiel #2
0
        public Entity CreateEntity()
        {
            switch (Type)
            {
            case EntityManagerType.ENTITY_MANAGER:
                return(EntityManager.CreateEntity());

            case EntityManagerType.ENTITY_COMMAND_BUFFER:
                return(EntityCommandBuffer.CreateEntity());

            case EntityManagerType.ENTITY_COMMAND_BUFFER_CONCURRENT:
                return(EntityCommandBufferConcurrent.CreateEntity(EntityCommandBufferJobIndex));
            }

            throw new NotImplementedException();
        }
Beispiel #3
0
        public DynamicBuffer <T> AddBuffer <T>(Entity entity) where T : struct, IBufferElementData
        {
            switch (Type)
            {
            case EntityManagerType.ENTITY_MANAGER:
                return(EntityManager.AddBuffer <T>(entity));

            case EntityManagerType.ENTITY_COMMAND_BUFFER:
                return(EntityCommandBuffer.AddBuffer <T>(entity));

            case EntityManagerType.ENTITY_COMMAND_BUFFER_CONCURRENT:
                return(EntityCommandBufferConcurrent.AddBuffer <T>(EntityCommandBufferJobIndex, entity));
            }

            throw new NotImplementedException();
        }
Beispiel #4
0
        public Entity Instantiate(Entity prefabEntity)
        {
            switch (Type)
            {
            case EntityManagerType.ENTITY_MANAGER:
                return(EntityManager.Instantiate(prefabEntity));

            case EntityManagerType.ENTITY_COMMAND_BUFFER:
                return(EntityCommandBuffer.Instantiate(prefabEntity));

            case EntityManagerType.ENTITY_COMMAND_BUFFER_CONCURRENT:
                return(EntityCommandBufferConcurrent.Instantiate(EntityCommandBufferJobIndex, prefabEntity));
            }

            throw new NotImplementedException();
        }
Beispiel #5
0
        public void Destroy(Entity entity)
        {
            switch (Type)
            {
            case EntityManagerType.ENTITY_MANAGER:
                EntityManager.DestroyEntity(entity);
                return;

            case EntityManagerType.ENTITY_COMMAND_BUFFER:
                EntityCommandBuffer.DestroyEntity(entity);
                return;

            case EntityManagerType.ENTITY_COMMAND_BUFFER_CONCURRENT:
                EntityCommandBufferConcurrent.DestroyEntity(EntityCommandBufferJobIndex, entity);
                return;
            }
        }
Beispiel #6
0
        public Entity CreateEntityFromArchetype <T>() where T : IArchetypeDescriptor
        {
            var archetype = EntityArchetypeManager.Instance.GetOrCreateArchetype <T>();

            switch (Type)
            {
            case EntityManagerType.ENTITY_MANAGER:
                return(EntityManager.CreateEntity(archetype));

            case EntityManagerType.ENTITY_COMMAND_BUFFER:
            case EntityManagerType.ENTITY_MANAGER_AND_COMMAND_BUFFER:
                return(EntityCommandBuffer.CreateEntity(archetype));

            case EntityManagerType.ENTITY_COMMAND_BUFFER_CONCURRENT:
                return(EntityCommandBufferConcurrent.CreateEntity(EntityCommandBufferJobIndex, archetype));
            }

            throw new NotImplementedException();
        }
Beispiel #7
0
        public bool RemoveComponent <T>(Entity entity) where T : struct, IComponentData
        {
            switch (Type)
            {
            case EntityManagerType.ENTITY_MANAGER:
                return(EntityManager.RemoveComponent <T>(entity));

            case EntityManagerType.ENTITY_COMMAND_BUFFER:
            case EntityManagerType.ENTITY_MANAGER_AND_COMMAND_BUFFER:
                EntityCommandBuffer.RemoveComponent <T>(entity);
                return(true);

            case EntityManagerType.ENTITY_COMMAND_BUFFER_CONCURRENT:
                EntityCommandBufferConcurrent.RemoveComponent <T>(EntityCommandBufferJobIndex, entity);
                return(true);
            }

            throw new NotImplementedException();
        }
Beispiel #8
0
        public void AddSharedComponentData <T>(Entity entity, T component) where T : struct, ISharedComponentData
        {
            switch (Type)
            {
            case EntityManagerType.ENTITY_MANAGER:
                EntityManager.AddSharedComponentData(entity, component);
                return;

            case EntityManagerType.ENTITY_COMMAND_BUFFER:
                EntityCommandBuffer.AddSharedComponent(entity, component);
                return;

            case EntityManagerType.ENTITY_COMMAND_BUFFER_CONCURRENT:
                EntityCommandBufferConcurrent.AddSharedComponent(EntityCommandBufferJobIndex, entity, component);
                return;
            }

            throw new NotImplementedException();
        }
Beispiel #9
0
        public Entity CreateEntityFromArchetype(EntityArchetype archetype)
        {
            switch (Type)
            {
            case EntityManagerType.MOCK:
                return(Entity.Null);

            case EntityManagerType.ENTITY_MANAGER:
                return(EntityManager.CreateEntity(archetype));

            case EntityManagerType.ENTITY_COMMAND_BUFFER:
            case EntityManagerType.ENTITY_MANAGER_AND_COMMAND_BUFFER:
                return(EntityCommandBuffer.CreateEntity(archetype));

            case EntityManagerType.ENTITY_COMMAND_BUFFER_CONCURRENT:
                return(EntityCommandBufferConcurrent.CreateEntity(EntityCommandBufferJobIndex, archetype));
            }

            throw new NotImplementedException();
        }
Beispiel #10
0
        public bool RemoveComponent(Entity entity, ComponentType componentType)
        {
            switch (Type)
            {
            case EntityManagerType.MOCK:
                return(false);

            case EntityManagerType.ENTITY_MANAGER:
                return(EntityManager.RemoveComponent(entity, componentType));

            case EntityManagerType.ENTITY_COMMAND_BUFFER:
            case EntityManagerType.ENTITY_MANAGER_AND_COMMAND_BUFFER:
                EntityCommandBuffer.RemoveComponent(entity, componentType);
                return(true);

            case EntityManagerType.ENTITY_COMMAND_BUFFER_CONCURRENT:
                EntityCommandBufferConcurrent.RemoveComponent(EntityCommandBufferJobIndex, entity, componentType);
                return(true);
            }

            throw new NotImplementedException();
        }
Beispiel #11
0
        public void AppendToBuffer <T>(Entity entity, T bufferElementData) where T : struct, IBufferElementData
        {
            switch (Type)
            {
            case EntityManagerType.MOCK:
                return;

            case EntityManagerType.ENTITY_MANAGER:
                var buffer = EntityManager.HasComponent <T>(entity) ? EntityManager.GetBuffer <T>(entity) : EntityManager.AddBuffer <T>(entity);
                buffer.Add(bufferElementData);
                break;

            case EntityManagerType.ENTITY_MANAGER_AND_COMMAND_BUFFER:
                EntityCommandBuffer.AppendToBuffer(entity, bufferElementData);
                return;

            case EntityManagerType.ENTITY_COMMAND_BUFFER_CONCURRENT:
                EntityCommandBufferConcurrent.AppendToBuffer(EntityCommandBufferJobIndex, entity, bufferElementData);
                return;
            }

            throw new NotImplementedException("Adding component object only possible using EntityManager, not buffer");
        }