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 VirtualInsanity v1.1.6
justsunnit.virtual_insanity.dll
Decompiled a year agousing System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using CSync.Extensions; using CSync.Lib; using GameNetcodeStuff; using HarmonyLib; using LobbyCompatibility.Attributes; using Microsoft.CodeAnalysis; using Unity.Netcode; using UnityEngine; using VirtualInsanity.Patches; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("justsunnit.virtual_insanity")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.1.6.0")] [assembly: AssemblyInformationalVersion("1.1.6+65701cab9770b4cc315a62059137b963e9e06243")] [assembly: AssemblyProduct("VirtualInsanity")] [assembly: AssemblyTitle("justsunnit.virtual_insanity")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.1.6.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.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [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 VirtualInsanity { public class Tools { public static bool checkNear(Vector3 Player, Vector3 target, int range) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) if (Player.x > target.x - (float)range && Player.x < target.x + (float)range && Player.z > target.z - (float)range && Player.z < target.z - (float)range) { return true; } return false; } } [BepInPlugin("justsunnit.virtual_insanity", "VirtualInsanity", "1.1.6")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency("com.sigurd.csync", "5.0.0")] [LobbyCompatibility(/*Could not decode attribute arguments.*/)] public class VirtualInsanity : BaseUnityPlugin { internal static VirtualInsanityConfig Config; public static VirtualInsanity Instance { get; private set; } internal static ManualLogSource Logger { get; private set; } internal static Harmony? Harmony { get; set; } private void Awake() { Logger = ((BaseUnityPlugin)this).Logger; Instance = this; Config = new VirtualInsanityConfig(((BaseUnityPlugin)this).Config); Patch(); Logger.LogInfo((object)"justsunnit.virtual_insanity v1.1.6 has loaded!"); } internal static void Patch() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Expected O, but got Unknown if (Harmony == null) { Harmony = new Harmony("justsunnit.virtual_insanity"); } Logger.LogDebug((object)"Patching..."); Harmony.PatchAll(typeof(PlayerPatches)); Harmony.PatchAll(typeof(JesterPatches)); Harmony.PatchAll(typeof(BlobPatches)); Harmony.PatchAll(typeof(BarberPatches)); Harmony.PatchAll(typeof(TerminalPatches)); Harmony.PatchAll(typeof(CoilHeadPatches)); Harmony.PatchAll(typeof(ThumperPatches)); Harmony.PatchAll(typeof(RoundPatches)); Harmony.PatchAll(typeof(SickAssRobot)); Harmony.PatchAll(typeof(SnareFleaPatches)); Harmony.PatchAll(typeof(BabyPatches)); Harmony.PatchAll(typeof(TimeODay)); Harmony.PatchAll(typeof(deezNutcrackerPatches)); Harmony.PatchAll(typeof(HudPatches)); Harmony.PatchAll(typeof(LeverPatches)); Logger.LogDebug((object)"Finished patching!"); } internal static void Unpatch() { Logger.LogDebug((object)"Unpatching..."); Harmony? harmony = Harmony; if (harmony != null) { harmony.UnpatchSelf(); } Logger.LogDebug((object)"Finished unpatching!"); } } public class VirtualInsanityConfig : SyncedConfig2<VirtualInsanityConfig> { [SyncedEntryField] public SyncedEntry<bool> DieOnExhaustion; [SyncedEntryField] public SyncedEntry<bool> DieOnWater; [SyncedEntryField] public SyncedEntry<bool> DieOnInsanity; [SyncedEntryField] public SyncedEntry<float> Drunkness; [SyncedEntryField] public SyncedEntry<bool> CanPullLever; [SyncedEntryField] public SyncedEntry<bool> ThumperChangesEnabled; [SyncedEntryField] public SyncedEntry<bool> JesterChangesEnabled; [SyncedEntryField] public SyncedEntry<bool> BabyChangesEnabled; [SyncedEntryField] public SyncedEntry<bool> BarberChangesEnabled; [SyncedEntryField] public SyncedEntry<bool> NutcrackerChangesEnabled; [SyncedEntryField] public SyncedEntry<bool> SnareChangesEnabled; [SyncedEntryField] public SyncedEntry<bool> RobotChangesEnabled; [SyncedEntryField] public SyncedEntry<bool> BlobChangesEnabled; [SyncedEntryField] public SyncedEntry<bool> CoilChangesEnabled; [SyncedEntryField] public SyncedEntry<bool> MeteorEnabled; [SyncedEntryField] public SyncedEntry<bool> EclipseEnabled; [SyncedEntryField] public SyncedEntry<bool> ElevatorBreakdownEnabled; [SyncedEntryField] public SyncedEntry<int> QuotaMultiplier; public VirtualInsanityConfig(ConfigFile cfg) : base("justsunnit.virtual_insanity") { //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Expected O, but got Unknown //IL_0225: Unknown result type (might be due to invalid IL or missing references) //IL_022f: Expected O, but got Unknown DieOnExhaustion = SyncedBindingExtensions.BindSyncedEntry<bool>(cfg, "Player", "Die On Exhaustion", true, "Player dies upon exhaustion."); DieOnWater = SyncedBindingExtensions.BindSyncedEntry<bool>(cfg, "Player", "Die On Water Contact", true, "Player dies upon water contact."); DieOnInsanity = SyncedBindingExtensions.BindSyncedEntry<bool>(cfg, "Player", "Die On Max Insanity", true, "Player dies upon reaching maximum insanity."); Drunkness = SyncedBindingExtensions.BindSyncedEntry<float>(cfg, "Player", "Drunkness", 0.2f, new ConfigDescription("Player's initial level of drunkness.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>())); CanPullLever = SyncedBindingExtensions.BindSyncedEntry<bool>(cfg, "Misc", "Can Pull Lever", true, "Allow players to pull the lever."); ThumperChangesEnabled = SyncedBindingExtensions.BindSyncedEntry<bool>(cfg, "Enemies", "Thumper Changes Enabled", true, "Enable changes for Thumper enemy."); JesterChangesEnabled = SyncedBindingExtensions.BindSyncedEntry<bool>(cfg, "Enemies", "Jester Changes Enabled", true, "Enable changes for Jester enemy."); BabyChangesEnabled = SyncedBindingExtensions.BindSyncedEntry<bool>(cfg, "Enemies", "Baby Changes Enabled", true, "Enable changes for Baby enemy."); BarberChangesEnabled = SyncedBindingExtensions.BindSyncedEntry<bool>(cfg, "Enemies", "Barber Changes Enabled", true, "Enable changes for Barber enemy."); NutcrackerChangesEnabled = SyncedBindingExtensions.BindSyncedEntry<bool>(cfg, "Enemies", "Nutcracker Changes Enabled", true, "Enable changes for Nutcracker enemy."); SnareChangesEnabled = SyncedBindingExtensions.BindSyncedEntry<bool>(cfg, "Enemies", "Snare Changes Enabled", true, "Enable changes for Snare enemy."); RobotChangesEnabled = SyncedBindingExtensions.BindSyncedEntry<bool>(cfg, "Enemies", "Robot Changes Enabled", true, "Enable changes for Robot enemy."); BlobChangesEnabled = SyncedBindingExtensions.BindSyncedEntry<bool>(cfg, "Enemies", "Blob Changes Enabled", true, "Enable changes for Blob enemy."); CoilChangesEnabled = SyncedBindingExtensions.BindSyncedEntry<bool>(cfg, "Enemies", "Coil Changes Enabled", true, "Enable changes for Coil enemy."); MeteorEnabled = SyncedBindingExtensions.BindSyncedEntry<bool>(cfg, "Environment", "Meteors Enabled", true, "Enable meteor events."); EclipseEnabled = SyncedBindingExtensions.BindSyncedEntry<bool>(cfg, "Environment", "Eclipse All Planets Enabled", true, "Enable eclipses for all planets."); ElevatorBreakdownEnabled = SyncedBindingExtensions.BindSyncedEntry<bool>(cfg, "Environment", "Elevator Breakdown Enabled", true, "Enable elevator breakdowns."); QuotaMultiplier = SyncedBindingExtensions.BindSyncedEntry<int>(cfg, "Money", "Quota Multiplier", 2, new ConfigDescription("Multiplier for quotas.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 10), Array.Empty<object>())); ConfigManager.Register<VirtualInsanityConfig>((SyncedConfig2<VirtualInsanityConfig>)(object)this); Console.WriteLine("Config registered"); } } public static class MyPluginInfo { public const string PLUGIN_GUID = "justsunnit.virtual_insanity"; public const string PLUGIN_NAME = "VirtualInsanity"; public const string PLUGIN_VERSION = "1.1.6"; } } namespace VirtualInsanity.Patches { [HarmonyPatch(typeof(CaveDwellerAI), "Start")] public class BabyPatches { [HarmonyPostfix] public static void BabyPathes(CaveDwellerAI __instance) { if (VirtualInsanity.Config.BabyChangesEnabled.Value) { __instance.TransformIntoAdult(); } } } [HarmonyPatch(typeof(ClaySurgeonAI), "HourChanged")] public class BarberPatches { [HarmonyPostfix] private static void BarberPatch(ClaySurgeonAI __instance) { if (VirtualInsanity.Config.BarberChangesEnabled.Value) { __instance.currentInterval = 1f; } } } [HarmonyPatch(typeof(BlobAI), "Update")] public class BlobPatches { [HarmonyPostfix] private static void BlobPatch(BlobAI __instance) { if (VirtualInsanity.Config.BlobChangesEnabled.Value) { __instance.tamedTimer = 0f; } } } [HarmonyPatch(typeof(SpringManAI), "Update")] public class CoilHeadPatches { [HarmonyPostfix] private static void CoilHeadPatch(SpringManAI __instance) { if (VirtualInsanity.Config.CoilChangesEnabled.Value) { __instance.loseAggroTimer = 0f; } } } [HarmonyPatch(typeof(NutcrackerEnemyAI), "Start")] public class deezNutcrackerPatches { [HarmonyPostfix] public static void NutcrakerPatch(NutcrackerEnemyAI __instance) { if (VirtualInsanity.Config.NutcrackerChangesEnabled.Value) { ((EnemyAI)__instance).agent.speed = 10f; __instance.torsoTurnSpeed = 2500f; } } } [HarmonyPatch(typeof(HUDManager), "Update")] public class HudPatches { public static HUDManager Instance; [HarmonyPostfix] public static void Postfix(HUDManager __instance) { Instance = __instance; } } [HarmonyPatch(typeof(JesterAI), "SetJesterInitialValues")] public class JesterPatches { [HarmonyPostfix] private static void JesterPatch(JesterAI __instance) { if (VirtualInsanity.Config.JesterChangesEnabled.Value) { __instance.popUpTimer = Random.Range(1f, 5f); } } } [HarmonyPatch(typeof(StartMatchLever), "Update")] public class LeverPatches { [HarmonyPrefix] public static void LeverPatch(StartMatchLever __instance) { if (__instance.playersManager.shipHasLanded && VirtualInsanity.Config.CanPullLever.Value) { if (RoundPatches.currentlevel.planetHasTime) { __instance.triggerScript.interactable = false; } else { __instance.triggerScript.interactable = true; } } } } [HarmonyPatch(typeof(PlayerControllerB), "Update")] public class PlayerPatches { public static bool playerInFacilty; [HarmonyPostfix] public static void PlayerPatch(PlayerControllerB __instance) { //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) if (!RoundPatches.ShipPhase) { if (VirtualInsanity.Config.DieOnExhaustion.Value && __instance.isExhausted) { __instance.KillPlayer(new Vector3(0f, 0f, 0f), true, (CauseOfDeath)0, 0, default(Vector3)); } if (__instance.insanityLevel >= __instance.maxInsanityLevel && VirtualInsanity.Config.DieOnInsanity.Value) { __instance.KillPlayer(new Vector3(0f, 0f, 0f), true, (CauseOfDeath)0, 0, default(Vector3)); } if (__instance.isUnderwater && VirtualInsanity.Config.DieOnWater.Value) { __instance.KillPlayer(new Vector3(0f, 0f, 0f), true, (CauseOfDeath)0, 0, default(Vector3)); } __instance.drunkness = VirtualInsanity.Config.Drunkness.Value; playerInFacilty = __instance.isInsideFactory; } else if (RoundPatches.ShipPhase) { __instance.drunkness = 0f; } } } public class RoundPatches { public static int time = 5; public static bool tryDeath; public static bool elevatorRunning; public static SelectableLevel currentlevel = null; public static bool ShipPhase; [HarmonyPatch(typeof(StartOfRound), "Update")] [HarmonyPostfix] private static void StartOfRoundPatch(StartOfRound __instance) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) currentlevel = __instance.currentLevel; Vector3 val = __instance.elevatorTransform.position + ((Component)__instance.localPlayerController).transform.position; if (((Vector3)(ref val)).magnitude >= 5f && __instance.elevatorTransform.position != new Vector3(0f, 0f, 0f) && !tryDeath && elevatorRunning && PlayerPatches.playerInFacilty) { if (Random.RandomRangeInt(1, 11) == 1 && VirtualInsanity.Config.ElevatorBreakdownEnabled.Value) { PlayerControllerB localPlayerController = __instance.localPlayerController; Vector3 val2 = new Vector3(0f, 0f, 0f); val = default(Vector3); localPlayerController.KillPlayer(val2, true, (CauseOfDeath)0, 0, val); tryDeath = true; HudPatches.Instance.DisplayTip("Death Reason", "Elevator Broke Down", true, false, "LC_EclipseTip"); } else { tryDeath = true; } } ShipPhase = __instance.inShipPhase; } [HarmonyPatch(typeof(StartOfRound), "OnShipLandedMiscEvents")] [HarmonyPrefix] public static bool StartOfRoundOnShipLandedMiscEventsPatch(StartOfRound __instance) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Invalid comparison between Unknown and I4 if ((int)TimeOfDay.Instance.currentLevelWeather == 5) { switch (Random.RandomRangeInt(1, 4)) { case 1: HudPatches.Instance.DisplayTip("Caution", "Loitering On The Ship Will Not be Tolerated >:(", true, false, "LC_EclipseTip"); break; case 2: HudPatches.Instance.DisplayTip("Caution", "Ship Lever Is Broken Sowwy :c", true, false, "LC_EclipseTip"); break; case 3: HudPatches.Instance.DisplayTip("Caution", "GO BE PRODUCTIVE, FOR THE COMPANY!!!", true, false, "LC_EclipseTip"); break; } } else { HudPatches.Instance.DisplayTip("71-Gordion", "Time to be Financially responsible", true, false, "LC_EclipseTip"); } return true; } [HarmonyPatch(typeof(MineshaftElevatorController), "Update")] [HarmonyPostfix] public static void ElevatorControllerPatch(MineshaftElevatorController __instance) { elevatorRunning = __instance.elevatorJingleMusic.isPlaying; if (!__instance.elevatorJingleMusic.isPlaying) { tryDeath = false; } } } public class SickAssRobot { [HarmonyPatch(typeof(RadMechAI), "Update")] [HarmonyPostfix] private static void Postfix(RadMechAI __instance) { if (VirtualInsanity.Config.RobotChangesEnabled.Value) { __instance.fireRate = 0.1f; } } } public class SnareFleaPatches { [HarmonyPatch(typeof(CentipedeAI), "Update")] [HarmonyPostfix] private static void CentipedePatch(CentipedeAI __instance) { if (VirtualInsanity.Config.SnareChangesEnabled.Value) { __instance.damagePlayerInterval = 0f; } } } [HarmonyPatch(typeof(Terminal), "Update")] public class TerminalPatches { [HarmonyPostfix] private static void ApplyMoonWeather(ref Terminal __instance) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) if (VirtualInsanity.Config.EclipseEnabled.Value) { SelectableLevel[] moonsCatalogueList = __instance.moonsCatalogueList; foreach (SelectableLevel val in moonsCatalogueList) { val.currentWeather = (LevelWeatherType)5; val.maxEnemyPowerCount = 40; val.maxOutsideEnemyPowerCount = 60; } } } } public class ThumperPatches { [HarmonyPatch(typeof(CrawlerAI), "Update")] private static void ThumperPatch(CrawlerAI __instance) { if (VirtualInsanity.Config.ThumperChangesEnabled.Value) { ((EnemyAI)__instance).agent.acceleration = 10f; } } } public class TimeODay { [HarmonyPatch(typeof(TimeOfDay), "DecideRandomDayEvents")] [HarmonyPostfix] public static void MeteorPatch(TimeOfDay __instance) { if (VirtualInsanity.Config.MeteorEnabled.Value) { __instance.meteorShowerAtTime = 0.1f; } } [HarmonyPatch(typeof(TimeOfDay), "SetNewProfitQuota")] [HarmonyPrefix] public static void SetNewProfitQuota(TimeOfDay __instance) { if (!((NetworkBehaviour)__instance).IsServer) { return; } __instance.timesFulfilledQuota++; int num = __instance.quotaFulfilled - __instance.profitQuota; float num2 = Mathf.Clamp((float)(1.0 + (double)__instance.timesFulfilledQuota * ((double)__instance.timesFulfilledQuota / (double)__instance.quotaVariables.increaseSteepness)), 0f, 10000f); __instance.CalculateLuckValue(); float num3 = Random.Range(0f, 1f); Debug.Log((object)$"Randomizer amount before: {num3}"); float num4 = num3 * Mathf.Abs(__instance.luckValue - 1f); Debug.Log((object)$"Randomizer amount after: {num4}"); float num5 = (float)((double)__instance.quotaVariables.baseIncrease * (double)num2 * ((double)__instance.quotaVariables.randomizerCurve.Evaluate(num4) * (double)__instance.quotaVariables.randomizerMultiplier + 1.0)); Debug.Log((object)$"Amount to increase quota:{num5}"); __instance.profitQuota = (int)Mathf.Clamp((float)__instance.profitQuota + num5, 0f, 1E+09f) * VirtualInsanity.Config.QuotaMultiplier.Value; __instance.quotaFulfilled = 0; __instance.timeUntilDeadline = __instance.totalTime * 4f; int num6 = num / 5 + 15 * __instance.daysUntilDeadline; __instance.furniturePlacedAtQuotaStart.Clear(); AutoParentToShip[] array = Object.FindObjectsByType<AutoParentToShip>((FindObjectsSortMode)0); for (int i = 0; i < array.Length; i++) { if (array[i].unlockableID != -1) { __instance.furniturePlacedAtQuotaStart.Add(array[i].unlockableID); } } __instance.SyncNewProfitQuotaClientRpc(__instance.profitQuota, num6, __instance.timesFulfilledQuota); } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } }