Decompiled source of TrapDisabler v1.0.0

plugins/TrapDisabler/TrapDisabler.dll

Decompiled 8 months ago
using System;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using Fusion;
using Microsoft.CodeAnalysis;
using On;
using TrapDisabler.Patch;
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(".NETFramework,Version=v4.6.2", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("TrapDisabler")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+c09d0a58c32f0e0db3f50865ce02fc5a3bb6f135")]
[assembly: AssemblyProduct("TrapDisabler")]
[assembly: AssemblyTitle("TrapDisabler")]
[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 TrapDisabler
{
	internal static class Log
	{
		private static ManualLogSource _logSource;

		internal static void Init(ManualLogSource logSource)
		{
			_logSource = logSource;
		}

		internal static void Debug(object data)
		{
			_logSource.LogDebug(data);
		}

		internal static void Error(object data)
		{
			_logSource.LogError(data);
		}

		internal static void Fatal(object data)
		{
			_logSource.LogFatal(data);
		}

		internal static void Info(object data)
		{
			_logSource.LogInfo(data);
		}

		internal static void Message(object data)
		{
			_logSource.LogMessage(data);
		}

		internal static void Warning(object data)
		{
			_logSource.LogWarning(data);
		}
	}
	[BepInPlugin("LloydHawkeye.TrapDisabler", "TrapDisabler", "1.0.0")]
	[BepInProcess("Lycans.exe")]
	public class TrapDisabler : BaseUnityPlugin
	{
		public const string PLUGIN_GUID = "LloydHawkeye.TrapDisabler";

		public const string PLUGIN_AUTHOR = "LloydHawkeye";

		public const string PLUGIN_NAME = "TrapDisabler";

		public const string PLUGIN_VERSION = "1.0.0";

		private void Awake()
		{
			Log.Init(((BaseUnityPlugin)this).Logger);
			GameManagerPatch.Patch();
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "TrapDisabler";

		public const string PLUGIN_NAME = "TrapDisabler";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace TrapDisabler.Patch
{
	internal class GameManagerPatch
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static hook_SpawnRandomItems <0>__GameManager_SpawnRandomItems;
		}

		public static void Patch()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			object obj = <>O.<0>__GameManager_SpawnRandomItems;
			if (obj == null)
			{
				hook_SpawnRandomItems val = GameManager_SpawnRandomItems;
				<>O.<0>__GameManager_SpawnRandomItems = val;
				obj = (object)val;
			}
			GameManager.SpawnRandomItems += (hook_SpawnRandomItems)obj;
		}

		private static void GameManager_SpawnRandomItems(orig_SpawnRandomItems orig, GameManager self)
		{
			//IL_0084: 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_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			if (GameManager.Instance.HuntersCount > 0)
			{
				for (int i = 0; i < self.ItemsSpawnRate * 3; i++)
				{
					Transform andLockRandomItemSpawn = self.GetAndLockRandomItemSpawn();
					if ((Object)(object)andLockRandomItemSpawn != (Object)null)
					{
						((SimulationBehaviour)self).Runner.Spawn<BulletItem>(self.bulletPrefab, (Vector3?)andLockRandomItemSpawn.position, (Quaternion?)andLockRandomItemSpawn.rotation, (PlayerRef?)null, (OnBeforeSpawned)null, (NetworkObjectPredictionKey?)null, true);
					}
				}
			}
			if (!NetworkBool.op_Implicit(self.BattleRoyale))
			{
				return;
			}
			int num = PlayerRegistry.Where((Predicate<PlayerController>)((PlayerController p) => !NetworkBool.op_Implicit(p.IsDead))).Count();
			for (int j = 0; j < num * 10; j++)
			{
				Transform andLockRandomItemSpawn2 = self.GetAndLockRandomItemSpawn();
				if ((Object)(object)andLockRandomItemSpawn2 != (Object)null)
				{
					((SimulationBehaviour)self).Runner.Spawn<BulletItem>(self.bulletPrefab, (Vector3?)andLockRandomItemSpawn2.position, (Quaternion?)andLockRandomItemSpawn2.rotation, (PlayerRef?)null, (OnBeforeSpawned)null, (NetworkObjectPredictionKey?)null, true);
				}
			}
		}
	}
}