Decompiled source of CatLaser v1.1.1

CatLaser.dll

Decompiled 7 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.Bootstrap;
using CatLaser.Patches;
using GameNetcodeStuff;
using HarmonyLib;
using LethalThings;
using Microsoft.CodeAnalysis;
using NeedyCats;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.AI;

[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("CatLaser")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("A template for Lethal Company")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+dcc909f3d62d78bb32e1f6e22cb8f604a0803220")]
[assembly: AssemblyProduct("CatLaser")]
[assembly: AssemblyTitle("CatLaser")]
[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.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace CatLaser
{
	public static class LethalThingsCompatibility
	{
		private static bool? _enabled;

		public static bool enabled
		{
			get
			{
				if (!_enabled.HasValue)
				{
					_enabled = Chainloader.PluginInfos.ContainsKey("evaisa.lethalthings");
				}
				return _enabled.Value;
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static bool IsLauncher(GrabbableObject laserSource)
		{
			return laserSource is RocketLauncher;
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static bool IsLauncherActive(GrabbableObject laserSource)
		{
			RocketLauncher val = (RocketLauncher)(object)((laserSource is RocketLauncher) ? laserSource : null);
			return val != null && !((Behaviour)val.laserPointer).enabled;
		}
	}
	[BepInPlugin("CatLaser", "CatLaser", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		private readonly Harmony harmony = new Harmony("CatLaser");

		private void Awake()
		{
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin CatLaser is loaded!");
			harmony.PatchAll(typeof(PlayerControllerBPatch));
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "CatLaser";

		public const string PLUGIN_NAME = "CatLaser";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace CatLaser.Patches
{
	[HarmonyPatch(typeof(PlayerControllerB))]
	public class PlayerControllerBPatch
	{
		private const float maxDistance = 10f;

		[HarmonyPatch(typeof(PlayerControllerB), "Update")]
		[HarmonyPrefix]
		private static void PatchUpdate(PlayerControllerB __instance)
		{
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
			if (!NetworkManager.Singleton.IsServer || (Object)(object)__instance == (Object)null)
			{
				return;
			}
			GrabbableObject currentlyHeldObjectServer = __instance.currentlyHeldObjectServer;
			if ((Object)(object)currentlyHeldObjectServer == (Object)null)
			{
				return;
			}
			bool flag = LethalThingsCompatibility.enabled && LethalThingsCompatibility.IsLauncher(currentlyHeldObjectServer);
			if (!(currentlyHeldObjectServer is FlashlightItem || flag))
			{
				return;
			}
			FlashlightItem val = (FlashlightItem)(object)((currentlyHeldObjectServer is FlashlightItem) ? currentlyHeldObjectServer : null);
			if ((val != null && (val.flashlightTypeID != 2 || !((GrabbableObject)val).isBeingUsed)) || (flag && LethalThingsCompatibility.IsLauncherActive(currentlyHeldObjectServer)))
			{
				return;
			}
			Vector3 position = ((Component)__instance.gameplayCamera).transform.position;
			Vector3 forward = ((Component)__instance.gameplayCamera).transform.forward;
			RaycastHit val2 = default(RaycastHit);
			if (!Physics.Raycast(position, forward, ref val2, float.PositiveInfinity, 605030721))
			{
				return;
			}
			NeedyCatProp[] array = Object.FindObjectsByType<NeedyCatProp>((FindObjectsInactive)0, (FindObjectsSortMode)0);
			NeedyCatProp[] array2 = array;
			foreach (NeedyCatProp val3 in array2)
			{
				if (!(Vector3.Distance(((Component)val3).transform.position, ((RaycastHit)(ref val2)).point) >= 10f))
				{
					object? obj = typeof(NeedyCatProp).GetField("agent", BindingFlags.Instance | BindingFlags.NonPublic)?.GetValue(val3);
					NavMeshAgent val4 = (NavMeshAgent)((obj is NavMeshAgent) ? obj : null);
					if ((Object)(object)val4 != (Object)null)
					{
						val4.speed = val3.RunningSpeed;
					}
					typeof(NeedyCatProp).GetField("timeBeforeNextMove", BindingFlags.Instance | BindingFlags.NonPublic)?.SetValue(val3, val3.IntervalMove.y);
					val3.SetDestinationToPosition(((RaycastHit)(ref val2)).point, false);
				}
			}
		}
	}
}