public void RemoveComponent(EntityQuery entityQuery, ComponentTypes types) { if (entityQuery.CalculateLength() == 0) { return; } // @TODO: Opportunity to do all components in batch on a per chunk basis. for (int i = 0; i != types.Length; i++) { RemoveComponent(entityQuery, types.GetComponentType(i)); } }
public static T[] ToComponentArray <T>(this EntityQuery group) where T : Component { int length = group.CalculateLength(); ComponentChunkIterator iterator = group.GetComponentChunkIterator(); var indexInComponentGroup = group.GetIndexInEntityQuery(TypeManager.GetTypeIndex <T>()); iterator.IndexInEntityQuery = indexInComponentGroup; var arr = new T[length]; var cache = default(ComponentChunkCache); for (int i = 0; i < length; ++i) { if (i < cache.CachedBeginIndex || i >= cache.CachedEndIndex) { iterator.MoveToEntityIndexAndUpdateCache(i, out cache, true); } arr[i] = (T)iterator.GetManagedObject(group.ManagedComponentStore, cache.CachedBeginIndex, i); } return(arr); }