private static void PlayerProgression_LoadProgression(On.PlayerProgression.orig_LoadProgression orig, PlayerProgression self)
 {
     self.regionNames = CustomWorldMod.AddModdedRegions(self.regionNames);
     if (self.regionNames.Length != self.mapDiscoveryTextures.Length)
     {
         Array.Resize(ref self.mapDiscoveryTextures, self.regionNames.Length);
         CustomWorldMod.Log($"Custom Regions: Resizing mapDiscovery in PlayerProgression.");
     }
     self.miscProgressionData.discoveredShelters = new List <string> [self.regionNames.Length];
     orig(self);
 }
        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);
        }
        public static void UpdateProgresionCRS(PlayerProgression self)
        {
            self.regionNames = CustomWorldMod.AddModdedRegions(self.regionNames);

            if (self.regionNames.Length != self.mapDiscoveryTextures.Length)
            {
                Array.Resize(ref self.mapDiscoveryTextures, self.regionNames.Length);
                CustomWorldMod.Log($"Custom Regions: Resizing mapDiscovery in PlayerProgression.");
            }
            self.miscProgressionData.discoveredShelters = new List <string> [self.regionNames.Length];

            // Karma locks
            List <string> tempLocks = new List <string>(self.karmaLocks);

            foreach (KeyValuePair <string, string> keyValues in CustomWorldMod.activatedPacks)
            {
                CustomWorldMod.Log($"Custom Regions: Loading karmaGate requirement for {keyValues.Key}", false, CustomWorldMod.DebugLevel.FULL);
                string locksPath = CRExtras.BuildPath(keyValues.Value, CRExtras.CustomFolder.Gates, file: "locks.txt");
                if (File.Exists(locksPath))
                {
                    foreach (string line in File.ReadAllLines(locksPath))
                    {
                        if (!tempLocks.Contains(line) && !line.Equals(string.Empty))
                        {
                            tempLocks.Insert(0, line);
                        }
                    }
                }
                else
                {
                    CustomWorldMod.Log($"Custom Regions: {keyValues.Key} does not contain a locks.txt file", false, CustomWorldMod.DebugLevel.MEDIUM);
                }
            }

            self.karmaLocks = tempLocks.ToArray();
            CustomWorldMod.Log($"Loaded karmaGate requirements [{string.Join(", ", self.karmaLocks)}]", false, CustomWorldMod.DebugLevel.MEDIUM);
        }