private static void LoadCustomEventsFromFile(int fileName, string regionPackFolder, Conversation self) { CustomWorldMod.Log("~~~LOAD CONVO " + fileName); string file = "Text_" + LocalizationTranslator.LangShort(CustomWorldMod.rainWorldInstance.inGameTranslator.currentLanguage) + Path.DirectorySeparatorChar + fileName + ".txt"; string convoPath = CRExtras.BuildPath(regionPackFolder, CRExtras.CustomFolder.Text, file: file); if (!File.Exists(convoPath)) { CustomWorldMod.Log("NOT FOUND " + convoPath); return; } string text2 = File.ReadAllText(convoPath, Encoding.Default); if (text2[0] == '0') { CustomWorldMod.EncryptCustomDialogue(CRExtras.BuildPath(regionPackFolder, CRExtras.CustomFolder.Text), regionPackFolder); } else { CustomWorldMod.Log($"Decrypting file [{fileName}] at [{regionPackFolder}] in [{CustomWorldMod.rainWorldInstance.inGameTranslator.currentLanguage}]"); text2 = Custom.xorEncrypt(text2, (int)(54 + fileName + (int)CustomWorldMod.rainWorldInstance.inGameTranslator.currentLanguage * 7)); } string[] array = Regex.Split(text2, Environment.NewLine); if (array.Length < 2) { CustomWorldMod.Log($"Corrupted conversation [{array}]", true); } try { if (Regex.Split(array[0], "-")[1] == fileName.ToString()) { CustomWorldMod.Log($"Moon conversation... [{array[1].Substring(0, Math.Min(array[1].Length, 15))}]"); for (int j = 1; j < array.Length; j++) { string[] array3 = Regex.Split(array[j], " : "); if (array3.Length == 1 && array3[0].Length > 0) { self.events.Add(new Conversation.TextEvent(self, 0, array3[0], 0)); } } } else { CustomWorldMod.Log($"Corrupted dialogue file...[{Regex.Split(array[0], "-")[1]}]", true); } } catch { CustomWorldMod.Log("TEXT ERROR"); self.events.Add(new Conversation.TextEvent(self, 0, "TEXT ERROR", 100)); } }
private static void LoadCustomEventsFromFile(int fileName, string customRegion, Conversation self) { CustomWorldMod.Log("~~~LOAD CONVO " + fileName); char div = Path.DirectorySeparatorChar; string convoPath = Custom.RootFolderDirectory() + CustomWorldMod.resourcePath + customRegion + div + "Assets" + div + "Text" + div + "Text_" + LocalizationTranslator.LangShort(CustomWorldMod.rainWorldInstance.inGameTranslator.currentLanguage) + div + fileName + ".txt"; if (!File.Exists(convoPath)) { CustomWorldMod.Log("NOT FOUND " + convoPath); return; } string text2 = File.ReadAllText(convoPath, Encoding.Default); if (text2[0] == '0') { //Debug.LogError("Tried to encrypt custom text"); //Conversation.EncryptAllDialogue(); CustomWorldMod.EncryptCustomDialogue(Custom.RootFolderDirectory() + CustomWorldMod.resourcePath + customRegion + div, customRegion); } else { CustomWorldMod.Log($"Decrypting file [{fileName}] from [{customRegion}] in [{CustomWorldMod.rainWorldInstance.inGameTranslator.currentLanguage}]"); text2 = Custom.xorEncrypt(text2, (int)(54 + fileName + (int)CustomWorldMod.rainWorldInstance.inGameTranslator.currentLanguage * 7)); } string[] array = Regex.Split(text2, Environment.NewLine); if (array.Length < 2) { CustomWorldMod.Log($"Corrupted conversation [{array}]", true); } try { if (Regex.Split(array[0], "-")[1] == fileName.ToString()) { CustomWorldMod.Log($"Moon conversation... [{array[1].Substring(0, Math.Min(array[1].Length, 15))}]"); for (int j = 1; j < array.Length; j++) { string[] array3 = Regex.Split(array[j], " : "); /* * if (array3.Length == 3) * { * self.events.Add(new Conversation.TextEvent(self, int.Parse(array3[0]), array3[2], int.Parse(array3[1]))); * } * else if (array3.Length == 2) * { * if (array3[0] == "SPECEVENT") * { * self.events.Add(new Conversation.SpecialEvent(self, 0, array3[1])); * } * else if (array3[0] == "PEBBLESWAIT") * { * //self.events.Add(new SSOracleBehavior.PebblesConversation.PauseAndWaitForStillEvent(self, null, int.Parse(array3[1]))); * } * } * else*/ if (array3.Length == 1 && array3[0].Length > 0) { self.events.Add(new Conversation.TextEvent(self, 0, array3[0], 0)); } /* * else * { * CustomWorldMod.Log($"Corrupted conversation [{array3[0]}]", true); * } */ } } else { CustomWorldMod.Log($"Corrupted dialogue file...[{Regex.Split(array[0], " - ")[1]}]", true); } } catch { CustomWorldMod.Log("TEXT ERROR"); self.events.Add(new Conversation.TextEvent(self, 0, "TEXT ERROR", 100)); } }