static void BuildEntity(EGID entityID, FasterDictionary <RefWrapperType, ITypeSafeDictionary> group , IComponentBuilder componentBuilder, IEnumerable <object> implementors) { var entityComponentType = componentBuilder.GetEntityComponentType(); var safeDictionary = group.GetOrCreate(new RefWrapperType(entityComponentType), (ref IComponentBuilder cb) => cb.CreateDictionary(1), ref componentBuilder); //if the safeDictionary hasn't been created yet, it will be created inside this method. componentBuilder.BuildEntityAndAddToList(safeDictionary, entityID, implementors); }
static void BuildEntity(EGID entityID, FasterDictionary <RefWrapperType, ITypeSafeDictionary> group, Type entityComponentType, IComponentBuilder componentBuilder, IEnumerable <object> implementors) { var entityComponentsPoolWillBeCreated = group.TryGetValue(new RefWrapperType(entityComponentType), out var safeDictionary) == false; //passing the undefined entityComponentsByType inside the entityComponentBuilder will allow it to be created with the //correct type and casted back to the undefined list. that's how the list will be eventually of the target //type. componentBuilder.BuildEntityAndAddToList(ref safeDictionary, entityID, implementors); if (entityComponentsPoolWillBeCreated) { group.Add(new RefWrapperType(entityComponentType), safeDictionary); } }