private static void WaterGate_ctor(On.WaterGate.orig_ctor orig, WaterGate self, Room room) { /* * foreach (KeyValuePair<string, CustomWorldMod.RegionInformation> entries in CustomWorldMod.availableRegions) * { * if (!entries.Value.activated || entries.Value.electricGates == null || entries.Value.electricGates.Count == 0) * { * continue; * } * * if (entries.Value.electricGates.ContainsKey(room.abstractRoom.name)) * { * CustomWorldMod.Log($"This gate [{room.abstractRoom.name}] should be electric gate, returning..."); * return; * } * } */ CustomWorldMod.Log("Water gate created, checking if it should be electric..."); foreach (KeyValuePair <string, string> regions in CustomWorldMod.activatedPacks) { if (CustomWorldMod.installedPacks[regions.Key].electricGates != null) { if (CustomWorldMod.installedPacks[regions.Key].electricGates.ContainsKey(room.abstractRoom.name)) { CustomWorldMod.Log($"This gate [{room.abstractRoom.name}] should be electric gate, returning..."); return; } } } orig(self, room); }
private static void PlayerProgression_SaveToDisk(On.PlayerProgression.orig_SaveToDisk orig, PlayerProgression self, bool saveCurrentState, bool saveMaps, bool saveMiscProg) { // Check if first time saved string saveFileName = Custom.RootFolderDirectory() + CustomWorldMod.regionSavePath + $"CRsav_{self.rainWorld.options.saveSlot + 1}.txt"; CustomWorldMod.Log($"CR save data path [{saveFileName}]"); if (!File.Exists(saveFileName)) { string saveRegionData = string.Empty; //dictionaryString += $"{ string.Join(", ", new List<string>(CustomWorldMod.loadedRegions.Values).ToArray())}" + "}"; //saveRegionData += $"{CustomWorldMod.saveDividerA}REGIONLIST{string.Join(",",CustomWorldMod.loadedRegions.Keys.ToArray())}{CustomWorldMod.saveDividerA}"; foreach (KeyValuePair <string, string> keyValues in CustomWorldMod.activatedPacks) { if (CustomWorldMod.installedPacks.TryGetValue(keyValues.Key, out RegionPack regionInfo)) { saveRegionData += CustomWorldMod.SerializeRegionInfo(regionInfo); } } // WRITE FILE using (StreamWriter streamWriter = File.CreateText(saveFileName)) { CustomWorldMod.Log($"Creating save log [{saveRegionData}]"); streamWriter.Write(Custom.Md5Sum(saveRegionData) + saveRegionData); } } orig(self, saveCurrentState, saveMaps, saveMiscProg); }
private static void RainWorld_Start(On.RainWorld.orig_Start orig, RainWorld self) { CustomWorldMod.LoadCustomWorldResources(); CustomWorldMod.rainWorldInstance = self; orig(self); }
private static void MainLoopProcess_Update(On.MainLoopProcess.orig_Update orig, MainLoopProcess self) { CustomWorldMod.scripts.RemoveAll(x => x == null); //foreach(CustomRegionScript script in CustomWorldMod.scripts) for (int i = CustomWorldMod.scripts.Count - 1; i >= 0; i--) { CustomWorldScript script = CustomWorldMod.scripts[i]; { if (script != null) { if (script.readyToDelete) { script.Clear(); //CustomWorldMod.Log($"Destroying script [{script.name}]"); //UnityEngine.Object.Destroy(script); CustomWorldMod.scripts.Remove(script); script = null; CustomWorldMod.Log($"Scripts count [{CustomWorldMod.scripts.Count}]"); } else { script.Update(); } } } } }
public virtual void Clear() { stopwatch.Stop(); DateTime date2 = new DateTime(stopwatch.ElapsedTicks); CustomWorldMod.Log($"[{this.name}] Clearing [{this.ID}]. Total time Elapsed [{date2.ToString("s.ffff")}s]", false, CustomWorldMod.DebugLevel.RELEASE); }
// Only called from Dev-tools R private static void RainWorldGame_RestartGame(On.RainWorldGame.orig_RestartGame orig, RainWorldGame self) { orig(self); if (UnityEngine.Input.GetKey(UnityEngine.KeyCode.LeftShift)) { CustomWorldMod.Log("\nResetting CRS ... \n"); CustomWorldMod.LoadCustomWorldResources(); // Line above resets progression, including map discovery textures... // Fix nullref on map discovery in the frame of the reset lol for (int num = 0; num < self.cameras.Length; num++) { self.cameras[num].hud.ResetMap(new HUD.Map.MapData(self.world, self.rainWorld)); if (self.cameras[num].hud.textPrompt.subregionTracker != null) { self.cameras[num].hud.textPrompt.subregionTracker.lastShownRegion = 0; } } } else { CustomWorldMod.Log("Hold [shift]+[r] to also reset CRS packs and configuration"); } }
private static void FlyGraphics_ctor(On.FlyGraphics.orig_ctor orig, FlyGraphics self, PhysicalObject ow) { orig(self, ow); customColor = null; World world = ow.abstractPhysicalObject.world; if (world != null && !world.singleRoomWorld && world.region != null) { foreach (KeyValuePair <string, string> keyValues in CustomWorldMod.activatedPacks) { if (CustomWorldMod.installedPacks[keyValues.Key].regionConfig.TryGetValue(world.region.name, out CustomWorldStructs.RegionConfiguration config)) { if (!config.batVanilla) { CustomWorldMod.Log($"Glowing batfly in [{world.region.name}] from [{CustomWorldMod.installedPacks[keyValues.Key].name}]", false, CustomWorldMod.DebugLevel.FULL); customColor = config.batFlyColor; break; } } } } }
private static void MapPage_LoadMapConfig(On.DevInterface.MapPage.orig_LoadMapConfig orig, MapPage self) { string mapPath = string.Empty; bool loadedMap = false; // Iterate backwards, leaving the first activated region as filePath, but loading the info from the rest. for (int i = CustomWorldMod.activatedPacks.Count - 1; i >= 0; i--) { KeyValuePair <string, string> keyValues = CustomWorldMod.activatedPacks.ElementAt(i); mapPath = CRExtras.BuildPath(keyValues.Value, CRExtras.CustomFolder.RegionID, regionID: self.owner.game.world.name, file: "map_" + self.owner.game.world.name + ".txt"); if (File.Exists(mapPath)) { loadedMap = true; CustomWorldMod.Log($"[DEV] New map filepath for [{keyValues.Value}]"); self.filePath = mapPath; orig(self); } } if (!loadedMap) { orig(self); } }
private static AbstractRoomNode World_GetNode(On.World.orig_GetNode orig, World self, WorldCoordinate c) { bool foundError = false; try { if (self.GetAbstractRoom(c.room) == null) { foundError = true; CustomWorldMod.Log("ERROR at GetNode !!! c.room Abstract is null", true); } else if (self.GetAbstractRoom(c.room).nodes == null) { foundError = true; CustomWorldMod.Log("ERROR at GetNode !!! abstractRoomNodes is null", true); } else if (self.GetAbstractRoom(c.room).nodes.Length < 1) { foundError = true; CustomWorldMod.Log("ERROR at GetNode !!! abstractRoomNodes is empty", true); } } catch (Exception e) { CustomWorldMod.Log("ERROR!" + e, true); } if (foundError) { CustomWorldMod.Log("Fatal error while loading the world. This is probably caused by a broken connection. " + "Make sure you are not missing a comp patch.", true); } return(orig(self, c)); }
private static string[] PlayerProgression_GetProgLines(On.PlayerProgression.orig_GetProgLines orig, PlayerProgression self) { const string mapHeader = "MAP<progDivB>"; bool WillCrashUponSave(string line) { return(line.StartsWith(mapHeader) && !self.regionNames.Any(acro => line.Length >= mapHeader.Length + acro.Length && line.Substring(mapHeader.Length, acro.Length) == acro)); } string[] lines = orig(self); if (removeMapLines && lines.Any(WillCrashUponSave)) { foreach (var line in lines.Where(WillCrashUponSave)) { string regionName; try { regionName = line.Substring(mapHeader.Length, 2); } catch { regionName = "ERROR"; } CustomWorldMod.Log($"Removed map progression for region: {regionName}"); } lines = lines.Where(line => !WillCrashUponSave(line)).ToArray(); } return(lines); }
private static UnityEngine.AudioClip SoundLoader_RequestAmbientAudioClip(On.SoundLoader.orig_RequestAmbientAudioClip orig, SoundLoader self, string clipName) { foreach (KeyValuePair <string, string> keyValues in CustomWorldMod.activatedPacks) { string ambientPath = CRExtras.BuildPath(keyValues.Value, CRExtras.CustomFolder.Ambient); string clipPath = Path.Combine(ambientPath, clipName); CustomWorldMod.Log($"[SoundLoader] Loading new audioClip at [{clipPath}] from [{keyValues.Key}]", false, CustomWorldMod.DebugLevel.FULL); if (File.Exists(clipPath)) { for (int j = 0; j < self.ambientImporters.Count; j++) { if (self.ambientImporters[j].fileName == clipName) { CustomWorldMod.Log($"[SoundLoader] AudioClip already loaded [{clipPath}] from [{keyValues.Key}]", false, CustomWorldMod.DebugLevel.FULL); return(self.ambientImporters[j].loadedClip); } } if (self.gameObject == null) { self.gameObject = new GameObject("CustomSoundLoader"); } CustomWorldMod.Log($"[SoundLoader] Loaded new audioClip at [{clipPath}] from [{keyValues.Key}]", false, CustomWorldMod.DebugLevel.FULL); SoundLoader.AmbientImporter ambientImporter = self.gameObject.AddComponent <SoundLoader.AmbientImporter>(); ambientImporter.fileName = clipName; self.ambientImporters.Add(ambientImporter); ambientImporter.absolutePath = ambientPath; ambientImporter.Init(self); return(null); /* * // File already loaded * for (int i = 0; i < self.ambientClipsThroughUnity.Count; i++) * { * if (self.ambientClipsThroughUnity[i].name == clipName) * { * CustomWorldMod.Log($"[SoundLoader] AudioClip already loaded [{clipPath}] from [{keyValues.Key}]", false, CustomWorldMod.DebugLevel.FULL); * return self.ambientClipsThroughUnity[i]; * } * } * WWW www = new WWW("file://" + clipPath); * AudioClip audioClip = www.GetAudioClip(false, false, AudioType.OGGVORBIS); * if (audioClip == null) * { * CustomWorldMod.Log($"[SoundLoader] Error loading file [{"file://" + clipPath}]", true); * return null; * } * audioClip.name = clipName; * self.ambientClipsThroughUnity.Add(audioClip); * CustomWorldMod.Log($"[SoundLoader] Loaded new audioClip at [{clipPath}] from [{keyValues.Key}]", false, CustomWorldMod.DebugLevel.FULL); * return audioClip; */ } } return(orig(self, clipName)); }
private static string AbstractDataPearl_ToString(On.DataPearl.AbstractDataPearl.orig_ToString orig, DataPearl.AbstractDataPearl self) { /* * DataPearl.AbstractDataPearl.DataPearlType backUpType = self.pearlType; * * if (backUpType > DataPearl.AbstractDataPearl.DataPearlType.Red_stomach) * { * self.pearlType = (DataPearl.AbstractDataPearl.DataPearlType)CustomWorldMod.customPearls.First(x => x.Value.name.Equals(backUpType.ToString())).Key; * } * CustomWorldMod.Log($"DataPearl to string. PearlType [{self.pearlType}] [{backUpType.ToString()}]"); * string toString = orig(self); * self.pearlType = backUpType; * return toString; */ DataPearl.AbstractDataPearl.DataPearlType backUpType = self.dataPearlType; KeyValuePair <int, CustomWorldStructs.CustomPearl> entry = CustomWorldMod.customPearls.FirstOrDefault(x => x.Value.name.Equals(backUpType.ToString())); // Pearl is not vanilla if (!entry.Equals(default(KeyValuePair <int, CustomWorldStructs.CustomPearl>))) { self.dataPearlType = (DataPearl.AbstractDataPearl.DataPearlType)entry.Key; } CustomWorldMod.Log($"AbstractDataPearl to string. PearlType [{self.dataPearlType}] [{backUpType.ToString()}]"); string toString = orig(self); self.dataPearlType = backUpType; return(toString); //CustomWorldMod.Log($"PearlData to string [{string.Concat(array)}] - PearlTypeHas [{num2}] - PearlType [{CustomWorldMod.customPearls[num2].name}]"); //int num2 = CustomWorldMod.customPearls.First(x => x.Value.name.Equals(self.dataPearlType.ToString())).Key; }
/// <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)) { fullRegionName = entry.Value; CustomWorldMod.Log($"Displaying region name: [{fullRegionName}]. 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; } } } } } }
private static void SlugcatSelectMenu_ctor(On.Menu.SlugcatSelectMenu.orig_ctor orig, SlugcatSelectMenu self, ProcessManager manager) { orig(self, manager); int saveSlot = self.manager.rainWorld.options.saveSlot; if (CustomWorldMod.saveProblems[saveSlot].AnyProblems) { bool allNewGame = true; string errorText = CustomWorldMod.Translate("Problems found in your save, please check the tab SaveAnalyzer in the config screen for more information."); for (int m = 0; m < self.slugcatPages.Length; m++) { if (self.saveGameData[m] != null) { allNewGame = false; break; } } if (allNewGame) { errorText = CustomWorldMod.Translate("Problems found in your save, please use the Reset Progress button in the RW options menu"); } MenuLabel menuLabel = new MenuLabel(self, self.pages[0], errorText, new Vector2(self.manager.rainWorld.options.ScreenSize.x * 0.5f, self.manager.rainWorld.options.ScreenSize.y * 0.85f), new Vector2(0, 0), false); menuLabel.label.color = new Color((108f / 255f), 0.001f, 0.001f); menuLabel.label.alignment = FLabelAlignment.Center; self.pages[0].subObjects.Add(menuLabel); } }
/// <summary> /// Checks if the region has albino leviathans configured /// </summary> private static void BigEel_ctor(On.BigEel.orig_ctor orig, BigEel self, AbstractCreature abstractCreature, World world) { orig(self, abstractCreature, world); if (world != null && !world.singleRoomWorld && world.region != null) { foreach (KeyValuePair <string, string> keyValues in CustomWorldMod.activatedPacks) { if (CustomWorldMod.installedPacks[keyValues.Key].regionConfig.TryGetValue(world.region.name, out CustomWorldStructs.RegionConfiguration config)) { if (config.albinoLevi) { CustomWorldMod.Log($"Albino leviathan in [{world.region.name}] from [{CustomWorldMod.installedPacks[keyValues.Key].name}]", false, CustomWorldMod.DebugLevel.FULL); self.albino = true; self.iVars.patternColorB = new HSLColor(0f, 0.6f, 0.75f); self.iVars.patternColorA.hue = 0.5f; self.iVars.patternColorA = HSLColor.Lerp(self.iVars.patternColorA, new HSLColor(0.97f, 0.8f, 0.75f), 0.9f); break; } } } } }
private static void Room_AddObject(On.Room.orig_AddObject orig, Room self, UpdatableAndDeletable obj) { if (self.game == null) { return; } if (obj is WaterGate) { // Add electric gate if (self.abstractRoom.gate) { CustomWorldMod.Log("Water gate created, checking if it should be electric..."); foreach (KeyValuePair <string, string> regions in CustomWorldMod.activatedPacks) { if (CustomWorldMod.installedPacks[regions.Key].electricGates != null) { if (CustomWorldMod.installedPacks[regions.Key].electricGates.ContainsKey(self.abstractRoom.name)) { (obj as WaterGate).Destroy(); CustomWorldMod.Log($"Added electric gate [{self.abstractRoom.name}] from [{regions.Value}]"); self.regionGate = new ElectricGate(self); (self.regionGate as ElectricGate).meterHeight = CustomWorldMod.installedPacks[regions.Key].electricGates[self.abstractRoom.name]; obj = self.regionGate; break; } } } } } orig(self, obj); }
/// <summary> /// Adjust chance of spawning black salamanders /// </summary> private static void LizardGraphics_ctor(On.LizardGraphics.orig_ctor orig, LizardGraphics self, PhysicalObject ow) { orig(self, ow); World world = ow.abstractPhysicalObject.world; if (world != null && !world.singleRoomWorld && world.region != null) { foreach (KeyValuePair <string, string> keyValues in CustomWorldMod.activatedPacks) { if (CustomWorldMod.installedPacks[keyValues.Key].regionConfig.TryGetValue(world.region.name, out CustomWorldStructs.RegionConfiguration config)) { if (config.blackSalamanderChance >= 0) { CustomWorldMod.Log($"Custom salamander chance [{config.blackSalamanderChance}] in [{world.region.name}] from " + $"[{CustomWorldMod.installedPacks[keyValues.Key].name}]", false, CustomWorldMod.DebugLevel.FULL); int seed = UnityEngine.Random.seed; UnityEngine.Random.seed = self.lizard.abstractCreature.ID.RandomSeed; self.blackSalamander = (UnityEngine.Random.value < config.blackSalamanderChance); UnityEngine.Random.seed = seed; break; } } } } }
public override void Update() { if (process == null || process.HasExited && !readyToDelete) { Log("RegionPackDownloader console has exited"); if (!errorGrabbingPack) { LogPackDownload(CustomWorldMod.rainDbPacks[this.packName], CustomWorldMod.exeDownloaderLocation); } CheckForDependencies(); if (movedDependencies) { stringStatus = "Done"; PopUp(false); } else if (errorGrabbingPack) { stringStatus = "Retry"; PopUp(true); } else { stringStatus = "Finished"; CustomWorldMod.LoadCustomWorldResources(); } readyToDelete = true; } if (downloadButton != null) { downloadButton.text = stringStatus; } }
private static void DataPearlData_FromString(On.PlacedObject.DataPearlData.orig_FromString orig, PlacedObject.DataPearlData self, string s) { try { orig(self, s); } catch (Exception e) { CustomWorldMod.Log("Fatal Error: " + e, true); } string[] array = Regex.Split(s, "~"); try { if (array.Length >= 5) { int hash = int.Parse(array[4]); if (CustomWorldMod.customPearls.TryGetValue(hash, out CustomWorldStructs.CustomPearl customPearl)) { string pearlName = customPearl.name; DataPearl.AbstractDataPearl.DataPearlType type = (DataPearl.AbstractDataPearl.DataPearlType)Enum.Parse(typeof(DataPearl.AbstractDataPearl.DataPearlType), pearlName); CustomWorldMod.Log($"Loaded custom pearl [{type.ToString()}] Hash [{hash}]"); self.pearlType = type; self.hidden = (array[5] == "1"); } else if (hash > 0x25) { CustomWorldMod.Log($"Error loading data pearl. You are missing dataPearls.txt or your pack needs to be updated\n" + $"Please remove the custom datapearl [{self.pearlType}] with devtools and place it again [{self.owner.pos}]", true); } } } catch (Exception e) { CustomWorldMod.Log($"Exception loading pearl [{e}]", true); } }
/// <summary> /// in FastTravelScreen - Searchs for custom SceneID, sets the the currentShelter to null to avoid nullref and stores it in a static var /// </summary> private static Menu.MenuScene.SceneID FastTravelScreen_TitleSceneID(On.Menu.FastTravelScreen.orig_TitleSceneID orig, Menu.FastTravelScreen self, string regionName) { // Debug CustomWorldMod.Log($"Accesible regions count [{self.accessibleRegions.Count}] out of [{FastTravelScreen.GetRegionOrder().Count}]"); //CustomWorldMod.sceneCustomID = string.Empty; MenuScene.SceneID ID = MenuScene.SceneID.Empty; CustomWorldMod.Log($"Custom Regions: TitleSceneID {regionName}"); try { ID = (MenuScene.SceneID)Enum.Parse(typeof(MenuScene.SceneID), $"Landscape_{regionName}"); } catch (Exception e) { CustomWorldMod.Log($"Enum not found [{e}]"); } if (orig(self, regionName) == Menu.MenuScene.SceneID.Empty && ID != MenuScene.SceneID.Empty) { CustomWorldMod.Log($"Custom Regions: TitleSceneID. Using custom SceneID [{ID}]"); // removing the current shelter to avoid Array index out of range in Fastravelscreen ctor. temporalShelter = self.currentShelter; self.currentShelter = null; return(ID); } return(orig(self, regionName)); }
public static void AddMissingRegions(OverWorld self) { int num = self.regions[self.regions.Length - 1].firstRoomIndex; int regionNumber = self.regions[self.regions.Length - 1].regionNumber + 1; foreach (KeyValuePair <string, string> keyValues in CustomWorldMod.activatedPacks) { foreach (string regionToAdd in CustomWorldMod.installedPacks[keyValues.Key].regions) { bool shouldAdd = true; for (int i = 0; i < self.regions.Length; i++) { if (regionToAdd.Equals(self.regions[i].name)) { shouldAdd = false; } } if (shouldAdd) { Array.Resize(ref self.regions, self.regions.Length + 1); self.regions[self.regions.Length - 1] = new Region(regionToAdd, num, regionNumber); CustomWorldMod.Log($"Added new region [{regionToAdd}] from [{keyValues.Value}]. " + $"Number of rooms [{self.regions[self.regions.Length - 1].numberOfRooms}]. Region number [{regionNumber}]"); num += self.regions[self.regions.Length - 1].numberOfRooms; regionNumber++; } } } }
private static void MenuIllustration_LoadFile_1(On.Menu.MenuIllustration.orig_LoadFile_1 orig, Menu.MenuIllustration self, string folder) { if (folder.Contains("CustomResources")) { try { CustomWorldMod.Log($"Custom Regions: Loading custom resources at MenuIllustration. Folder [{folder}] and fileName [{self.fileName}]"); self.www = new WWW(string.Concat(new object[] { "file:///", Custom.RootFolderDirectory(), folder, Path.DirectorySeparatorChar, self.fileName, ".png" })); self.texture = new Texture2D(1, 1, TextureFormat.ARGB32, false); self.texture.wrapMode = TextureWrapMode.Clamp; if (self.crispPixels) { self.texture.anisoLevel = 0; self.texture.filterMode = FilterMode.Point; } self.www.LoadImageIntoTexture(self.texture); HeavyTexturesCache.LoadAndCacheAtlasFromTexture(self.fileName, self.texture); self.www = null; } catch (Exception e) { CustomWorldMod.Log($"Custom Regions: Failed loading textures for {folder} - {self.fileName} " + e); } } else { orig(self, folder); } }
// Helpers // Gets the configured regions special scavenger item. Affects init gearup and trader's specialty. private static bool TryGetSpecialScavItem(string regionName, out AbstractPhysicalObject.AbstractObjectType type) { type = default; foreach (KeyValuePair <string, string> keyValues in CustomWorldMod.activatedPacks) { if (CustomWorldMod.installedPacks[keyValues.Key].regionConfig.TryGetValue(regionName, out CustomWorldStructs.RegionConfiguration config)) { if (config.scavTradeItem != null) { if (!Enum.IsDefined(typeof(AbstractPhysicalObject.AbstractObjectType), config.scavTradeItem)) { CustomWorldMod.Log($"Scavenger trade item misconfigured in {keyValues.Key}:{regionName}, got [{config.scavTradeItem}] which is not a valid AbstractObjectType", false, CustomWorldMod.DebugLevel.RELEASE); } else { CustomWorldMod.Log($"Found Scavenger trade item in {keyValues.Key}:{regionName}, got [{config.scavTradeItem}]", false, CustomWorldMod.DebugLevel.FULL); type = (AbstractPhysicalObject.AbstractObjectType)Enum.Parse(typeof(AbstractPhysicalObject.AbstractObjectType), config.scavTradeItem); return(true); } } } } return(false); }
private static void MenuScene_BuildScene(On.Menu.MenuScene.orig_BuildScene orig, Menu.MenuScene self) { orig(self); if (self.sceneID != MenuScene.SceneID.Empty && (int)self.sceneID > 69) { CustomWorldMod.Log($"Custom Regions: Building custom scene [{self.sceneID}]"); string regionID = string.Empty; try { regionID = Regex.Split(self.sceneID.ToString(), "Landscape_")[1]; } catch (Exception e) { CustomWorldMod.Log($"Error trimming regionID [{self.sceneID}] {e}", true); return; } string regionPackFolder = string.Empty; try { // This might be slow regionPackFolder = CustomWorldMod.installedPacks.FirstOrDefault(x => (x.Value.activated && x.Value.regions.Contains(regionID))).Value.folderName; } catch (Exception e) { CustomWorldMod.Log($"Error finding regionName [{self.sceneID}] {e}", true); return; } string sceneFolder = CRExtras.BuildPath(regionPackFolder, CRExtras.CustomFolder.Scenes, folder: $"Landscape - {regionID}", includeRoot: false); CustomWorldMod.Log($"Custom Regions: Searching assets at {sceneFolder}", false, CustomWorldMod.DebugLevel.MEDIUM); if (Directory.Exists(sceneFolder)) { CustomWorldMod.Log($"Custom Regions: Found custom scene [{sceneFolder}]"); self.sceneFolder = sceneFolder; BuildCustomRegionScene(self, regionID, sceneFolder); } } }
private static void MainLoopProcess_Update(On.MainLoopProcess.orig_Update orig, MainLoopProcess self) { orig(self); CustomWorldMod.scripts.RemoveAll(x => x == null); for (int i = CustomWorldMod.scripts.Count - 1; i >= 0; i--) { CustomWorldScript script = CustomWorldMod.scripts[i]; { if (script != null) { if (script.readyToDelete) { script.Clear(); CustomWorldMod.scripts.Remove(script); script = null; CustomWorldMod.Log($"Scripts count [{CustomWorldMod.scripts.Count}]"); } else { script.Update(); } } } } }
public static void LoadScenePositionSettings(MenuScene self, string sceneFolder, string regionID) { CustomWorldMod.Log($"Custom Regions: Loading settings for Illustration at [{sceneFolder}]"); string[] readingTextFile = new string[0]; if (File.Exists(sceneFolder + "positions.txt")) { CustomWorldMod.Log($"Custom Regions: Reading positions.txt for {regionID}"); readingTextFile = File.ReadAllLines(sceneFolder + "positions.txt"); int num2 = 0; while (num2 < readingTextFile.Length && num2 < self.depthIllustrations.Count) { self.depthIllustrations[num2].pos.x = float.Parse(Regex.Split(readingTextFile[num2], ", ")[0]); self.depthIllustrations[num2].pos.y = float.Parse(Regex.Split(readingTextFile[num2], ", ")[1]); self.depthIllustrations[num2].lastPos = self.depthIllustrations[num2].pos; CustomWorldMod.Log($"Custom Regions: Position file Number [{num2 + 1}] position loaded [{self.depthIllustrations[num2].pos}]"); num2++; } } if (File.Exists(sceneFolder + "depths.txt")) { CustomWorldMod.Log($"Custom Regions: Reading depths.txt for {regionID}"); readingTextFile = File.ReadAllLines(sceneFolder + "depths.txt"); int num2 = 0; while (num2 < readingTextFile.Length && num2 < self.depthIllustrations.Count) { self.depthIllustrations[num2].depth = float.Parse(readingTextFile[num2]); CustomWorldMod.Log($"Custom Regions: Depths file Number [{num2 + 1}] position loaded [{self.depthIllustrations[num2].depth}]"); num2++; } } }
private static AbstractPhysicalObject SaveState_AbstractPhysicalObjectFromString(On.SaveState.orig_AbstractPhysicalObjectFromString orig, World world, string objString) { AbstractPhysicalObject result = orig(world, objString); if (result != null && result.type == AbstractPhysicalObject.AbstractObjectType.DataPearl) { try { if (result is DataPearl.AbstractDataPearl dataPearl) { string[] array = Regex.Split(objString, "<oA>"); int hash = int.Parse(array[5]); if (CustomWorldMod.customPearls.ContainsKey(hash)) { CustomWorldMod.customPearls.TryGetValue(hash, out CustomWorldStructs.CustomPearl customPearl); string pearlName = customPearl.name; DataPearl.AbstractDataPearl.DataPearlType type = (DataPearl.AbstractDataPearl.DataPearlType)Enum.Parse(typeof(DataPearl.AbstractDataPearl.DataPearlType), pearlName); CustomWorldMod.Log($"Loaded custom pearl [{type.ToString()}] Hash [{hash}]"); dataPearl.dataPearlType = type; } else if (hash > 0x25) { CustomWorldMod.Log($"Error loading data pearl (AbsPhysObj). You are missing dataPearls.txt or your pack needs to be updated", true); } } } catch (Exception e) { CustomWorldMod.Log($"Error while loading dataPearl from SaveState [{e}]"); } } return(result); }
/// <summary> /// Stores in a static variable the custom color of Tentacle plants, if configured. /// </summary> private static void TentaclePlantGraphics_ctor(On.TentaclePlantGraphics.orig_ctor orig, TentaclePlantGraphics self, PhysicalObject ow) { orig(self, ow); customColor = null; World world = ow.abstractPhysicalObject.world; if (world != null && !world.singleRoomWorld && world.region != null) { foreach (KeyValuePair <string, string> keyValues in CustomWorldMod.activatedPacks) { if (CustomWorldMod.installedPacks[keyValues.Key].regionConfig.TryGetValue(world.region.name, out CustomWorldStructs.RegionConfiguration config)) { if (!config.kelpVanilla) { customColor = new Color[self.danglers.Length]; CustomWorldMod.Log($"Spawning tentacle plant with custom color in [{world.region.name}] from " + $"[{CustomWorldMod.installedPacks[keyValues.Key].name}]"); for (int i = 0; i < customColor.Length; i++) { HSLColor hsl = CRExtras.RGB2HSL(config.kelpColor ?? new Color()); customColor[i] = Custom.HSL2RGB( Mathf.Lerp(hsl.hue * 0.8f, hsl.hue * 1.2f, Mathf.Pow(self.danglerProps[i, 0], 1.6f)), Mathf.Lerp(hsl.saturation, 0.4f, self.danglerProps[i, 0]), Mathf.Lerp(hsl.lightness, 0.4f, self.danglerProps[i, 0]) ); } break; } } } } }
private static void MapRenderOutput_Signal(On.DevInterface.MapRenderOutput.orig_Signal orig, global::DevInterface.MapRenderOutput self, global::DevInterface.DevUISignalType type, global::DevInterface.DevUINode sender, string message) { string pathToMapFile = string.Empty; // From a Custom Region foreach (KeyValuePair <string, string> keyValues in CustomWorldMod.activatedPacks) { string customFilePath = CRExtras.BuildPath(keyValues.Value, CRExtras.CustomFolder.RegionID, regionID: self.owner.game.world.name); if (Directory.Exists(customFilePath)) { pathToMapFile = customFilePath + "map_" + self.owner.game.world.name + ".png"; CustomWorldMod.Log($"[DEV] Saving custom Map Config to map_XX.png from [{keyValues.Value}] to [{pathToMapFile}]"); PNGSaver.SaveTextureToFile(self.texture, pathToMapFile); self.ClearSprites(); (self.parentNode as MapPage).renderOutput = null; (self.parentNode as MapPage).modeSpecificNodes.Remove(self); self.parentNode.subNodes.Remove(self); return; } } CustomWorldMod.Log($"[DEV] No custom region folder found for [{self.owner.game.world.name}], using vanilla..."); orig(self, type, sender, message); }
private static void OverWorld_LoadWorld(On.OverWorld.orig_LoadWorld orig, OverWorld self, string worldName, int playerCharacterNumber, bool singleRoomWorld) { CustomWorldMod.Log($"Custom Regions: Loading world. Worldname [{worldName}], using [{textLoadWorld}]. SingleWorld [{singleWorld}]"); orig(self, textLoadWorld ?? worldName, playerCharacterNumber, singleWorld ?? singleRoomWorld); // TEST THIS textLoadWorld = null; singleWorld = null; }