Decompiled source of VirtualInsanity v1.0.0

justsunnit.virtual_insanity.dll

Decompiled a week ago
using 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.Logging;
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.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+7523b383b90b572bb73bbf7d650f1fdc8f45d7fa")]
[assembly: AssemblyProduct("VirtualInsanity")]
[assembly: AssemblyTitle("justsunnit.virtual_insanity")]
[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.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.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[LobbyCompatibility(/*Could not decode attribute arguments.*/)]
	public class VirtualInsanity : BaseUnityPlugin
	{
		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;
			Patch();
			Logger.LogInfo((object)"justsunnit.virtual_insanity v1.0.0 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 static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "justsunnit.virtual_insanity";

		public const string PLUGIN_NAME = "VirtualInsanity";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace VirtualInsanity.Patches
{
	[HarmonyPatch(typeof(CaveDwellerAI), "Start")]
	public class BabyPatches
	{
		[HarmonyPostfix]
		public static void BabyPathes(CaveDwellerAI __instance)
		{
			__instance.TransformIntoAdult();
		}
	}
	[HarmonyPatch(typeof(ClaySurgeonAI), "HourChanged")]
	public class BarberPatches
	{
		[HarmonyPostfix]
		private static void BarberPatch(ClaySurgeonAI __instance)
		{
			__instance.currentInterval = 1f;
		}
	}
	[HarmonyPatch(typeof(BlobAI), "Update")]
	public class BlobPatches
	{
		[HarmonyPostfix]
		private static void BlobPatch(BlobAI __instance)
		{
			__instance.tamedTimer = 0f;
		}
	}
	[HarmonyPatch(typeof(SpringManAI), "Update")]
	public class CoilHeadPatches
	{
		[HarmonyPostfix]
		private static void CoilHeadPatch(SpringManAI __instance)
		{
			__instance.loseAggroTimer = 0f;
		}
	}
	[HarmonyPatch(typeof(NutcrackerEnemyAI), "Start")]
	public class deezNutcrackerPatches
	{
		[HarmonyPostfix]
		public static void NutcrakerPatch(NutcrackerEnemyAI __instance)
		{
			__instance.torsoTurnSpeed = 2500f;
			((EnemyAI)__instance).agent.speed = 10f;
		}
	}
	[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)
		{
			__instance.popUpTimer = Random.Range(1f, 5f);
		}
	}
	[HarmonyPatch(typeof(StartMatchLever), "Update")]
	public class LeverPatches
	{
		[HarmonyPrefix]
		public static void LeverPatch(StartMatchLever __instance)
		{
			if (__instance.playersManager.shipHasLanded)
			{
				if (RoundPatches.currentlevel.planetHasTime)
				{
					__instance.triggerScript.interactable = false;
				}
				else
				{
					__instance.triggerScript.interactable = true;
				}
			}
		}
	}
	[HarmonyPatch(typeof(PlayerControllerB), "Update")]
	public class PlayerPatches
	{
		public static bool playerInFacilty;

		public static float timeInShip = 10f;

		public static bool Counting;

		[HarmonyPostfix]
		public static void PlayerPatch(PlayerControllerB __instance)
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: 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)
			//IL_0086: 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_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_016f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0179: Unknown result type (might be due to invalid IL or missing references)
			//IL_017f: Unknown result type (might be due to invalid IL or missing references)
			if (!RoundPatches.ShipPhase)
			{
				if (__instance.isExhausted)
				{
					__instance.KillPlayer(new Vector3(0f, 0f, 0f), true, (CauseOfDeath)0, 0, default(Vector3));
					HudPatches.Instance.DisplayTip("Death Reason", "You've Tripped on oxygen", true, false, "LC_EclipseTip");
				}
				if (__instance.insanityLevel >= __instance.maxInsanityLevel)
				{
					__instance.KillPlayer(new Vector3(0f, 0f, 0f), true, (CauseOfDeath)0, 0, default(Vector3));
					HudPatches.Instance.DisplayTip("Death Reason", "Went Crazy", true, false, "LC_EclipseTip");
				}
				if (__instance.isUnderwater)
				{
					__instance.KillPlayer(new Vector3(0f, 0f, 0f), true, (CauseOfDeath)0, 0, default(Vector3));
					HudPatches.Instance.DisplayTip("Death Reason", "Your a terrible swimmer", true, false, "LC_EclipseTip");
				}
				__instance.drunkness = 0.5f;
				playerInFacilty = __instance.isInsideFactory;
				if (__instance.isInHangarShipRoom && Counting)
				{
					timeInShip -= Time.deltaTime;
				}
				if (timeInShip <= 0f)
				{
					__instance.KillPlayer(new Vector3(0f, 0f, 0f), true, (CauseOfDeath)0, 0, default(Vector3));
					HudPatches.Instance.DisplayTip("Death Reason", "NO LOITERING", true, false, "LC_EclipseTip");
				}
			}
			else if (RoundPatches.ShipPhase)
			{
				__instance.drunkness = 0f;
				Counting = false;
			}
		}
	}
	public class RoundPatches
	{
		public static int time = 5;

		public static bool tryDeath;

		public static bool elevatorRunning;

		public static SelectableLevel currentlevel;

		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_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: 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)
				{
					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_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Invalid comparison between Unknown and I4
			PlayerPatches.Counting = true;
			PlayerPatches.timeInShip = 150f;
			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)
		{
			__instance.fireRate = 0.1f;
		}
	}
	public class SnareFleaPatches
	{
		[HarmonyPatch(typeof(CentipedeAI), "Update")]
		[HarmonyPostfix]
		private static void CentipedePatch(CentipedeAI __instance)
		{
			__instance.damagePlayerInterval = 0f;
		}
	}
	[HarmonyPatch(typeof(Terminal), "Update")]
	public class TerminalPatches
	{
		[HarmonyPostfix]
		private static void ApplyMoonWeather(ref Terminal __instance)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			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)
		{
			((EnemyAI)__instance).agent.acceleration = 10f;
		}
	}
	public class TimeODay
	{
		[HarmonyPatch(typeof(TimeOfDay), "DecideRandomDayEvents")]
		[HarmonyPostfix]
		public static void MeteorPatch(TimeOfDay __instance)
		{
			__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) * 2;
			__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)
		{
		}
	}
}