public void ctor(ProcessManager manager) { //Delegate to call the base constructor Type[] constructorSignature = new Type[2]; constructorSignature[0] = typeof(ProcessManager); constructorSignature[1] = typeof(ProcessManager.ProcessID); RuntimeMethodHandle handle = typeof(Menu.Menu).GetConstructor(constructorSignature).MethodHandle; RuntimeHelpers.PrepareMethod(handle); IntPtr ptr = handle.GetFunctionPointer(); Action <ProcessManager, ProcessManager.ProcessID> funct = (Action <ProcessManager, ProcessManager.ProcessID>)Activator.CreateInstance(typeof(Action <ProcessManager, ProcessManager.ProcessID>), this, ptr); funct(manager, ProcessManager.ProcessID.SlugcatSelect);//Menu.Menu Constructor pages.Add(new Menu.Page(this, null, "main", 0)); if (!manager.rainWorld.flatIllustrations) { rainEffect = new Menu.RainEffect(this, pages[0]); pages[0].subObjects.Add(rainEffect); } if (CheckUnlockRed()) { manager.rainWorld.progression.miscProgressionData.redUnlocked = true; } slugcatColorOrder = new int[] { 1, 0, 2 }; for (int i = 0; i < slugcatColorOrder.Length; i++) { if (slugcatColorOrder[i] == manager.rainWorld.progression.miscProgressionData.currentlySelectedSinglePlayerSlugcat) { slugcatPageIndex = i; } } slugcatPageIndex = 1; saveGameData = new Menu.SlugcatSelectMenu.SaveGameData[3]; for (int j = 0; j < 3; j++) { saveGameData[j] = MineForSaveData(manager, slugcatColorOrder[j]); } if (saveGameData[2] != null && ((saveGameData[2].redsDeath && saveGameData[2].cycle >= RedsIllness.RedsCycles(saveGameData[2].redsExtraCycles)) || saveGameData[2].ascended)) { redIsDead = true; } int num = 0; for (int k = 0; k < 3; k++) { if (saveGameData[k] != null) { num++; } } if (num == 1) { for (int l = 0; l < 3; l++) { if (saveGameData[l] != null) { slugcatPageIndex = l; break; } } } slugcatPages = new Menu.SlugcatSelectMenu.SlugcatPage[3]; for (int m = 0; m < slugcatPages.Length; m++) { if (saveGameData[m] != null) { slugcatPages[m] = new Menu.SlugcatSelectMenu.SlugcatPageContinue(this, null, 1 + m, slugcatColorOrder[m]); } else { slugcatPages[m] = new Menu.SlugcatSelectMenu.SlugcatPageNewGame(this, null, 1 + m, slugcatColorOrder[m]); } pages.Add(slugcatPages[m]); } startButton = new Menu.HoldButton(this, pages[0], string.Empty, "START", new Vector2(683f, 85f), 40f); pages[0].subObjects.Add(startButton); pages[0].subObjects.Add(new Menu.SimpleButton(this, pages[0], "BACK", "BACK", new Vector2(200f, 668f), new Vector2(110f, 30f))); //this.pages[0].subObjects.Add(new Menu.BigArrowButton(this, this.pages[0], "PREV", new Vector2(200f, 50f), -1)); //this.pages[0].subObjects.Add(new Menu.BigArrowButton(this, this.pages[0], "NEXT", new Vector2(1116f, 50f), 1)); //Removed access to other characters float textWidth = 85f; restartCheckbox = new Menu.CheckBox(this, pages[0], this, new Vector2(startButton.pos.x + 200f, 30f), textWidth, "Restart game", "RESTART"); pages[0].subObjects.Add(restartCheckbox); UpdateStartButtonText(); UpdateSelectedSlugcatInMiscProg(); mySoundLoopID = SoundID.MENU_Main_Menu_LOOP; }
/// <summary> /// Retrieves the region name to show it in the slugcat select menu /// </summary> private static void SlugcatPageContinue_ctor(On.Menu.SlugcatSelectMenu.SlugcatPageContinue.orig_ctor orig, Menu.SlugcatSelectMenu.SlugcatPageContinue self, Menu.Menu menu, Menu.MenuObject owner, int pageIndex, int slugcatNumber) { orig(self, menu, owner, pageIndex, slugcatNumber); if (self.saveGameData.shelterName != null && self.saveGameData.shelterName.Length > 2) { string regID = self.saveGameData.shelterName.Substring(0, 2); bool customRegion = true; List <string> vanillaRegions = CustomWorldMod.VanillaRegions().ToList(); for (int i = 0; i < vanillaRegions.Count; i++) { if (regID == vanillaRegions[i]) { customRegion = false; } } if (customRegion) { foreach (MenuObject label in self.subObjects) { if (label is MenuLabel && label == self.regionLabel && (label as MenuLabel).text.Length < 3) { string fullRegionName = "N / A"; //CustomWorldMod.activatedPacks.TryGetValue(text2, out fullRegionName); if (CustomWorldMod.activeModdedRegions.Contains(regID)) { foreach (KeyValuePair <string, string> entry in CustomWorldMod.activatedPacks) { if (CustomWorldMod.installedPacks[entry.Key].regions.Contains(regID)) { string regionName = CWorld.RegionHook.GetSubRegionName(entry.Value, regID); if (CustomWorldMod.installedPacks[entry.Key].useRegionName && regionName != null) { fullRegionName = regionName; CustomWorldMod.Log($"Displaying region name: [{fullRegionName}]. If your pack" + $"contains multiple regions, add \"useRegionName\" to the packInfo.json to use" + $"the Subregion field from the Properties.txt file"); } else { fullRegionName = entry.Key; CustomWorldMod.Log($"Displaying pack name: [{fullRegionName}]."); //[OUTDATED] If you pack contains multiple regions, contact @Garrakx."); } break; } } } if (fullRegionName != null) { if (fullRegionName.Length > 0) { regID = fullRegionName; fullRegionName = string.Concat(new object[] { regID, " - ", menu.Translate("Cycle"), " ", (slugcatNumber != 2) ? self.saveGameData.cycle : (RedsIllness.RedsCycles(self.saveGameData.redsExtraCycles) - self.saveGameData.cycle) }); } (label as MenuLabel).text = fullRegionName; break; } } } } } }
public void ctor(Menu.Menu menu, MenuObject owner, int pageIndex, int slugcatNumber) { orig_ctor(menu, owner, pageIndex, slugcatNumber); hud.ClearAllSprites(); hudContainers = new FContainer[2]; for (int i = 0; i < hudContainers.Length; i++) { hudContainers[i] = new FContainer(); Container.AddChild(hudContainers[i]); } hud = new HUD.HUD(hudContainers, menu.manager.rainWorld, this); saveGameData.karma = Custom.IntClamp(saveGameData.karma, 0, saveGameData.karmaCap); saveGameData.food = Custom.IntClamp(saveGameData.food, 0, SlugcatStats.SlugcatFoodMeter(slugcatNumber).y); hud.AddPart(new KarmaMeter(hud, hudContainers[1], new IntVector2(saveGameData.karma, saveGameData.karmaCap), saveGameData.karmaReinforced)); hud.AddPart(new FoodMeter(hud, SlugcatStats.SlugcatFoodMeter(slugcatNumber).x, SlugcatStats.SlugcatFoodMeter(slugcatNumber).y)); string text = String.Empty; if (saveGameData.shelterName != null && saveGameData.shelterName.Length > 2) { string text2 = saveGameData.shelterName.Substring(0, 2); switch (text2) { case "CC": text = "Chimney Canopy"; break; case "DS": text = "Drainage System"; break; case "HI": text = "Industrial Complex"; break; case "GW": text = "Garbage Wastes"; break; case "SI": text = "Sky Islands"; break; case "SU": text = "Outskirts"; break; case "SH": text = "Shaded Citadel"; break; case "IS": text = "Intake System"; break; case "SL": text = "Shoreline"; break; case "LF": text = "Farm Arrays"; break; case "UW": text = "The Exterior"; break; case "SB": text = "Subterranean"; break; case "SS": text = "Five Pebbles"; break; case "LM": text = "Looks To the Moon"; break; case "MW": text = "The Fragmented Exterior"; break; case "FS": text = "Forest Sanctuary"; break; } if (text.Length > 0) { text2 = text; text = string.Concat(new object[] { text2, " - ", menu.Translate("Cycle"), " ", (slugcatNumber != 2) ? saveGameData.cycle : (RedsIllness.RedsCycles(saveGameData.redsExtraCycles) - saveGameData.cycle) }); } } regionLabel = new MenuLabel(menu, this, text, new Vector2(-1000f, imagePos.y - 249f), new Vector2(200f, 30f), true); regionLabel.label.alignment = FLabelAlignment.Center; subObjects.Add(regionLabel); }
private static void SaveState_LoadGame(On.SaveState.orig_LoadGame orig, SaveState self, string str, RainWorldGame game) { self.loaded = true; self.redExtraCycles = false; self.initiatedInGameVersion = 0; if (str == string.Empty) { Debug.Log("NOTHING TO LOAD - START CLEAR"); self.denPosition = ((self.saveStateNumber != 2) ? "SU_C04" : "LF_H01"); } else { string[] array = Regex.Split(str, "<svA>"); List <string[]> list = new List <string[]>(); for (int i = 0; i < array.Length; i++) { string[] array2 = Regex.Split(array[i], "<svB>"); if (array2.Length > 0 && array2[0].Length > 0) { list.Add(array2); } } int j = 0; while (j < list.Count) { string text = list[j][0]; if (text == null) { goto IL_66F; } Dictionary <string, int> dictionary = new Dictionary <string, int>(24); dictionary.Add("SAV STATE NUMBER", 0); dictionary.Add("DENPOS", 1); dictionary.Add("CYCLENUM", 2); dictionary.Add("FOOD", 3); dictionary.Add("NEXTID", 4); dictionary.Add("HASTHEGLOW", 5); dictionary.Add("GUIDEOVERSEERDEAD", 6); dictionary.Add("RESPAWNS", 7); dictionary.Add("WAITRESPAWNS", 8); dictionary.Add("REGIONSTATE", 9); dictionary.Add("COMMUNITIES", 10); dictionary.Add("MISCWORLDSAVEDATA", 11); dictionary.Add("DEATHPERSISTENTSAVEDATA", 12); dictionary.Add("SWALLOWEDITEMS", 13); dictionary.Add("VERSION", 14); dictionary.Add("INITVERSION", 15); dictionary.Add("WORLDVERSION", 16); dictionary.Add("SEED", 17); dictionary.Add("DREAMSSTATE", 18); dictionary.Add("TOTFOOD", 19); dictionary.Add("TOTTIME", 20); dictionary.Add("CURRVERCYCLES", 21); dictionary.Add("KILLS", 22); dictionary.Add("REDEXTRACYCLES", 23); dictionary.Add("EXTRAINVENTORY", 24); int num; if (!dictionary.TryGetValue(text, out num)) { goto IL_66F; } switch (num) { case 0: break; case 1: self.denPosition = list[j][1]; break; case 2: self.cycleNumber = int.Parse(list[j][1]); break; case 3: self.food = int.Parse(list[j][1]); break; case 4: if (game != null) { game.nextIssuedId = int.Parse(list[j][1]); } break; case 5: self.theGlow = true; break; case 6: self.guideOverseerDead = true; break; case 7: { string[] array3 = list[j][1].Split(new char[] { '.' }); for (int k = 0; k < array3.Length; k++) { if (k < array3.Length) { self.respawnCreatures.Add(int.Parse(array3[k])); } } break; } case 8: { string[] array4 = list[j][1].Split(new char[] { '.' }); for (int l = 0; l < array4.Length; l++) { if (l < array4.Length) { self.waitRespawnCreatures.Add(int.Parse(array4[l])); } } break; } case 9: { string[] array5 = Regex.Split(list[j][1], "<rgA>"); for (int m = 0; m < array5.Length; m++) { if (Regex.Split(array5[m], "<rgB>")[0] == "REGIONNAME") { for (int n = 0; n < self.progression.regionNames.Length; n++) { if (self.progression.regionNames[n] == Regex.Split(array5[m], "<rgB>")[1]) { self.regionLoadStrings[n] = list[j][1]; break; } } break; } } break; } case 10: self.creatureCommunitiesString = list[j][1]; break; case 11: self.miscWorldSaveData.FromString(list[j][1]); break; case 12: self.deathPersistentSaveData.FromString(list[j][1]); if (self.saveStateNumber == 1) { self.deathPersistentSaveData.howWellIsPlayerDoing = -1f; } else if (self.saveStateNumber == 2) { self.deathPersistentSaveData.howWellIsPlayerDoing = 1f; } break; case 13: self.swallowedItems = new string[list[j].Length - 1]; for (int num2 = 1; num2 < list[j].Length; num2++) { self.swallowedItems[num2 - 1] = list[j][num2]; } break; case 14: self.gameVersion = int.Parse(list[j][1]); break; case 15: self.initiatedInGameVersion = int.Parse(list[j][1]); break; case 16: self.worldVersion = int.Parse(list[j][1]); break; case 17: self.seed = int.Parse(list[j][1]); break; case 18: self.dreamsState.FromString(list[j][1]); break; case 19: self.totFood = int.Parse(list[j][1]); break; case 20: self.totTime = int.Parse(list[j][1]); break; case 21: self.cyclesInCurrentWorldVersion = int.Parse(list[j][1]); break; case 22: { self.kills.Clear(); string[] array6 = Regex.Split(list[j][1], "<svC>"); for (int num3 = 0; num3 < array6.Length; num3++) { self.kills.Add(new KeyValuePair <IconSymbol.IconSymbolData, int>(IconSymbol.IconSymbolData.IconSymbolDataFromString(Regex.Split(array6[num3], "<svD>")[0]), int.Parse(Regex.Split(array6[num3], "<svD>")[1]))); } break; } case 23: self.redExtraCycles = true; break; case 24: { KarmaAppetite_ExtraInventory.InventorySave = list[j][1]; KarmaAppetite_ExtraInventory.Inventories.Clear(); break; } default: goto IL_66F; } IL_68A: j++; continue; IL_66F: Debug.Log("Unknown save state load string"); Debug.Log(list[j][0]); goto IL_68A; } } if (game != null) { if (game.setupValues.cheatKarma > 0) { self.deathPersistentSaveData.karma = game.setupValues.cheatKarma - 1; self.deathPersistentSaveData.karmaCap = Math.Max(self.deathPersistentSaveData.karmaCap, self.deathPersistentSaveData.karma); } if (game.setupValues.theMark) { self.deathPersistentSaveData.theMark = true; } if (self.worldVersion != game.rainWorld.worldVersion) { game.manager.rainWorld.progression.miscProgressionData.redUnlocked = true; BackwardsCompability.UpdateWorldVersion(self, game.rainWorld.worldVersion, game.rainWorld.progression); self.cyclesInCurrentWorldVersion = 0; } } else { Debug.Log("LOADING SAV WITH NULL GAME"); } if (self.deathPersistentSaveData.redsDeath && self.cycleNumber < RedsIllness.RedsCycles(self.redExtraCycles)) { self.deathPersistentSaveData.redsDeath = false; } }