Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of LLLLP v1.2.1
LLLLP.dll
Decompiled 2 years agousing System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using LethalLevelLoader; using LethalLevelLoader.Tools; using Unity.Netcode; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = "")] [assembly: AssemblyCompany("LLLLP")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("Lethal Level Loader Localized Patcher")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("LLLLP")] [assembly: AssemblyTitle("LLLLP")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] namespace LLLLPr; internal static class ConfigManager { internal static void BindConfigs() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected O, but got Unknown //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Expected O, but got Unknown //IL_003a: Expected O, but got Unknown ConfigFile val = new ConfigFile(Path.Combine(Paths.ConfigPath, "LLLLP.cfg"), false); TerminalConfig terminalConfig = new TerminalConfig(val, "", 0); LocalizeConfig localizeConfig = new LocalizeConfig(val, "", 1); ItemConfig itemConfig = new ItemConfig(val, "", 2); terminalConfig.BindConfigs(); foreach (ExtendedLevel vanillaExtendedLevel in PatchedContent.VanillaExtendedLevels) { itemConfig.RegisterItems(vanillaExtendedLevel); } foreach (ExtendedLevel customExtendedLevel in PatchedContent.CustomExtendedLevels) { itemConfig.RegisterItems(customExtendedLevel); } itemConfig.BindConfigs(); foreach (ExtendedLevel extendedLevel in PatchedContent.ExtendedLevels) { localizeConfig.BindConfigs(extendedLevel); } } } public class TerminalConfig : ConfigTemplate { public static string CatalogueText = ""; public static string ScanText = ""; public TerminalConfig(ConfigFile newConfigFile, string newCatagory, int newSortingPriority) : base(newConfigFile, newCatagory, newSortingPriority) { ((ConfigTemplate)this).Catagory = "General"; } public void BindConfigs() { CatalogueText = ((ConfigTemplate)this).BindValue<string>("Moon Catalogue Text", "", "\n\n\nWelcome to the exomoons catagloue.\nTo route the autopilot to a moon, use the word ROUTE.\nTo learn about any moon, use the word INFO.\n------------------------------\n\n* The Company Building // Buying at [companyBuyingPercent].\n\n").Value; ScanText = ((ConfigTemplate)this).BindValue<string>("Scan Text", "{0} : Scrap Count, {1} : Total scrap price", "There are {0} objects outside the ship, totalling at an approximate value of ${1}.").Value; } } public class ItemConfig : ConfigTemplate { public static ConfigEntry<bool> bOverrideItemNames; private static readonly Dictionary<string, string> ItemNameLocalizeDict = new Dictionary<string, string>(); private static readonly Dictionary<string, List<ExtendedLevel>> ItemMapDict = new Dictionary<string, List<ExtendedLevel>>(); private static readonly Dictionary<string, string> ItemNameDict = new Dictionary<string, string>(); private static readonly Dictionary<string, GameObject> ItemObjects = new Dictionary<string, GameObject>(); private static readonly Dictionary<string, string> ItemAlias = new Dictionary<string, string> { { "Airhorn", "Airhorn" }, { "Chemical jug", "ChemicalJug" }, { "Comedy", "ComedyMask" }, { "Lava Crystal", "lavacrystal" }, { "Bit coin", "coin" }, { "Oil Lantern", "lantern" }, { "Whoopie cushion", "WhoopieCushion" }, { "Remote", "Remote" }, { "Large axle", "Cog" }, { "Pickaxe", "pickaxe" }, { "Hairdryer", "Hairdryer" }, { "Flask", "Flask" }, { "Toy robot", "RobotToy" }, { "Bell", "HandBell" }, { "Burnt Note 4", "note4" }, { "Tea kettle", "TeaKettle" }, { "Red soda", "RedSodaCan" }, { "Burnt Note 1", "note1" }, { "V-type engine", "EnginePart" }, { "Homemade flashbang", "DiyFlashbang" }, { "Bottles", "BinFullOfBottles" }, { "Burnt Note 2", "note2" }, { "Rock", "rock" }, { "Rubber Ducky", "RubberDucky" }, { "Metal sheet", "MetalSheet" }, { "Cookie mold pan", "CookieMoldPan" }, { "Raw Gold", "rawgold" }, { "Magic 7 ball", "Magic7Ball" }, { "Golden cup", "FancyGlass" }, { "Old phone", "OldPhone" }, { "Shotgun", "ShotgunItem" }, { "Fancy lamp", "FancyLamp" }, { "Big bolt", "BigBolt" }, { "Tragedy", "TragedyMask" }, { "Pill bottle", "PillBottle" }, { "Candy", "Candy" }, { "Brush", "Hairbrush" }, { "Concrete Block", "concreteslab" }, { "Oil Shale", "oilshale" }, { "Magnifying glass", "MagnifyingGlass" }, { "Painting", "Painting" }, { "Hive", "RedLocustHive" }, { "Steering wheel", "SteeringWheel" }, { "Egg beater", "EggBeater" }, { "Stop sign", "StopSign" }, { "Plastic fish", "FishTestProp" }, { "Skull", "skull" }, { "Dust pan", "Dustpan" }, { "Toy cube", "ToyCube" }, { "Laser pointer", "LaserPointer" }, { "Gold bar", "GoldBar" }, { "Teeth", "Dentures" }, { "Perfume bottle", "PerfumeBottle" }, { "Gift", "GiftBox" }, { "Clown horn", "Clownhorn" }, { "Yield sign", "YieldSign" }, { "Flintlock", "flintlock" }, { "Mug", "Mug" }, { "Amethyst Cluster", "amethyst" }, { "Body", "BodyScanDisplay" }, { "Jar of pickles", "PickleJar" }, { "Burnt Note 3", "note3" }, { "Apparatus", "LungApparatusTurnedOff" }, { "Toothpaste", "Toothpaste" }, { "Ring", "FancyRing" }, { "Cash register", "CashRegisterItem" } }; public ItemConfig(ConfigFile newConfigFile, string newCatagory, int newSortingPriority) : base(newConfigFile, newCatagory, newSortingPriority) { } public static GameObject GetScrapPrefab(string itemName) { if (ItemAlias.ContainsKey(itemName) && ItemObjects.ContainsKey(ItemAlias[itemName])) { return ItemObjects[ItemAlias[itemName]]; } return null; } public void RegisterItems(ExtendedLevel level) { foreach (SpawnableItemWithRarity item in level.selectableLevel.spawnableScrap) { if (!((Object)(object)item.spawnableItem == (Object)null) && !((Object)(object)item.spawnableItem.spawnPrefab == (Object)null)) { string itemName = item.spawnableItem.itemName; string name = ((Object)item.spawnableItem.spawnPrefab).name; if (!ItemObjects.ContainsKey(name)) { ItemObjects.Add(name, item.spawnableItem.spawnPrefab); ItemNameDict.Add(name, itemName); } item.spawnableItem.itemName = ItemNameDict[name]; if (!ItemMapDict.ContainsKey(name)) { ItemMapDict.Add(name, new List<ExtendedLevel>()); } if (!((Object)(object)ItemMapDict[name].Find((ExtendedLevel el) => el.NumberlessPlanetName.Equals(level.NumberlessPlanetName)) != (Object)null)) { ItemMapDict[name].Add(level); } } } } public void BindConfigs() { ((ConfigTemplate)this).Catagory = "Items"; bOverrideItemNames = ((ConfigTemplate)this).BindValue<bool>("Override Item Names", "", false); foreach (string key in ItemNameDict.Keys) { string spawnMaps = $"Spawn Maps ({ItemMapDict[key].Count}) :"; ItemMapDict[key].ForEach(delegate(ExtendedLevel level) { spawnMaps = spawnMaps + " " + level.NumberlessPlanetName + ","; }); spawnMaps = spawnMaps.Substring(0, spawnMaps.Length - 1); ConfigEntry<string> val = ((ConfigTemplate)this).BindValue<string>(key, spawnMaps, ItemNameDict[key]); if (bOverrideItemNames.Value && !ItemNameLocalizeDict.ContainsKey(key)) { ItemNameLocalizeDict.Add(ItemNameDict[key], val.Value); } } } public static string GetItemLocalizedName(string name) { if (!ItemNameLocalizeDict.ContainsKey(name)) { return name; } return ItemNameLocalizeDict[name]; } } public class LocalizeConfig : ConfigTemplate { private ConfigEntry<bool> bOverrideLocalize; private ConfigEntry<string> bOverrideName; private ConfigEntry<string> bOverrideDescription; public static readonly Dictionary<string, string> PlanetNameMap = new Dictionary<string, string>(); public LocalizeConfig(ConfigFile newConfigFile, string catagory, int newSortingPriority) : base(newConfigFile, catagory, newSortingPriority) { } private void AppendTerminal(ExtendedLevel extendedLevel, string name, string description) { PlanetNameMap.Add(name, extendedLevel.NumberlessPlanetName); extendedLevel.selectableLevel.PlanetName = name; extendedLevel.selectableLevel.LevelDescription = description; TerminalKeyword val = Reflections.CreateNewTerminalKeyword(); ((Object)val).name = Extensions.Sanitized(Extensions.StripSpecialCharacters(name)) + "Keyword"; val.word = Extensions.Sanitized(Extensions.StripSpecialCharacters(name)); val.defaultVerb = Reflections.GetRouteKeyword(); TerminalNode val2 = Reflections.CreateNewTerminalNode(); ((Object)val2).name = Extensions.Sanitized(Extensions.StripSpecialCharacters(name)) + "Route"; val2.displayText = name + "의 이동 비용은 [totalCost]입니다. 이 위성의 현재 날씨는 [currentPlanetTime]입니다."; val2.displayText += "\n\nCONFIRM 혹은 DENY를 입력하세요.\n\n"; val2.clearPreviousText = true; val2.buyRerouteToMoon = -2; val2.displayPlanetInfo = extendedLevel.selectableLevel.levelID; val2.itemCost = extendedLevel.RoutePrice; val2.overrideOptions = true; TerminalNode val3 = Reflections.CreateNewTerminalNode(); ((Object)val3).name = Extensions.Sanitized(Extensions.StripSpecialCharacters(extendedLevel.NumberlessPlanetName)) + "RouteConfirm"; val3.displayText = extendedLevel.selectableLevel.PlanetName + "로 이동합니다.\n현재 소지금은 [playerCredits]입니다."; val3.clearPreviousText = true; val3.buyRerouteToMoon = extendedLevel.selectableLevel.levelID; int itemCost = (((Object)(object)extendedLevel.routeNode == (Object)null) ? (-1) : extendedLevel.routeNode.itemCost); val3.itemCost = itemCost; TerminalNode val4 = Reflections.CreateNewTerminalNode(); ((Object)val4).name = Extensions.Sanitized(Extensions.StripSpecialCharacters(extendedLevel.NumberlessPlanetName)) + "Info"; val4.clearPreviousText = true; val4.maxCharactersToType = 35; string text = extendedLevel.selectableLevel.PlanetName + "\n----------------------\n"; List<string> list = new List<string>(); string text2 = description; while (text2.Contains("\n")) { string text3 = text2.Substring(text2.IndexOf("\n")); list.Add(text2.Replace(text3, "")); if (text3.Contains("\n")) { text2 = text3.Substring(text3.IndexOf("\n") + 1); } } list.Add(text2); foreach (string item in list) { text = text + "\n" + item + "\n"; } val4.displayText = text; Extensions.AddCompatibleNoun(val2, Reflections.GetDenyKeyword(), Reflections.GetCancelRouteNode()); Extensions.AddCompatibleNoun(val2, Reflections.GetConfirmKeyword(), val3); Extensions.AddCompatibleNoun(Reflections.GetRouteKeyword(), val, val2); Extensions.AddCompatibleNoun(Reflections.GetInfoKeyword(), val, val4); extendedLevel.routeNode = val2; extendedLevel.routeConfirmNode = val3; extendedLevel.infoNode = val4; Debug.Log((object)("Override Localize Terminal Complete [Moon - " + extendedLevel.selectableLevel.PlanetName + "]")); } public void BindConfigs(ExtendedLevel eLevel) { if (PlanetNameMap.ContainsKey(eLevel.NumberlessPlanetName)) { Debug.Log((object)(eLevel.NumberlessPlanetName + " is duplicated route.")); return; } SelectableLevel selectableLevel = eLevel.selectableLevel; ((ConfigTemplate)this).Catagory = eLevel.selectableLevel.PlanetName; bOverrideLocalize = ((ConfigTemplate)this).BindValue<bool>("Override Localize Settings", "", false); bOverrideName = ((ConfigTemplate)this).BindValue<string>("Localized Name", "", eLevel.NumberlessPlanetName); bOverrideDescription = ((ConfigTemplate)this).BindValue<string>("Localized Description", "", selectableLevel.LevelDescription); Debug.Log((object)$"Override Localize Settings [Moon - {eLevel.selectableLevel.PlanetName}] :: {bOverrideLocalize.Value}"); if (bOverrideLocalize.Value) { AppendTerminal(eLevel, bOverrideName.Value, bOverrideDescription.Value); } } } public class LLLPatcher { internal const int harmonyPriority = 199; [HarmonyPatch(typeof(Terminal), "TextPostProcess")] [HarmonyPrefix] internal static void TextPostProcess_PreFix(ref string modifiedDisplayText) { bool num = modifiedDisplayText.Contains("Welcome to the exomoons catalogue"); bool flag = modifiedDisplayText.Contains("[scanForItems]"); if (num) { modifiedDisplayText = TerminalConfig.CatalogueText + TerminalManager.GetMoonCatalogDisplayListings() + "\n"; } if (!flag) { return; } GrabbableObject[] array = Object.FindObjectsOfType<GrabbableObject>(); int num2 = 0; int num3 = 0; GrabbableObject[] array2 = array; foreach (GrabbableObject val in array2) { bool isScrap = val.itemProperties.isScrap; bool isInShipRoom = val.isInShipRoom; bool isInElevator = val.isInElevator; if (!(!isScrap || isInShipRoom || isInElevator)) { num2++; num3 += val.scrapValue; } } modifiedDisplayText = modifiedDisplayText.Replace("[scanForItems]", string.Format(TerminalConfig.ScanText, num2, num3)); } [HarmonyPriority(199)] [HarmonyPatch(typeof(RoundManager), "Awake")] [HarmonyPostfix] internal static void RoundManagerAwake_Postfix(RoundManager __instance) { ConfigManager.BindConfigs(); } private static bool IsLethalExpansionLevel(ExtendedLevel level) { FieldInfo field = typeof(ExtendedLevel).GetField("isLethalExpansion", BindingFlags.Instance | BindingFlags.NonPublic); if (!(field == null)) { return (bool)field.GetValue(level); } return false; } [HarmonyPriority(199)] [HarmonyPatch(typeof(Terminal), "Start")] [HarmonyPostfix] internal static void TerminalStart_Postfix() { foreach (ExtendedLevel customExtendedLevel in PatchedContent.CustomExtendedLevels) { if ((Object)(object)customExtendedLevel == (Object)null || !IsLethalExpansionLevel(customExtendedLevel)) { continue; } CompatibleNoun[] compatibleNouns = Reflections.GetRouteKeyword().compatibleNouns; foreach (CompatibleNoun val in compatibleNouns) { string text = (LocalizeConfig.PlanetNameMap.ContainsKey(customExtendedLevel.NumberlessPlanetName) ? LocalizeConfig.PlanetNameMap[customExtendedLevel.NumberlessPlanetName] : "None"); if (!text.Equals("None") && ((Object)val.noun).name.ToLower().Contains(text.ToLower())) { Debug.Log((object)$"Override {customExtendedLevel.NumberlessPlanetName}'s RoutePrice to {val.result.itemCost}."); customExtendedLevel.RoutePrice = val.result.itemCost; break; } } } } [HarmonyPriority(199)] [HarmonyPatch(typeof(RoundManager), "SpawnScrapInLevel")] [HarmonyPrefix] internal static void SpawnScrapInLevel_Prefix(RoundManager __instance) { int count = __instance.currentLevel.spawnableScrap.Count; List<SpawnableItemWithRarity> list = new List<SpawnableItemWithRarity>(); foreach (SpawnableItemWithRarity item in __instance.currentLevel.spawnableScrap) { if ((Object)(object)item.spawnableItem == (Object)null) { Debug.Log((object)("Find No ItemProperties Item from Loading moon-" + __instance.currentLevel.PlanetName + ".")); list.Add(item); continue; } if (!((Object)(object)item.spawnableItem.spawnPrefab != (Object)null)) { GameObject scrapPrefab = ItemConfig.GetScrapPrefab(item.spawnableItem.itemName); if ((Object)(object)scrapPrefab == (Object)null) { Debug.Log((object)("Unknown Prefab Item {" + item.spawnableItem.itemName + "} from Loading moon-" + __instance.currentLevel.PlanetName + ".")); list.Add(item); continue; } item.spawnableItem.spawnPrefab = scrapPrefab; } if (!((Object)(object)item.spawnableItem.spawnPrefab.GetComponent<GrabbableObject>() != (Object)null)) { Debug.Log((object)("Find Ungrabbable item {" + item.spawnableItem.itemName + "} from Loading moon-" + __instance.currentLevel.PlanetName + ".")); list.Add(item); } } list.ForEach(delegate(SpawnableItemWithRarity item) { __instance.currentLevel.spawnableScrap.Remove(item); }); Debug.Log((object)$"Complete Cleaned Moon-{__instance.currentLevel.PlanetName}. {count} -> {__instance.currentLevel.spawnableScrap.Count}"); } [HarmonyPriority(199)] [HarmonyPatch(typeof(RoundManager), "SpawnScrapInLevel")] [HarmonyPostfix] internal static void SpawnScrapInLevel_Postfix(RoundManager __instance) { GrabbableObject[] array = Object.FindObjectsOfType<GrabbableObject>(); for (int i = 0; i < array.Length; i++) { ScanNodeProperties componentInChildren = ((Component)array[i]).gameObject.GetComponentInChildren<ScanNodeProperties>(); if (!((Object)(object)componentInChildren == (Object)null) && ItemConfig.bOverrideItemNames.Value) { componentInChildren.headerText = ItemConfig.GetItemLocalizedName(componentInChildren.headerText); } } } [HarmonyPriority(199)] [HarmonyPatch(typeof(RoundManager), "waitForScrapToSpawnToSync")] [HarmonyPrefix] internal static void waitForScrapToSpawnToSync_Prefix(RoundManager __instance, ref NetworkObjectReference[] spawnedScrap, ref int[] scrapValues) { NetworkObject val = default(NetworkObject); for (int i = 0; i < spawnedScrap.Length; i++) { if (scrapValues[i] <= 0 && ((NetworkObjectReference)(ref spawnedScrap[i])).TryGet(ref val, (NetworkManager)null)) { GrabbableObject component = ((Component)val).gameObject.GetComponent<GrabbableObject>(); int num = Mathf.RoundToInt((float)__instance.AnomalyRandom.Next(component.itemProperties.minValue, component.itemProperties.maxValue) * __instance.scrapValueMultiplier); component.SetScrapValue(num); scrapValues[i] = num; } } } } [BepInPlugin("goosegoop.llllp", "LLLLP", "1.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] internal class Plugin : BaseUnityPlugin { public const string ModGuid = "goosegoop.llllp"; public const string ModName = "LLLLP"; public const string ModVersion = "1.0.0"; public static Plugin Instance; internal static readonly Harmony Harmony = new Harmony("goosegoop.llllp"); private void Awake() { if ((Object)(object)Instance == (Object)null) { Instance = this; } ((BaseUnityPlugin)this).Logger.LogInfo((object)"Lethal Level Loader Localized Patcher Loaded!!"); Harmony.PatchAll(typeof(LLLPatcher)); } } public class Reflections { private static BindingFlags terminalManagerFlags = BindingFlags.Static | BindingFlags.NonPublic; public static TerminalKeyword CreateNewTerminalKeyword() { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Expected O, but got Unknown return (TerminalKeyword)typeof(TerminalManager).GetMethod("CreateNewTerminalKeyword", terminalManagerFlags).Invoke(null, null); } public static TerminalKeyword GetRouteKeyword() { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Expected O, but got Unknown return (TerminalKeyword)typeof(TerminalManager).GetField("routeKeyword", terminalManagerFlags).GetValue(null); } public static TerminalKeyword GetDenyKeyword() { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Expected O, but got Unknown return (TerminalKeyword)typeof(TerminalManager).GetField("denyKeyword", terminalManagerFlags).GetValue(null); } public static TerminalKeyword GetConfirmKeyword() { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Expected O, but got Unknown return (TerminalKeyword)typeof(TerminalManager).GetField("confirmKeyword", terminalManagerFlags).GetValue(null); } public static TerminalKeyword GetInfoKeyword() { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Expected O, but got Unknown return (TerminalKeyword)typeof(TerminalManager).GetField("infoKeyword", terminalManagerFlags).GetValue(null); } public static TerminalNode CreateNewTerminalNode() { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Expected O, but got Unknown return (TerminalNode)typeof(TerminalManager).GetMethod("CreateNewTerminalNode", terminalManagerFlags).Invoke(null, null); } public static TerminalNode GetCancelRouteNode() { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Expected O, but got Unknown return (TerminalNode)typeof(TerminalManager).GetField("cancelRouteNode", terminalManagerFlags).GetValue(null); } }