Please disclose if your mod was created primarily 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 ExtraLethalCompany v1.2.2
ExtraLethalCompany.dll
Decompiled 2 years agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text.RegularExpressions; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Logging; using ExtraLethalCompany.Extra.Creatures; using ExtraLethalCompany.Extra.ExtraTraitor; using ExtraLethalCompany.Extra.Furniture.ExtraItemCharger; using ExtraLethalCompany.Patches; using GameNetcodeStuff; using HarmonyLib; using LC_API.ClientAPI; using LC_API.Data; using LC_API.GameInterfaceAPI; using LC_API.ServerAPI; using Microsoft.CodeAnalysis; using Steamworks.Data; using TMPro; using Unity.Netcode; using UnityEngine; using UnityEngine.InputSystem; using UnityEngine.InputSystem.Controls; using UnityEngine.Rendering.HighDefinition; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("ExtraLethalCompany")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyDescription("My first plugin")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("ExtraLethalCompany")] [assembly: AssemblyTitle("ExtraLethalCompany")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.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 ExtraLethalCompany { internal static class Disabler { public static int MinimumToExplode; internal static void Init() { foreach (PluginInfo value in Chainloader.PluginInfos.Values) { MethodInfo method = typeof(Disabler).GetMethod(value.Metadata.GUID.Replace('.', '_').Replace(' ', '_'), BindingFlags.Static | BindingFlags.NonPublic); if (method != null) { ExtraLethalCompany.LogSource.LogInfo((object)("Disabling: " + ((object)value.Instance).GetType().Name)); method.Invoke(typeof(Disabler), new object[1] { value.Instance }); } } } private static void LethalCompanyMinimap(object inst) { DisableHarmony(inst, "harmony"); Object.DestroyImmediate((Object)(object)GameObject.Find("MinimapGUI")); } private static void dev_alexanderdiaz_biggerbattery(object _) { MinimumToExplode = -3; } private static void stormytuna_RouteRandom(object inst) { DisableHarmony(inst, "harmony"); } private static void NoPenalty(object inst) { DisableHarmony(inst, "harmonymain"); } private static void DisableHarmony(object inst, string harmonyName) { Traverse.Create(inst).Field(harmonyName).GetValue<Harmony>() .UnpatchSelf(); } } [BepInPlugin("ExtraLethalCompany", "ExtraLethalCompany", "1.1.5")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public class ExtraLethalCompany : BaseUnityPlugin { public static ManualLogSource LogSource; private static readonly Harmony Harmony = new Harmony("ExtraLethalCompany"); private void Awake() { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Expected O, but got Unknown if (((Object)((Component)this).gameObject).name != "ExtraLethalCompany") { GameObject val = new GameObject("ExtraLethalCompany"); val.AddComponent<ExtraLethalCompany>(); val.AddComponent<ExtraSporeLizzard>(); val.AddComponent<ExtraTraitor>(); Object.DontDestroyOnLoad((Object)(object)val); ((Object)val).hideFlags = (HideFlags)61; } else { LogSource = ((BaseUnityPlugin)this).Logger; ModdedServer.SetServerModdedOnly(); Disabler.Init(); Harmony.PatchAll(typeof(HUDManager_Patch)); Harmony.PatchAll(typeof(Terminal_Patch)); Harmony.PatchAll(typeof(ItemCharger_Patch)); Harmony.PatchAll(typeof(StartOfRound_Patch)); Harmony.PatchAll(typeof(TimeOfDay_Patch)); Harmony.PatchAll(typeof(BlobAI_Patch)); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin ExtraLethalCompany is loaded!"); } } private void Update() { //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Invalid comparison between Unknown and I4 BlobAI[] array = Object.FindObjectsOfType<BlobAI>(); foreach (BlobAI val in array) { GameObject gameObject = ((Component)val).gameObject; if ((Object)(object)gameObject.GetComponent<ExtraBlob>() == (Object)null) { gameObject.AddComponent<ExtraBlob>(); } } if ((int)GameState.ShipState != 0 && (int)GameState.ShipState != 1) { return; } ItemCharger[] array2 = Object.FindObjectsOfType<ItemCharger>(); foreach (ItemCharger val2 in array2) { GameObject gameObject2 = ((Component)val2).gameObject; if ((Object)(object)gameObject2.GetComponent<ExtraItemCharger>() == (Object)null) { gameObject2.AddComponent<ExtraItemCharger>(); } } } private void LobbyEntered(Lobby lobby) { throw new NotImplementedException(); } } public static class PluginInfo { public const string PLUGIN_GUID = "ExtraLethalCompany"; public const string PLUGIN_NAME = "ExtraLethalCompany"; public const string PLUGIN_VERSION = "1.0.0"; } } namespace ExtraLethalCompany.Patches { internal static class HUDManager_Patch { [HarmonyPatch(typeof(HUDManager), "ApplyPenalty")] [HarmonyPrefix] private static bool ApplyPenaltyPrefix(HUDManager __instance, int playersDead, ref int bodiesInsured) { Terminal val = Object.FindObjectOfType<Terminal>(); int profitQuota = TimeOfDay.Instance.profitQuota; int num = (int)((float)profitQuota * ((float)(playersDead - bodiesInsured) * 0.2f) + (float)profitQuota * ((float)bodiesInsured * 0.08f)); int num2 = -Math.Min(val.groupCredits - num, 0); val.groupCredits -= num - num2; TimeOfDay instance = TimeOfDay.Instance; instance.profitQuota += num2; ((TMP_Text)__instance.statsUIElements.penaltyAddition).text = $"{playersDead} casualties: -{20f * (float)(playersDead - bodiesInsured)}%\n" + $"{bodiesInsured} injuries: -{8f * (float)bodiesInsured}%\n" + "\nAll unpaid fines will be added to your quota."; ((TMP_Text)__instance.statsUIElements.penaltyTotal).text = $"PAID: {num - num2}" + "\n" + $"DUE: {num2}"; return false; } } internal static class StartOfRound_Patch { [HarmonyPatch(typeof(StartOfRound), "PowerSurgeShip")] [HarmonyPrefix] private static bool PowerSurgeShipPrefix(StartOfRound __instance) { __instance.mapScreen.SwitchScreenOn(false); if (!((NetworkBehaviour)__instance).IsServer) { return false; } CollectionExtensions.Do<TVScript>((IEnumerable<TVScript>)Object.FindObjectsOfType<TVScript>(), (Action<TVScript>)delegate(TVScript obj) { obj.TurnOffTVServerRpc(); }); __instance.shipRoomLights.SetShipLightsServerRpc(false); if (Random.Range(0, 10) == 0) { TimeOfDay.Instance.SetShipLeaveEarlyClientRpc(TimeOfDay.Instance.normalizedTimeOfDay + 0.04167f, TimeOfDay.Instance.votesForShipToLeaveEarly); } return false; } [HarmonyPatch(typeof(StartOfRound), "SetMapScreenInfoToCurrentLevel")] [HarmonyPostfix] private static void SetMapScreenInfoToCurrentLevelPrefix(StartOfRound __instance) { ((TMP_Text)__instance.screenLevelDescription).text = "Orbiting: " + __instance.currentLevel.PlanetName + "\n" + __instance.currentLevel.LevelDescription + "\n" + "{Sensor Err}"; } } internal static class Terminal_Patch { [HarmonyPatch(typeof(Terminal), "TextPostProcess")] [HarmonyPrefix] private static bool TextPostProcessPrefix(Terminal __instance, ref string __result, ref string modifiedDisplayText, TerminalNode node) { int num = modifiedDisplayText.Split("[planetTime]").Length - 1; if (num > 0) { Regex regex = new Regex(Regex.Escape("[planetTime]")); for (int i = 0; i < num && i < __instance.moonsCatalogueList.Length; i++) { modifiedDisplayText = regex.Replace(modifiedDisplayText, "{SENSOR ERR}", 1); } } if (node == null || node.displayPlanetInfo != -1) { modifiedDisplayText = modifiedDisplayText?.Replace("[currentPlanetTime]", "{SENSOR ERR}"); } __result = modifiedDisplayText; return true; } } internal static class TimeOfDay_Patch { [HarmonyPatch(typeof(TimeOfDay), "SetBuyingRateForDay")] [HarmonyPrefix] private static bool SetBuyingRateForDayPrefix(TimeOfDay __instance) { __instance.daysUntilDeadline = (int)(__instance.timeUntilDeadline / __instance.totalTime); StartOfRound.Instance.companyBuyingRate = 1.15f - (float)(__instance.quotaVariables.deadlineDaysAmount - __instance.daysUntilDeadline) * (0.54f / (float)__instance.quotaVariables.deadlineDaysAmount); return false; } [HarmonyPatch(typeof(TimeOfDay), "SetShipLeaveEarlyServerRpc")] [HarmonyPostfix] private static void SetShipLeaveEarlyServerRpcPostfix(TimeOfDay __insntance) { int num = StartOfRound.Instance.connectedPlayersAmount + 1 - StartOfRound.Instance.livingPlayers; if (__insntance.votesForShipToLeaveEarly >= num) { __insntance.SetShipLeaveEarlyClientRpc(__insntance.normalizedTimeOfDay + 0.01f, __insntance.votesForShipToLeaveEarly); } } } } namespace ExtraLethalCompany.Extra.Furniture.ExtraItemCharger { public class ExtraItemCharger : MonoBehaviour { private ItemCharger Charger; private GrabbableObject Item; private Coroutine Coroutine; public string ID { get; private set; } private void Awake() { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) Charger = ((Component)this).gameObject.GetComponent<ItemCharger>(); Vector3 position = ((Component)this).transform.position; ID = $"{(int)position.x}-{(int)position.y}-{(int)position.z}"; GameState.ShipStartedLeaving += delegate { Networking.SetSyncVariable("IsBroken" + ID, "False"); }; } private void Update() { if (Networking.GetSyncVariable("IsActive" + ID) == "") { Networking.RegisterSyncVariable("IsActive" + ID); Networking.SetSyncVariable("IsActive" + ID, "False"); } if (Networking.GetSyncVariable("IsBroken" + ID) == "") { Networking.RegisterSyncVariable("IsBroken" + ID); Networking.SetSyncVariable("IsBroken" + ID, "False"); } if (Coroutine == null && Networking.GetSyncVariable("IsActive" + ID) == "True") { Coroutine = ((MonoBehaviour)this).StartCoroutine(ChargeItemDelayed(Charger, Item)); } } public void AskStartCharging(GrabbableObject item) { if (!(Networking.GetSyncVariable("IsBroken" + ID) == "True") && !(Networking.GetSyncVariable("IsActive" + ID) == "True")) { Item = item; bool flag = item.itemProperties.isConductiveMetal || Random.RandomRangeInt(-10, (int)(item.insertedBattery.charge * 10f) + 1) >= Disabler.MinimumToExplode; Networking.SetSyncVariable("IsBroken" + ID, flag.ToString()); Networking.SetSyncVariable("IsActive" + ID, "True"); } } private IEnumerator ChargeItemDelayed(ItemCharger inst, GrabbableObject item) { inst.zapAudio.Play(); yield return (object)new WaitForSeconds(0.75f); inst.chargeStationAnimator.SetTrigger("zap"); if ((Object)(object)item != (Object)null && item.itemProperties.requiresBattery) { item.SyncBatteryServerRpc(100); Item = null; } if (Networking.GetSyncVariable("IsBroken" + ID) == "True") { Landmine.SpawnExplosion(((Component)this).transform.position, true, 2.4f, 5f); StartOfRound.Instance.PowerSurgeShip(); } Networking.SetSyncVariable("IsActive" + ID, "False"); Coroutine = null; } } internal static class ItemCharger_Patch { [HarmonyPatch(typeof(ItemCharger), "ChargeItem")] [HarmonyPrefix] private static bool ChargeItemPrefix(ItemCharger __instance) { if (!StartOfRound.Instance.shipHasLanded) { return false; } GrabbableObject currentlyHeldObjectServer = GameNetworkManager.Instance.localPlayerController.currentlyHeldObjectServer; if ((Object)(object)currentlyHeldObjectServer == (Object)null) { return false; } if (!currentlyHeldObjectServer.itemProperties.requiresBattery && !currentlyHeldObjectServer.itemProperties.isConductiveMetal) { return false; } ExtraItemCharger component = ((Component)__instance).gameObject.GetComponent<ExtraItemCharger>(); component.AskStartCharging(currentlyHeldObjectServer); return false; } [HarmonyPatch(typeof(ItemCharger), "Update")] [HarmonyPrefix] private static bool UpdatePrefix(ItemCharger __instance) { //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)NetworkManager.Singleton == (Object)null) { return false; } ExtraItemCharger component = ((Component)__instance).gameObject.GetComponent<ExtraItemCharger>(); Traverse val = Traverse.Create((object)__instance).Field("updateInterval"); val.SetValue((object)(val.GetValue<float>() + Time.deltaTime)); if (val.GetValue<float>() > 1f) { val.SetValue((object)0f); ShipState shipState = GameState.ShipState; if (!((object)(ShipState)(ref shipState)).Equals((object)(ShipState)1)) { __instance.triggerScript.interactable = false; __instance.triggerScript.disabledHoverTip = "[Wait for ship to land]"; return false; } if ((Object)(object)component != (Object)null && Networking.GetSyncVariable("IsBroken" + component.ID) == "True") { __instance.triggerScript.interactable = false; __instance.triggerScript.disabledHoverTip = "[Charger broken for the round]"; return false; } GrabbableObject val2 = GameNetworkManager.Instance.localPlayerController?.currentlyHeldObjectServer; __instance.triggerScript.interactable = (Object)(object)val2 != (Object)null && (val2.itemProperties.requiresBattery || val2.itemProperties.isConductiveMetal); __instance.triggerScript.disabledHoverTip = ""; } return false; } } } namespace ExtraLethalCompany.Extra.ExtraTraitor { public class EnemyPlayerController : MonoBehaviour { public static EnemyPlayerController Instance; private Keyboard Keyboard = Keyboard.current; private void Awake() { Instance = this; } private void Update() { if (!((ButtonControl)Keyboard.f1Key).wasPressedThisFrame) { } } } public class ExtraTraitor : MonoBehaviour { private void Awake() { Networking.RegisterSyncVariable("TraitorID"); GameState.LandOnMoon += Landing; GameState.ShipStartedLeaving += Leaving; CommandHandler.RegisterCommand("morph", (Action<string[]>)delegate(string[] args) { if (StartOfRound.Instance.thisClientPlayerId == int.Parse(Networking.GetSyncVariable("TraitorID")) && args.Length >= 1) { ExtraLethalCompany.LogSource.LogInfo((object)args[0]); string text = args[0].ToLower(); string text2 = text; if (text2 != null) { switch (text2.Length) { case 5: switch (text2[1]) { case 'p': if (text2 == "spore") { } break; case 'l': if (text2 == "slime") { } break; case 'h': if (text2 == "ghost") { } break; case 'i': if (text2 == "giant") { } break; } break; case 7: switch (text2[0]) { case 'h': if (text2 == "hoarder") { } break; case 'b': if (text2 == "bracken") { } break; case 't': if (text2 == "thumper") { } break; } break; case 6: switch (text2[0]) { case 'm': if (text2 == "masked") { } break; case 's': if (text2 == "spider") { } break; case 'j': if (text2 == "jester") { } break; } break; case 4: switch (text2[0]) { case 'f': if (text2 == "flea") { } break; case 'c': if (text2 == "coil") { } break; case 'h': if (text2 == "hawk") { } break; case 'w': if (text2 == "worm") { } break; } break; case 10: if (text2 == "nutcracker") { } break; case 3: if (text2 == "dog") { } break; case 8: case 9: break; } } } }); } private void Landing() { if (((NetworkBehaviour)StartOfRound.Instance).IsHost) { Networking.SetSyncVariable("TraitorID", Random.RandomRangeInt(-1, StartOfRound.Instance.allPlayerScripts.Length).ToString()); } } private void Leaving() { if (((NetworkBehaviour)StartOfRound.Instance).IsHost) { Networking.SetSyncVariable("TraitorID", ""); } } } } namespace ExtraLethalCompany.Extra.Creatures { internal static class BlobAI_Patch { [HarmonyPatch(typeof(BlobAI), "SlimeKillPlayerEffectServerRpc")] [HarmonyPostfix] private static void SlimeKillPlayerEffectServerRpc(BlobAI __instance, int playerKilled) { if (((NetworkBehaviour)__instance).IsHost) { ((Component)__instance).gameObject.GetComponent<ExtraBlob>()?.AskEatPlayerBody(playerKilled); } } } public class ExtraBlob : MonoBehaviour { public Coroutine EatPlayerBodyCoroutine; private BlobAI Blob; private void Awake() { Blob = ((Component)this).gameObject.GetComponent<BlobAI>(); } private void OnCollisionEnter(Collision collision) { //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) if (((NetworkBehaviour)Blob).IsHost && ((EnemyAI)Blob).ventAnimationFinished && !((EnemyAI)Blob).isEnemyDead) { GrabbableObject component = ((Component)collision.collider).gameObject.GetComponent<GrabbableObject>(); if ((Object)(object)component != (Object)null) { Object.DestroyImmediate((Object)(object)component); Transform transform = ((Component)this).gameObject.transform; transform.localScale *= 1.05f; } } } public void AskEatPlayerBody(int playerKilled) { if (EatPlayerBodyCoroutine == null) { EatPlayerBodyCoroutine = ((MonoBehaviour)this).StartCoroutine(EatPlayerBody(playerKilled)); } } private IEnumerator EatPlayerBody(int playerKilled) { yield return null; PlayerControllerB playerScript = StartOfRound.Instance.allPlayerScripts[playerKilled]; float startTime = Time.realtimeSinceStartup; yield return (object)new WaitUntil((Func<bool>)(() => (Object)(object)playerScript.deadBody != (Object)null || Time.realtimeSinceStartup - startTime > 2f)); if ((Object)(object)playerScript.deadBody == (Object)null) { Debug.Log((object)"Blob: Player body was not spawned or found within 2 seconds."); yield break; } yield return (object)new WaitForSeconds(2f); Transform transform = ((Component)this).gameObject.transform; transform.localScale *= 1.1f; } } public class ExtraSporeLizzard : MonoBehaviour { private void Update() { //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)StartOfRound.Instance == (Object)null) { return; } LocalVolumetricFog[] array = (from g in Object.FindObjectsOfType<LocalVolumetricFog>() where ((Object)g).name.Contains("PufferSmoke", StringComparison.OrdinalIgnoreCase) select g).ToArray(); if (array.Length == 0) { return; } PlayerControllerB val = StartOfRound.Instance.allPlayerScripts[StartOfRound.Instance.thisClientPlayerId]; Vector3 position = ((Component)val).gameObject.transform.position; for (int i = 0; i < array.Length; i++) { if (!(Vector3.Distance(position, ((Component)array[i]).transform.position) >= 1f)) { val.DamagePlayer((int)(15f * Time.deltaTime), true, true, (CauseOfDeath)5, 0, false, default(Vector3)); } } } } }