Decompiled source of MolesterLootBug v1.1.0

MolesterLootBug.dll

Decompiled 6 months 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 Microsoft.CodeAnalysis;
using UnityEngine;

[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("MolesterLootBug")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("A Mod for Lethal Company")]
[assembly: AssemblyFileVersion("1.0.1.0")]
[assembly: AssemblyInformationalVersion("1.0.1")]
[assembly: AssemblyProduct("MolesterLootBug")]
[assembly: AssemblyTitle("MolesterLootBug")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.1.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 LethalCompanyTemplate
{
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "MolesterLootBug";

		public const string PLUGIN_NAME = "MolesterLootBug";

		public const string PLUGIN_VERSION = "1.0.1";
	}
}
namespace MolesterLootBug
{
	[BepInPlugin("EvilLootBugByOwen.1.10", "Molester Loot Bug", "0.2")]
	public class Plugin : BaseUnityPlugin
	{
		public class BeingHeldData : MonoBehaviour
		{
			public bool isHeld = false;

			public HoarderBugAI HoarderInstance = null;

			public PlayerControllerB player = null;

			public float holdTimeRemaining = bugHoldTime;
		}

		public class HoldingData : MonoBehaviour
		{
			public bool isHoldingPlayer = false;

			public PlayerControllerB HeldPlayer = null;

			public float CanHoldTime = bugHoldTime;
		}

		private const string PLUGIN_GUID = "EvilLootBugByOwen.1.10";

		private const string PLUGIN_NAME = "Molester Loot Bug";

		private const string PLUGIN_VERSION = "0.2";

		private readonly Harmony harmony = new Harmony("EvilLootBugByOwen.1.10");

		private static Plugin Instance;

		internal static ManualLogSource mls;

		internal static Random random = new Random();

		private static float bugHoldTime = 8f;

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			mls = Logger.CreateLogSource("EvilLootBugByOwen.1.10");
			mls.LogInfo((object)"Mod Awake OWEN GOATED");
			harmony.PatchAll(typeof(Plugin));
		}

		[HarmonyPatch(typeof(PlayerControllerB), "Awake")]
		[HarmonyPostfix]
		private static void AwakeUpdate(PlayerControllerB __instance)
		{
			mls.LogInfo((object)"Attempting to Load instance Data, Player Awake Patch");
			((Component)__instance).gameObject.AddComponent<BeingHeldData>();
			BeingHeldData component = ((Component)__instance).gameObject.GetComponent<BeingHeldData>();
			component.player = __instance;
			mls.LogInfo((object)$"Is Being Held ON AWAKE? {component.isHeld}");
		}

		[HarmonyPatch(typeof(PlayerControllerB), "Update")]
		[HarmonyPostfix]
		private static void PlayerUpdate(PlayerControllerB __instance, ref Vector3 ___serverPlayerPosition, ref bool ___snapToServerPosition)
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: 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)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			BeingHeldData component = ((Component)__instance).gameObject.GetComponent<BeingHeldData>();
			if (!component.isHeld)
			{
				return;
			}
			Vector3 serverPosition = ((EnemyAI)component.HoarderInstance).serverPosition;
			Vector3 position = ((Component)__instance).gameObject.transform.position;
			Vector3 val = serverPosition - position;
			__instance.thisController.SimpleMove(val * 6f);
			mls.LogInfo((object)$"PlayerServer Pos at {__instance.serverPlayerPosition}");
			mls.LogInfo((object)$"Local Pos at {__instance.serverPlayerPosition}");
			mls.LogInfo((object)$"Loot Pos at {((EnemyAI)component.HoarderInstance).serverPosition}");
			mls.LogInfo((object)$"Bug Holding Player. Time left: {component.holdTimeRemaining}");
			component.holdTimeRemaining -= Time.deltaTime;
			mls.LogInfo((object)$"Is Being Held? {component.isHeld}");
			if (component.holdTimeRemaining <= 0f || __instance.isPlayerDead || ((EnemyAI)component.HoarderInstance).isEnemyDead)
			{
				component.isHeld = false;
				component.holdTimeRemaining = bugHoldTime;
				((Component)component.HoarderInstance).gameObject.GetComponent<HoldingData>().CanHoldTime = bugHoldTime;
				HoldingData component2 = ((Component)component.HoarderInstance).gameObject.GetComponent<HoldingData>();
				if ((Object)(object)component2 != (Object)null)
				{
					component2.isHoldingPlayer = false;
				}
			}
		}

		[HarmonyPatch(typeof(HoarderBugAI), "Start")]
		[HarmonyPostfix]
		private static void BugStart(HoarderBugAI __instance)
		{
			((Component)__instance).gameObject.AddComponent<HoldingData>();
		}

		[HarmonyPatch(typeof(HoarderBugAI), "OnCollideWithPlayer")]
		[HarmonyPostfix]
		private static void BugOnCollide(HoarderBugAI __instance, Collider other)
		{
			HoldingData component = ((Component)__instance).gameObject.GetComponent<HoldingData>();
			if (!component.isHoldingPlayer && random.Next(0, 2) == 0 && !((EnemyAI)__instance).isEnemyDead && component.CanHoldTime <= 0f)
			{
				PlayerControllerB component2 = ((Component)other).GetComponent<PlayerControllerB>();
				if ((Object)(object)component2 != (Object)null)
				{
					((Component)component2).gameObject.GetComponent<BeingHeldData>().isHeld = true;
					((Component)component2).gameObject.GetComponent<BeingHeldData>().HoarderInstance = __instance;
					((Component)__instance).gameObject.GetComponent<HoldingData>().isHoldingPlayer = true;
					((Component)__instance).gameObject.GetComponent<HoldingData>().HeldPlayer = component2;
				}
			}
		}

		[HarmonyPatch(typeof(HoarderBugAI), "Update")]
		[HarmonyPostfix]
		private static void BugUpdate(HoarderBugAI __instance)
		{
			HoldingData component = ((Component)__instance).gameObject.GetComponent<HoldingData>();
			if (component.isHoldingPlayer)
			{
				mls.LogInfo((object)"Bug Holding Player.");
				__instance.angryTimer -= 2f * Time.deltaTime;
				__instance.angryAtPlayer = null;
				__instance.timeSinceHittingPlayer = -5f;
				if (((EnemyAI)__instance).isEnemyDead)
				{
					component.isHoldingPlayer = false;
					BeingHeldData component2 = ((Component)component.HeldPlayer).gameObject.GetComponent<BeingHeldData>();
					component2.isHeld = false;
				}
			}
			else
			{
				component.CanHoldTime -= Time.deltaTime;
			}
		}
	}
}
namespace MolesterLootBug.Patches
{
	[HarmonyPatch(typeof(HoarderBugAI))]
	internal class LootBugPatch
	{
	}
	internal class PlayerControllerBPatch
	{
	}
}