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.Configuration;
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 MolesterLootBug
{
[BepInPlugin("Molesterbug.agutrot", "MolesterLootBug Fork by Agutrot", "1.0.0")]
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 = "Molesterbug.agutrot";
private const string PLUGIN_NAME = "MolesterLootBug Fork by Agutrot";
private const string PLUGIN_VERSION = "1.0.0";
public static ConfigEntry<float> config_holdTime;
public static ConfigEntry<int> config_grabOdds;
private readonly Harmony harmony = new Harmony("Molesterbug.agutrot");
private static Plugin Instance;
internal static ManualLogSource mls;
internal static Random random = new Random();
private static float bugHoldTime = 5f;
private static int bugGrabOdds = 20;
private void Awake()
{
if ((Object)(object)Instance == (Object)null)
{
Instance = this;
}
config_holdTime = ((BaseUnityPlugin)this).Config.Bind<float>("BUG SETTINGS", "holdTime", 5f, "Determines how long the player is held by the loot bug. Time is in seconds. Default 5 seconds");
config_grabOdds = ((BaseUnityPlugin)this).Config.Bind<int>("BUGSETTINGS", "grabOdds", 20, "Determines how high the odds are for the loot bug grabbing the player, default 20 percent");
bugHoldTime = config_holdTime.Value;
bugGrabOdds = config_grabOdds.Value;
mls = Logger.CreateLogSource("Molesterbug.agutrot");
mls.LogInfo((object)"Mod Awake OWEN GOATED");
mls.LogInfo((object)("Molester holds for " + bugHoldTime + " seconds"));
mls.LogInfo((object)("Molester has a " + bugGrabOdds + " percent chance to grab the player"));
harmony.PatchAll(typeof(Plugin));
harmony.PatchAll(typeof(HoarderBugAI));
}
[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>();
mls.LogInfo((object)"Collided with player");
if (component.isHoldingPlayer)
{
return;
}
int num = random.Next(0, 100);
if (num <= bugGrabOdds && !((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;
}
}
mls.LogInfo((object)("Rolled " + num + " which needs to be under " + bugGrabOdds + " to be picked up"));
}
[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;
Traverse.Create((object)__instance).Field("timeSinceHittingPlayer").SetValue((object)(-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
{
}
}