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 Artery Corp v1.0.5
ArteryCorp.dll
Decompiled 2 years agousing System; using System.Collections; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Text.RegularExpressions; using ArteryCorp.Patches; using BepInEx; using BepInEx.Logging; using GameNetcodeStuff; using HarmonyLib; using Microsoft.CodeAnalysis; using TMPro; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("ArteryCorp")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("ArteryCorp")] [assembly: AssemblyCopyright("Copyright © 2023")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("b380f013-90e9-45c0-8c83-5667cad99cab")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyVersion("1.0.0.0")] [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 ArteryCorp { internal class PlayerPluginData : MonoBehaviour { public float frostProgress = 0f; public bool beingHeated = false; public float frostSpeed = 3.5f; public float shipHeatSpeed = 1f; public float facilityHeatSpeed = 3f; public float radarHeatSpeed = 3.5f; public string currentlyExperiencing = "None"; public int frostDamage = 7; } internal class WorldPluginData : MonoBehaviour { public string currentCustomWeather = "None"; public bool weatherLoaded = false; public int daysLeft = 4; } [BepInPlugin("mauskator.ArteryCorp", "Artery Corporation", "1.0.0")] public class ArteryCorpCore : BaseUnityPlugin { private const string modGUID = "mauskator.ArteryCorp"; private const string modName = "Artery Corporation"; private const string modVersion = "1.0.0"; private readonly Harmony harm = new Harmony("mauskator.ArteryCorp"); public static ArteryCorpCore Instance; public ManualLogSource mls; private void Awake() { if ((Object)(object)Instance == (Object)null) { Instance = this; } ((Object)((Component)Instance).gameObject).hideFlags = (HideFlags)61; mls = Logger.CreateLogSource("mauskator.ArteryCorp"); mls.LogInfo((object)"Artery Corporation active!"); harm.PatchAll(typeof(ArteryCorpCore)); harm.PatchAll(typeof(PlayerControllerBPatch)); harm.PatchAll(typeof(StartOfRoundPatch)); harm.PatchAll(typeof(TerminalCustomWeatherPatch)); harm.PatchAll(typeof(RoundManagerPatch)); harm.PatchAll(typeof(RadarBoosterPatch)); mls.LogInfo((object)"Artery Corporation loaded!"); } } } namespace ArteryCorp.Patches { [HarmonyPatch(typeof(RoundManager))] internal class RoundManagerPatch { [HarmonyPatch("Awake")] [HarmonyPostfix] private static void Function(RoundManager __instance) { if ((Object)(object)((Component)((Component)__instance).transform).gameObject.GetComponent<WorldPluginData>() == (Object)null) { ((Component)((Component)__instance).transform).gameObject.AddComponent<WorldPluginData>(); } } } [HarmonyPatch(typeof(RadarBoosterItem))] public static class RadarBoosterPatch { public static float heatingRange = 5f; [HarmonyPatch("Update")] [HarmonyPostfix] private static void Function(RadarBoosterItem __instance, ref bool ___radarEnabled) { //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts; GameObject[] allPlayerObjects = StartOfRound.Instance.allPlayerObjects; for (int i = 0; i < allPlayerScripts.Length; i++) { if (allPlayerScripts[i].health > 0) { bool beingHeated = false; if (Vector3.Distance(allPlayerObjects[i].transform.position, ((Component)__instance).transform.position) <= heatingRange && ___radarEnabled && !((GrabbableObject)__instance).isPocketed) { beingHeated = true; } ((Component)((Component)allPlayerScripts[i].thisPlayerModel).transform).gameObject.GetComponent<PlayerPluginData>().beingHeated = beingHeated; } } } } [HarmonyPatch(typeof(StartOfRound))] public static class StartOfRoundPatch { [HarmonyPatch("SetPlanetsWeather")] [HarmonyPostfix] private static void Function(ref SelectableLevel[] ___levels, ref int ___randomMapSeed) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) LevelWeatherType currentWeather = (LevelWeatherType)6; for (int i = 0; i < ___levels.Length; i++) { string planetName = ___levels[i].PlanetName; if (planetName == "85 Rend" || planetName == "7 Dine" || planetName == "8 Titan") { int num = 0; Random random = new Random(___randomMapSeed + 31); int num2 = random.Next(1, 11); switch (planetName) { case "85 Rend": num = 9; break; case "7 Dine": num = 6; break; case "8 Titan": num = 4; break; } if (num2 >= num || TimeOfDay.Instance.daysUntilDeadline == 1) { ___levels[i].currentWeather = currentWeather; } } } } [HarmonyPatch("SetMapScreenInfoToCurrentLevel")] [HarmonyPostfix] private static void Function() { //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Invalid comparison between Unknown and I4 string text = ((object)(LevelWeatherType)(ref StartOfRound.Instance.currentLevel.currentWeather)).ToString(); switch (text) { case "DustClouds": text = "Arid sandstorms"; break; case "Rainy": text = "Light rain"; break; case "Stormy": text = "Heavy storms"; break; case "Foggy": text = "Thick fog"; break; case "Flooded": text = "Abnormal water levels"; break; case "Eclipsed": text = "Total solar eclipse"; break; case "6": text = "Heavy snowstorms"; break; } string text2 = (((int)StartOfRound.Instance.currentLevel.currentWeather == -1) ? "" : ("Weather: " + text)); string levelDescription = StartOfRound.Instance.currentLevel.LevelDescription; ((TMP_Text)StartOfRound.Instance.screenLevelDescription).text = "Orbiting: " + StartOfRound.Instance.currentLevel.PlanetName + "\n" + levelDescription + "\n" + text2; } [HarmonyPatch("openingDoorsSequence")] [HarmonyPrefix] private static void Function(StartOfRound __instance) { string currentCustomWeather = ((Component)RoundManager.Instance).gameObject.GetComponent<WorldPluginData>().currentCustomWeather; if (currentCustomWeather == "6") { HUDManager.Instance.DisplayTip("/// WARNING ///", "Ongoing super-blizzard at target location. For your safety, please bring heating equipment.", false, false, "LC_Tip1"); } } } [HarmonyPatch(typeof(Terminal))] public class TerminalCustomWeatherPatch { [HarmonyPatch("TextPostProcess")] [HarmonyPostfix] private static void Function(ref string __result, SelectableLevel[] ___moonsCatalogueList, object[] __args, Terminal __instance) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Expected O, but got Unknown //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Invalid comparison between Unknown and I4 //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Invalid comparison between Unknown and I4 string text = __args[0].ToString(); Regex regex = new Regex(Regex.Escape("[planetTime]")); TerminalNode val = (TerminalNode)__args[1]; bool flag = false; for (int i = 0; ___moonsCatalogueList.Length > i; i++) { string text2 = Regex.Replace(___moonsCatalogueList[i].PlanetName, "[\\d-]", string.Empty); string text3 = ((object)(LevelWeatherType)(ref ___moonsCatalogueList[i].currentWeather)).ToString(); string text4 = "6"; string text5 = text3.ToLower(); bool flag2 = false; if (text3.Length > 2) { continue; } flag = true; string text6 = text3; string text7 = text6; if (text7 == "6") { text4 = "6"; text3 = "Snowstorm"; } if (__args[0].ToString().IndexOf("[currentPlanetTime]") != -1) { string text8 = (((int)StartOfRound.Instance.levels[val.displayPlanetInfo].currentWeather != -1) ? (((object)(LevelWeatherType)(ref StartOfRound.Instance.levels[val.displayPlanetInfo].currentWeather)).ToString().ToLower() ?? "") : "mild weather"); string text9 = "6"; string text10 = text8; string text11 = text10; if (text11 == "6") { text8 = "freezing"; } text = __result.Replace(" " + text9 + " ", " " + text8 + " "); } else { string newValue = (((int)___moonsCatalogueList[i].currentWeather != -1) ? (" (" + text3 + ")") : ""); string text12 = __result; if (flag2) { text12 = text; } else { flag2 = true; } text = text12.Replace(" (" + text4 + ")", newValue); } } if (flag) { __result = text; } } } [HarmonyPatch(typeof(PlayerControllerB))] internal class PlayerControllerBPatch : MonoBehaviour { public static float Clamp(float num, float min, float max) { if (num > max) { num = max; } else if (num < min) { num = min; } return num; } private static IEnumerator StormCalc(StartOfRound ___playersManager, SkinnedMeshRenderer ___thisPlayerModel, PlayerControllerB __instance) { while (__instance.health > 0 && !___playersManager.inShipPhase) { PlayerPluginData body = ((Component)((Component)___thisPlayerModel).transform).gameObject.GetComponent<PlayerPluginData>(); if (!__instance.isInsideFactory && !__instance.isInHangarShipRoom && !body.beingHeated) { body.frostProgress = Clamp(body.frostProgress + body.frostSpeed, 0f, 100f); } else { float finalHeat = (__instance.isInHangarShipRoom ? body.shipHeatSpeed : ((!__instance.isInsideFactory) ? 1f : body.facilityHeatSpeed)); if (body.beingHeated) { finalHeat += body.radarHeatSpeed; } body.frostProgress = Clamp(body.frostProgress - finalHeat, 0f, 100f); } if (body.frostProgress >= 100f) { __instance.DamagePlayer(body.frostDamage, false, true, (CauseOfDeath)10, 0, false, default(Vector3)); } Console.WriteLine("FROST PROG: " + body.frostProgress); yield return (object)new WaitForSeconds(1.25f); } } [HarmonyPatch("Update")] [HarmonyPrefix] private static void Function(ref StartOfRound ___playersManager, ref SkinnedMeshRenderer ___thisPlayerModel, ref bool ___isPlayerControlled, PlayerControllerB __instance) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Invalid comparison between Unknown and I4 //IL_00a7: Unknown result type (might be due to invalid IL or missing references) if (!___isPlayerControlled) { return; } LevelWeatherType currentWeather = ___playersManager.currentLevel.currentWeather; string text = ((object)(LevelWeatherType)(ref currentWeather)).ToString(); WorldPluginData component = ((Component)((Component)RoundManager.Instance).transform).gameObject.GetComponent<WorldPluginData>(); if (text.Length >= 2 || ___playersManager.inShipPhase) { return; } if ((int)currentWeather != -1 && component.currentCustomWeather != text) { component.currentCustomWeather = text; string currentCustomWeather = component.currentCustomWeather; string text2 = currentCustomWeather; if (text2 == "6") { ___playersManager.currentLevel.currentWeather = (LevelWeatherType)3; } } PlayerPluginData component2 = ((Component)___thisPlayerModel).GetComponent<PlayerPluginData>(); if (component2.currentlyExperiencing != component.currentCustomWeather) { component2.currentlyExperiencing = component.currentCustomWeather; } string currentCustomWeather2 = component.currentCustomWeather; string text3 = currentCustomWeather2; if (text3 == "6") { IEnumerator enumerator = StormCalc(___playersManager, ___thisPlayerModel, __instance); try { ((MonoBehaviour)ArteryCorpCore.Instance).StartCoroutine(enumerator); } catch (Exception ex) { Console.WriteLine(ex.ToString()); } } } [HarmonyPatch("Start")] [HarmonyPostfix] private static void Function(ref SkinnedMeshRenderer ___thisPlayerModel) { if ((Object)(object)((Component)((Component)___thisPlayerModel).transform).gameObject.GetComponent<PlayerPluginData>() == (Object)null) { ((Component)((Component)___thisPlayerModel).transform).gameObject.AddComponent<PlayerPluginData>(); } } } }