private static void FastTravelScreen_InitiateRegionSwitch(On.Menu.FastTravelScreen.orig_InitiateRegionSwitch orig, Menu.FastTravelScreen self, int switchToRegion) { if (!checkFastTravelForCustom) { orig(self, switchToRegion); return; } int maxIndex = -1; foreach (SlugBaseCharacter ply in PlayerManager.customPlayers) { maxIndex = Mathf.Max(maxIndex, ply.slugcatIndex); } // Add custom characterse to the shelter list int oldLen = self.playerShelters.Length; if (oldLen < maxIndex) { ResizeToFit(ref self.playerShelters, maxIndex + 1, null); for (int i = oldLen; i < self.playerShelters.Length; i++) { self.playerShelters[i] = self.manager.rainWorld.progression.ShelterOfSaveGame(i); } } var prog = self.manager.rainWorld.progression; // Check the current slugcat for a shelter if (prog.PlayingAsSlugcat >= 0 && prog.PlayingAsSlugcat < self.playerShelters.Length && self.playerShelters[prog.PlayingAsSlugcat] != null) { self.currentShelter = self.playerShelters[prog.PlayingAsSlugcat]; } // Find the region that this shelter is in if (self.currentShelter != null) { string regionName = self.currentShelter.Substring(0, 2); for (int regionInd = 0; regionInd < self.accessibleRegions.Count; regionInd++) { if (self.allRegions[self.accessibleRegions[regionInd]].name == regionName) { Debug.Log(self.currentShelter); Debug.Log(string.Concat(new object[] { "actually found start region (including SlugBase saves): ", regionInd, " ", self.allRegions[self.accessibleRegions[regionInd]].name })); self.currentRegion = regionInd; break; } } } orig(self, self.currentRegion); }
private static void FastTravelScreen_InitiateRegionSwitch(On.Menu.FastTravelScreen.orig_InitiateRegionSwitch orig, FastTravelScreen self, int switchToRegion) { if (switchToRegion == 0 && self.currentRegion == 0) { if (temporalShelter != null) { self.currentShelter = temporalShelter; temporalShelter = null; } string shelter = self.currentShelter ?? string.Empty; CustomWorldMod.Log($"Initiate Region switch, called from Fast Travel ctor... [{shelter}]"); int num = 0; //string pathToVanillaRegions = Custom.RootFolderDirectory() + @"World\Regions\regions.txt"; string pathToVanillaRegions = CRExtras.BuildPath(null, CRExtras.CustomFolder.Regions, file: "regions.txt"); string[] array = File.ReadAllLines(pathToVanillaRegions); array = CustomWorldMod.AddModdedRegions(array); self.allRegions = new Region[array.Length]; for (int num2 = 0; num2 < self.allRegions.Length; num2++) { self.allRegions[num2] = new Region(array[num2], num, num2); num += self.allRegions[num2].numberOfRooms; } self.loadedWorlds = new World[self.accessibleRegions.Count]; self.loadedMapData = new HUD.Map.MapData[self.accessibleRegions.Count]; if (self.currentShelter != null) { for (int num3 = 0; num3 < self.accessibleRegions.Count; num3++) { if (self.allRegions[self.accessibleRegions[num3]].name == self.currentShelter.Substring(0, 2)) { CustomWorldMod.Log(self.currentShelter); CustomWorldMod.Log(string.Concat(new object[] { "found start region: ", num3, " ", self.allRegions[self.accessibleRegions[num3]].name })); self.currentRegion = num3; break; } } } switchToRegion = self.currentRegion; } orig(self, switchToRegion); }