bool QueryEntitySafeDictionary <T>(int @group, out TypeSafeDictionary <T> typeSafeDictionary) where T : IEntityStruct { Dictionary <Type, ITypeSafeDictionary> entitiesInGroupPerType; typeSafeDictionary = null; //search for the group if (_groupEntityViewsDB.TryGetValue(@group, out entitiesInGroupPerType) == false) { return(false); } //search for the indexed entities in the group ITypeSafeDictionary safeDictionary; if (entitiesInGroupPerType.TryGetValue(typeof(T), out safeDictionary) == false) { return(false); } //return the indexes entities if they exist typeSafeDictionary = (safeDictionary as TypeSafeDictionary <T>); return(true); }
static void SafetyChecks <T>(TypeSafeDictionary <T> typeSafeDictionary, int count) where T : IEntityStruct { if (typeSafeDictionary.Count != count) { throw new ECSException("Entities cannot be swapped or removed during an iteration"); } }
public void ExecuteOnAllEntities <T, W>(ref W value, ActionRef <T, W> action) where T : IEntityStruct { int count; var typeSafeDictionaries = _groupedGroups[typeof(T)].GetFasterValuesBuffer(out count); for (int j = 0; j < count; j++) { int count2; var safedic = typeSafeDictionaries[j]; TypeSafeDictionary <T> casted = safedic as TypeSafeDictionary <T>; var entities = casted.GetFasterValuesBuffer(out count2); for (int i = 0; i < count2; i++) { action(ref entities[i], ref value); } } }
bool FindSafeDictionary <T>(EGID entityGID, out TypeSafeDictionary <T> casted) where T : IEntityStruct { var type = typeof(T); ITypeSafeDictionary entityViews; Dictionary <Type, ITypeSafeDictionary> entitiesInGroupPerType; if (_groupEntityViewsDB.TryGetValue(entityGID.groupID, out entitiesInGroupPerType) == false) { casted = null; return(false); } entitiesInGroupPerType.TryGetValue(type, out entityViews); casted = entityViews as TypeSafeDictionary <T>; return(true); }