Beispiel #1
0
        public ref T GetComponent <T>()
        {
            var t = (ComponentData <T>)Chunk.ComponentDatas[ComponentTypeManager.GetTypeIndex <T>()];

            if (t == null)
            {
                throw new EntitiesException($"Entity doesn't have component of type \"{typeof(T)}\"");
            }
            return(ref t[IndexInChunk]);
        }
Beispiel #2
0
        public void SetComponent <T>(T data)
        {
            var t = (ComponentData <T>)Chunk.ComponentDatas[ComponentTypeManager.GetTypeIndex <T>()];

            if (t == null)
            {
                throw new EntitiesException($"Entity doesn't have component of type \"{typeof(T)}\"");
            }
            t[IndexInChunk] = data;
        }
Beispiel #3
0
 public static ComponentType Create(Type type)
 {
     return(new ComponentType(ComponentTypeManager.GetTypeIndex(type)));
 }
Beispiel #4
0
        public bool HasNotNullComponent <T>() where T : class
        {
            var chunkComponentData = Chunk.ComponentDatas[ComponentTypeManager.GetTypeIndex <T>()];

            return(((ComponentData <T>)chunkComponentData)?[IndexInChunk] != null);
        }
Beispiel #5
0
 public static ComponentType Create <T>()
 {
     return(new ComponentType(ComponentTypeManager.GetTypeIndex <T>()));
 }