private void CreateOrAttachToExistingRooms(int numRegionGroups) { for (int i = 0; i < numRegionGroups; i++) { currentRegionGroup.Clear(); for (int j = 0; j < newRegions.Count; j++) { if (newRegions[j].newRegionGroupIndex == i) { currentRegionGroup.Add(newRegions[j]); } } if (!currentRegionGroup[0].type.AllowsMultipleRegionsPerRoom()) { if (currentRegionGroup.Count != 1) { Log.Error("Region type doesn't allow multiple regions per room but there are >1 regions in this group."); } Room room = Room.MakeNew(map); currentRegionGroup[0].Room = room; newRooms.Add(room); } else { bool multipleOldNeighborRooms; Room room2 = FindCurrentRegionGroupNeighborWithMostRegions(out multipleOldNeighborRooms); if (room2 == null) { Room item = RegionTraverser.FloodAndSetRooms(currentRegionGroup[0], map, null); newRooms.Add(item); } else if (!multipleOldNeighborRooms) { for (int k = 0; k < currentRegionGroup.Count; k++) { currentRegionGroup[k].Room = room2; } reusedOldRooms.Add(room2); } else { RegionTraverser.FloodAndSetRooms(currentRegionGroup[0], map, room2); reusedOldRooms.Add(room2); } } } }
private void CreateOrAttachToExistingRooms(int numRegionGroups) { for (int i = 0; i < numRegionGroups; i++) { this.currentRegionGroup.Clear(); for (int j = 0; j < this.newRegions.Count; j++) { if (this.newRegions[j].newRegionGroupIndex == i) { this.currentRegionGroup.Add(this.newRegions[j]); } } if (!this.currentRegionGroup[0].type.AllowsMultipleRegionsPerRoom()) { if (this.currentRegionGroup.Count != 1) { Log.Error("Region type doesn't allow multiple regions per room but there are >1 regions in this group."); } Room room = Room.MakeNew(this.map); this.currentRegionGroup[0].Room = room; this.newRooms.Add(room); } else { bool flag = default(bool); Room room2 = this.FindCurrentRegionGroupNeighborWithMostRegions(out flag); if (room2 == null) { Room item = RegionTraverser.FloodAndSetRooms(this.currentRegionGroup[0], this.map, null); this.newRooms.Add(item); } else if (!flag) { for (int k = 0; k < this.currentRegionGroup.Count; k++) { this.currentRegionGroup[k].Room = room2; } this.reusedOldRooms.Add(room2); } else { RegionTraverser.FloodAndSetRooms(this.currentRegionGroup[0], this.map, room2); this.reusedOldRooms.Add(room2); } } } }