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 LegalCompany v0.0.4
LegalCompany.dll
Decompiled 2 years agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Logging; using DunGen; using DunGen.Graph; using HarmonyLib; using Microsoft.CodeAnalysis; using MonoMod.Utils; using Unity.Netcode; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("LegalCompany")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("Legal Company")] [assembly: AssemblyFileVersion("0.0.0.0")] [assembly: AssemblyInformationalVersion("0.0.0")] [assembly: AssemblyProduct("LegalCompany")] [assembly: AssemblyTitle("LegalCompany")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace LegalCompany { [BepInPlugin("butterystancakes.lethalcompany.legalcompany", "Legal Company", "0.0.0")] public class Plugin : BaseUnityPlugin { private const string PLUGIN_GUID = "butterystancakes.lethalcompany.legalcompany"; private const string PLUGIN_NAME = "Legal Company"; private const string PLUGIN_VERSION = "0.0.0"; internal static ManualLogSource Logger; private void Awake() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) Logger = ((BaseUnityPlugin)this).Logger; new Harmony("butterystancakes.lethalcompany.legalcompany").PatchAll(); Logger.LogInfo((object)"Legal Company v0.0.0 loaded"); } } [HarmonyPatch] internal class Patches { private static StartMatchLever startMatchLever; private static float tempNodeDistance = -1f; [HarmonyPatch(typeof(StartOfRound), "Start")] [HarmonyPostfix] [HarmonyPriority(100)] private static void StartOfRoundPostStart(StartOfRound __instance) { //IL_0720: Unknown result type (might be due to invalid IL or missing references) //IL_0725: Unknown result type (might be due to invalid IL or missing references) //IL_0736: Unknown result type (might be due to invalid IL or missing references) //IL_073b: Unknown result type (might be due to invalid IL or missing references) //IL_074c: Unknown result type (might be due to invalid IL or missing references) //IL_0751: Unknown result type (might be due to invalid IL or missing references) //IL_0756: Unknown result type (might be due to invalid IL or missing references) //IL_0760: Expected O, but got Unknown //IL_0dc0: Unknown result type (might be due to invalid IL or missing references) //IL_0dc5: Unknown result type (might be due to invalid IL or missing references) //IL_0dd2: Unknown result type (might be due to invalid IL or missing references) //IL_0de4: Expected O, but got Unknown //IL_0c05: Unknown result type (might be due to invalid IL or missing references) //IL_0c0a: Unknown result type (might be due to invalid IL or missing references) //IL_0c12: Unknown result type (might be due to invalid IL or missing references) //IL_0c26: Expected O, but got Unknown startMatchLever = Object.FindObjectOfType<StartMatchLever>(); if (__instance.isChallengeFile) { return; } Dictionary<string, EnemyType> dictionary = new Dictionary<string, EnemyType>(); QuickMenuManager val = Object.FindObjectOfType<QuickMenuManager>(); if ((Object)(object)val != (Object)null) { List<SpawnableEnemyWithRarity>[] array = new List<SpawnableEnemyWithRarity>[3] { val.testAllEnemiesLevel.Enemies, val.testAllEnemiesLevel.OutsideEnemies, val.testAllEnemiesLevel.DaytimeEnemies }; for (int i = 0; i < array.Length; i++) { foreach (SpawnableEnemyWithRarity item3 in array[i]) { if (!dictionary.ContainsKey(((Object)item3.enemyType).name)) { dictionary.Add(((Object)item3.enemyType).name, item3.enemyType); } } } } RoundManager val2 = RoundManager.Instance ?? Object.FindObjectOfType<RoundManager>(); Dictionary<string, int> dictionary2 = new Dictionary<string, int>(); Dictionary<string, int> dictionary3 = new Dictionary<string, int>(); Dictionary<string, int> dictionary4 = new Dictionary<string, int>(); SpawnableMapObject val3 = null; AnimationCurve val4 = null; SelectableLevel[] levels = __instance.levels; foreach (SelectableLevel val5 in levels) { switch (((Object)val5).name) { case "ExperimentationLevel": val5.minScrap = 11; val5.maxScrap = 16; break; case "AssuranceLevel": val5.minScrap = 11; Extensions.AddRange<string, int>(dictionary3, new Dictionary<string, int> { { "Cog1", 94 }, { "EnginePart1", 80 }, { "BigBolt", 89 }, { "ToyCube", 18 }, { "StopSign", 27 }, { "YieldSign", 28 }, { "ToiletPaperRolls", 18 }, { "MetalSheet", 100 } }); break; case "VowLevel": Extensions.AddRange<string, int>(dictionary3, new Dictionary<string, int> { { "Cog1", 30 }, { "EnginePart1", 31 }, { "BottleBin", 58 }, { "Flask", 49 }, { "ToiletPaperRolls", 32 }, { "PlasticCup", 27 } }); dictionary4.Add("Level3Flow", 300); break; case "MarchLevel": val5.minScrap = 16; val5.maxScrap = 21; val5.factorySizeMultiplier = 1.8f; dictionary2.Add("RedLocustBees", 72); Extensions.AddRange<string, int>(dictionary3, new Dictionary<string, int> { { "Cog1", 25 }, { "EnginePart1", 25 }, { "BottleBin", 30 }, { "ToiletPaperRolls", 34 }, { "PlasticCup", 22 }, { "Bell", 40 }, { "MoldPan", 13 } }); val5.maxEnemyPowerCount = 11; val5.overrideWeather = true; break; case "OffenseLevel": Extensions.AddRange<string, int>(dictionary3, new Dictionary<string, int> { { "Cog1", 30 }, { "EnginePart1", 40 }, { "MetalSheet", 23 }, { "BigBolt", 59 }, { "ToyCube", 31 }, { "StopSign", 34 }, { "YieldSign", 17 }, { "ToiletPaperRolls", 19 }, { "Bell", 28 } }); val5.maxScrap = 19; dictionary4.Add("Level3Flow", 300); break; case "AdamanceLevel": val5.minScrap = 19; val5.maxScrap = 24; dictionary4.Add("Level2Flow", 17); break; case "RendLevel": val5.factorySizeMultiplier = 1.6f; Extensions.AddRange<string, int>(dictionary2, new Dictionary<string, int> { { "SpringMan", 70 }, { "Jester", 69 }, { "SandWorm", 18 } }); break; case "DineLevel": val5.maxScrap = 28; Extensions.AddRange<string, int>(dictionary3, new Dictionary<string, int> { { "Cog1", 15 }, { "EnginePart1", 14 }, { "FancyLamp", 54 }, { "Ring", 26 }, { "RobotToy", 26 }, { "PillBottle", 14 }, { "PerfumeBottle", 34 }, { "BottleBin", 30 }, { "Hairdryer", 22 }, { "7Ball", 30 }, { "Airhorn", 16 }, { "ClownHorn", 17 }, { "FancyPainting", 50 }, { "CashRegister", 12 }, { "Candy", 16 }, { "GiftBox", 21 }, { "TragedyMask", 64 } }); Extensions.AddRange<string, int>(dictionary2, new Dictionary<string, int> { { "DressGirl", 3 }, { "SandSpider", 7 }, { "Blob", 3 }, { "HoarderBug", 8 }, { "Jester", 5 }, { "Centipede", 6 }, { "ForestGiant", 28 }, { "Butler", 14 } }); val5.outsideEnemySpawnChanceThroughDay = new AnimationCurve((Keyframe[])(object)new Keyframe[3] { new Keyframe(-7.7369623E-07f, -2.8875f), new Keyframe(0.47669196f, 0.6959345f), new Keyframe(1.0052626f, 5.3594007f) }); Plugin.Logger.LogDebug((object)(((Object)val5).name + ".outsideEnemySpawnChanceThroughDay")); val5.maxEnemyPowerCount = 15; break; case "TitanLevel": val5.maxScrap = 36; Extensions.AddRange<string, int>(dictionary3, new Dictionary<string, int> { { "Cog1", 19 }, { "EnginePart1", 19 }, { "FancyLamp", 29 }, { "FancyPainting", 44 }, { "PerfumeBottle", 16 }, { "Mug", 44 }, { "7Ball", 24 }, { "DiyFlashbang", 10 }, { "WhoopieCushion", 18 } }); Extensions.AddRange<string, int>(dictionary2, new Dictionary<string, int> { { "Blob", 29 }, { "ForestGiant", 20 }, { "DressGirl", 28 }, { "RadMech", 13 } }); dictionary4.Add("Level2Flow", 69); val5.canSpawnMold = false; break; case "ArtificeLevel": val5.minScrap = 31; val5.maxScrap = 38; val5.factorySizeMultiplier = 2f; Extensions.AddRange<string, int>(dictionary3, new Dictionary<string, int> { { "GoldBar", 36 } }); Extensions.AddRange<string, int>(dictionary4, new Dictionary<string, int> { { "Level1Flow", 94 }, { "Level2Flow", 300 } }); val3 = ((IEnumerable<SpawnableMapObject>)val5.spawnableMapObjects).FirstOrDefault((Func<SpawnableMapObject, bool>)delegate(SpawnableMapObject spawnableMapObject) { GameObject prefabToSpawn = spawnableMapObject.prefabToSpawn; return ((prefabToSpawn != null) ? ((Object)prefabToSpawn).name : null) == "TurretContainer"; }); break; case "EmbrionLevel": val5.minScrap = 20; val5.maxScrap = 25; Extensions.AddRange<string, int>(dictionary3, new Dictionary<string, int> { { "YieldSign", 12 }, { "GiftBox", 64 }, { "EasterEgg", 17 }, { "ControlPad", 52 }, { "SoccerBall", 45 }, { "MetalSheet", 65 }, { "Cog1", 37 }, { "EnginePart1", 40 }, { "BigBolt", 55 }, { "FlashLaserPointer", 10 }, { "BottleBin", 42 }, { "RobotToy", 49 }, { "MagnifyingGlass", 37 }, { "TeaKettle", 23 }, { "Dentures", 37 }, { "Phone", 45 }, { "Airhorn", 39 }, { "ClownHorn", 31 } }); val5.canSpawnMold = false; break; case "LiquidationLevel": val4 = ((IEnumerable<SpawnableMapObject>)val5.spawnableMapObjects).FirstOrDefault((Func<SpawnableMapObject, bool>)delegate(SpawnableMapObject spawnableMapObject) { GameObject prefabToSpawn2 = spawnableMapObject.prefabToSpawn; return ((prefabToSpawn2 != null) ? ((Object)prefabToSpawn2).name : null) == "TurretContainer"; })?.numberToSpawn; break; } if (dictionary3.Count > 0) { foreach (SpawnableItemWithRarity item4 in val5.spawnableScrap) { if (dictionary3.ContainsKey(((Object)item4.spawnableItem).name)) { Plugin.Logger.LogDebug((object)$"{((Object)val5).name}.spawnableScrap: {item4.spawnableItem.itemName} - {item4.rarity} => {dictionary3[((Object)item4.spawnableItem).name]}"); item4.rarity = dictionary3[((Object)item4.spawnableItem).name]; dictionary3.Remove(((Object)item4.spawnableItem).name); } if (((Object)item4.spawnableItem).name == "GiftBox" && val5.levelIncludesSnowFootprints && ((Object)val5).name != "ArtificeLevel") { Plugin.Logger.LogDebug((object)$"{((Object)val5).name}.spawnableScrap: \"GiftBox\" - {item4.rarity} => {item4.rarity + 30}"); item4.rarity += 30; } } if (dictionary3.Count > 0) { foreach (KeyValuePair<string, int> itemID in dictionary3) { Item val6 = ((IEnumerable<Item>)__instance.allItemsList.itemsList).FirstOrDefault((Func<Item, bool>)((Item item) => ((Object)item).name == itemID.Key)); if ((Object)(object)val6 != (Object)null) { SpawnableItemWithRarity item2 = new SpawnableItemWithRarity { spawnableItem = val6, rarity = itemID.Value }; val5.spawnableScrap.Add(item2); Plugin.Logger.LogDebug((object)$"{((Object)val5).name}.spawnableScrap: +({val6.itemName}, {itemID.Value})"); } } } dictionary3.Clear(); } if (dictionary2.Count > 0) { foreach (KeyValuePair<string, int> item5 in dictionary2) { if (dictionary.TryGetValue(item5.Key, out var enemy)) { List<SpawnableEnemyWithRarity> list = null; string empty = string.Empty; if (enemy.isDaytimeEnemy) { list = val5.DaytimeEnemies; empty = "DaytimeEnemies"; } else if (enemy.isOutsideEnemy && ((Object)enemy).name != "MaskedPlayerEnemy") { list = val5.OutsideEnemies; empty = "OutsideEnemies"; } else { list = val5.Enemies; empty = "Enemies"; } SpawnableEnemyWithRarity val7 = ((IEnumerable<SpawnableEnemyWithRarity>)list).FirstOrDefault((Func<SpawnableEnemyWithRarity, bool>)((SpawnableEnemyWithRarity spawnableEnemyWithRarity) => (Object)(object)spawnableEnemyWithRarity.enemyType == (Object)(object)enemy)); if (val7 != null) { Plugin.Logger.LogDebug((object)$"{((Object)val5).name}.{empty}: {val7.enemyType.enemyName} - {val7.rarity} => {item5.Value}"); val7.rarity = item5.Value; } else { list.Add(new SpawnableEnemyWithRarity { enemyType = enemy, rarity = item5.Value }); Plugin.Logger.LogDebug((object)$"{((Object)val5).name}.{empty}: +({enemy.enemyName}, {item5.Value})"); } } } dictionary2.Clear(); } if (dictionary4.Count <= 0) { continue; } if (val5.dungeonFlowTypes.Length != 0 && (Object)(object)val2 != (Object)null) { IntWithRarity[] dungeonFlowTypes = val5.dungeonFlowTypes; foreach (IntWithRarity val8 in dungeonFlowTypes) { DungeonFlow dungeonFlow = val2.dungeonFlowTypes[val8.id].dungeonFlow; if (dictionary4.TryGetValue((dungeonFlow != null) ? ((Object)dungeonFlow).name : null, out var value)) { Plugin.Logger.LogDebug((object)$"{((Object)val5).name}.dungeonFlowTypes: {((Object)val2.dungeonFlowTypes[val8.id].dungeonFlow).name}, {val8.rarity} -> {value}"); val8.rarity = value; } } } dictionary4.Clear(); } if (val3 != null && val4 != null) { val3.numberToSpawn = val4; Plugin.Logger.LogDebug((object)"ArtificeLevel.spawnableMapObjects.TurretContainer"); } foreach (Item items in __instance.allItemsList.itemsList) { switch (((Object)items).name) { case "Jetpack": Plugin.Logger.LogDebug((object)$"{((Object)items).name}.batteryUsage: {items.batteryUsage}s -> 40s"); items.batteryUsage = 40f; break; case "ZapGun": Plugin.Logger.LogDebug((object)$"{((Object)items).name}.creditsWorth: {items.creditsWorth} -> $200"); items.creditsWorth = 200; break; case "StunGrenade": Plugin.Logger.LogDebug((object)$"{((Object)items).name}.creditsWorth: {items.creditsWorth} -> $40"); items.creditsWorth = 40; break; case "RadarBooster": Plugin.Logger.LogDebug((object)$"{((Object)items).name}.creditsWorth: {items.creditsWorth} -> $50"); items.creditsWorth = 50; break; } } foreach (KeyValuePair<string, EnemyType> item6 in dictionary) { if (item6.Key == "Butler") { item6.Value.increasedChanceInterior = 1; Plugin.Logger.LogDebug((object)"Butler.increasedChanceInterior: 1"); } } IndoorMapType val9 = ((IEnumerable<IndoorMapType>)val2?.dungeonFlowTypes).FirstOrDefault((Func<IndoorMapType, bool>)((IndoorMapType dungeonFlowType) => ((Object)dungeonFlowType.dungeonFlow).name == "Level3Flow")); if (val9 != null) { Plugin.Logger.LogDebug((object)$"Level3Flow.MapTileSize: {val9.MapTileSize} -> 1.1"); val9.MapTileSize = 1.111111f; } } [HarmonyPatch(typeof(NutcrackerEnemyAI), "GrabGun")] [HarmonyPostfix] private static void PostGrabGun(NutcrackerEnemyAI __instance, int ___randomSeedNumber) { if (!StartOfRound.Instance.isChallengeFile && !((NetworkBehaviour)__instance).IsServer && ((GrabbableObject)__instance.gun).scrapValue == 60) { ((GrabbableObject)__instance.gun).SetScrapValue(new Random(___randomSeedNumber).Next(25, 90)); } } [HarmonyPatch(typeof(NutcrackerEnemyAI), "InitializeNutcrackerValuesClientRpc")] [HarmonyPostfix] private static void PostInitializeNutcrackerValuesClientRpc(NutcrackerEnemyAI __instance, int ___randomSeedNumber) { if (!StartOfRound.Instance.isChallengeFile && (Object)(object)__instance.gun != (Object)null) { ((GrabbableObject)__instance.gun).SetScrapValue(new Random(___randomSeedNumber).Next(25, 90)); } } [HarmonyPatch(typeof(LungProp), "Start")] [HarmonyPostfix] private static void LungPropPostStart(LungProp __instance) { if (!StartOfRound.Instance.isChallengeFile && (Object)(object)startMatchLever != (Object)null && startMatchLever.leverHasBeenPulled && ((GrabbableObject)__instance).scrapValue == 80) { ((GrabbableObject)__instance).scrapValue = new Random(StartOfRound.Instance.randomMapSeed).Next(40, 120); } } [HarmonyPatch(typeof(GrabbableObject), "Start")] [HarmonyPostfix] private static void GrabbableObjectPostStart(GrabbableObject __instance) { if (!StartOfRound.Instance.isChallengeFile && (Object)(object)startMatchLever != (Object)null && startMatchLever.leverHasBeenPulled && __instance is KnifeItem) { __instance.SetScrapValue((int)((float)new Random(StartOfRound.Instance.randomMapSeed + (int)((NetworkBehaviour)__instance).NetworkObjectId).Next(70, 210) * RoundManager.Instance.scrapValueMultiplier)); } } [HarmonyPatch(typeof(TetraChemicalItem), "Update")] [HarmonyTranspiler] private static IEnumerable<CodeInstruction> TZPUpdate(IEnumerable<CodeInstruction> instructions) { List<CodeInstruction> list = instructions.ToList(); for (int i = 0; i < list.Count; i++) { if (list[i].opcode == OpCodes.Ldc_R4 && (float)list[i].operand == 22f) { list[i].operand = 24f; Plugin.Logger.LogDebug((object)"Transpiler (TZP capacity): Increase to 24"); return list; } } return instructions; } [HarmonyPatch(typeof(RuntimeDungeon), "Generate")] [HarmonyPrefix] private static void RuntimeDungeonPreGenerate(RuntimeDungeon __instance) { if (!StartOfRound.Instance.isChallengeFile && RoundManager.Instance.currentDungeonType == 4) { if (((Object)StartOfRound.Instance.currentLevel).name == "ArtificeLevel") { DungeonGenerator generator = __instance.Generator; generator.LengthMultiplier *= 0.9f; } else if (((Object)StartOfRound.Instance.currentLevel).name == "DineLevel") { DungeonGenerator generator2 = __instance.Generator; generator2.LengthMultiplier *= Mathf.Min(new float[3] { StartOfRound.Instance.levels[6].factorySizeMultiplier / StartOfRound.Instance.currentLevel.factorySizeMultiplier * 1.0833333f, 0.923077f, 1f }); } } } [HarmonyPatch(typeof(FlowermanAI), "Start")] [HarmonyPostfix] private static void PostChooseFarthestNodeFromPosition(FlowermanAI __instance) { tempNodeDistance = -1f; } [HarmonyPatch(typeof(EnemyAI), "ChooseFarthestNodeFromPosition")] [HarmonyPostfix] private static void PostChooseFarthestNodeFromPosition(EnemyAI __instance, Transform __result) { if ((Object)(object)__result != (Object)null && __instance is FlowermanAI) { tempNodeDistance = __instance.mostOptimalDistance; } } [HarmonyPatch(typeof(FlowermanAI), "AvoidClosestPlayer")] [HarmonyPrefix] private static void FlowermanAIPreAvoidClosestPlayer(FlowermanAI __instance, ref float __state) { __state = ((EnemyAI)__instance).mostOptimalDistance; if (tempNodeDistance >= 0f) { ((EnemyAI)__instance).mostOptimalDistance = tempNodeDistance; } } [HarmonyPatch(typeof(FlowermanAI), "AvoidClosestPlayer")] [HarmonyPostfix] private static void FlowermanAIPostAvoidClosestPlayer(FlowermanAI __instance, float __state) { ((EnemyAI)__instance).mostOptimalDistance = __state; } } public static class PluginInfo { public const string PLUGIN_GUID = "LegalCompany"; public const string PLUGIN_NAME = "LegalCompany"; public const string PLUGIN_VERSION = "0.0.0"; } }