///-------------------------------------------- /// void MoveEntity(IEntityBuilder[] entityBuilders, EGID entityGID, Type originalDescriptorType, EGID toEntityGID, Dictionary <Type, ITypeSafeDictionary> toGroup = null) { var profiler = new PlatformProfiler(); using (profiler.StartNewSession("Move Entity")) { //for each entity view generated by the entity descriptor Dictionary <Type, ITypeSafeDictionary> fromGroup; if (_groupEntityDB.TryGetValue(entityGID.groupID, out fromGroup) == false) { throw new ECSException("from group not found eid: " .FastConcat(entityGID.entityID).FastConcat(" group: ") .FastConcat(entityGID.groupID)); } ITypeSafeDictionary entityInfoViewDic; EntityInfoView entityInfoView = default; //Check if there is an EntityInfoView linked to this entity, if so it's a DynamicEntityDescriptor! bool correctEntityDescriptorFound = true; if (fromGroup.TryGetValue(_entityInfoView, out entityInfoViewDic) && (entityInfoViewDic as TypeSafeDictionary <EntityInfoView>).TryGetValue (entityGID.entityID, out entityInfoView) && (correctEntityDescriptorFound = entityInfoView.type == originalDescriptorType)) { var entitiesToMove = entityInfoView.entitiesToBuild; for (int i = 0; i < entitiesToMove.Length; i++) { MoveEntityView(entityGID, toEntityGID, toGroup, fromGroup, entitiesToMove[i].GetEntityType(), profiler); } } //otherwise it's a normal static entity descriptor else { #if DEBUG && !PROFILER if (correctEntityDescriptorFound == false) #if RELAXED_ECS { Console.LogError(INVALID_DYNAMIC_DESCRIPTOR_ERROR .FastConcat(" ID ").FastConcat(entityGID.entityID) .FastConcat(" group ID ").FastConcat(entityGID.groupID).FastConcat( " descriptor found: ", entityInfoView.type.Name, " descriptor Excepted ", originalDescriptorType.Name)); } #else { throw new ECSException(INVALID_DYNAMIC_DESCRIPTOR_ERROR.FastConcat(" ID ").FastConcat(entityGID.entityID) .FastConcat(" group ID ").FastConcat(entityGID.groupID).FastConcat( " descriptor found: ", entityInfoView.type.Name, " descriptor Excepted ", originalDescriptorType.Name)); } #endif #endif for (var i = 0; i < entityBuilders.Length; i++) { MoveEntityView(entityGID, toEntityGID, toGroup, fromGroup, entityBuilders[i].GetEntityType(), profiler); } } } }
void RemoveEntity(ref EntityInfoView entityInfoView, Dictionary <Type, ITypeSafeList> viewsDB, Dictionary <Type, ITypeSafeDictionary> entityViewsDBDic) { if (entityInfoView.isInAGroup) { InternalRemoveFromGroupAndDBAndEngines(entityInfoView.entityViews, entityInfoView.ID, entityInfoView.groupID, viewsDB, entityViewsDBDic); } else { InternalRemoveFromDBAndEngines(entityInfoView.entityViews, entityInfoView.ID, viewsDB, entityViewsDBDic); } }