Decompiled source of SR John Equilibrium v1.0.1

Packer.JohnEquilibrium.dll

Decompiled 4 months ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Logging;
using FistVR;
using Microsoft.CodeAnalysis;
using SupplyRaid;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyCompany("Packer")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Supply Raid John Equilibrium")]
[assembly: AssemblyFileVersion("1.0.1.0")]
[assembly: AssemblyInformationalVersion("1.0.1+6ec683ab568e60e0ffa73f6a03e3551a65c9cbb1")]
[assembly: AssemblyProduct("Packer.JohnEquilibrium")]
[assembly: AssemblyTitle("JohnEquilibrium")]
[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 BepInEx
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	[Conditional("CodeGeneration")]
	internal sealed class BepInAutoPluginAttribute : Attribute
	{
		public BepInAutoPluginAttribute(string id = null, string name = null, string version = null)
		{
		}
	}
}
namespace BepInEx.Preloader.Core.Patching
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	[Conditional("CodeGeneration")]
	internal sealed class PatcherAutoPluginAttribute : Attribute
	{
		public PatcherAutoPluginAttribute(string id = null, string name = null, string version = null)
		{
		}
	}
}
namespace Packer
{
	[BepInPlugin("Packer.JohnEquilibrium", "JohnEquilibrium", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class JohnEquilibriumPlugin : BaseUnityPlugin
	{
		public static bool H3MP;

		public static bool supplyRaid;

		public static bool TakeAndHold;

		public static bool Survival;

		public static SR_Manager SRManager;

		public bool foundCharacter = false;

		private FVRObject ammoObject;

		private Vector3 rotationOffset = new Vector3(90f, 90f, 90f);

		private float timeOut = 0f;

		private FVRFireArmMagazine leftAmmo;

		private FVRFireArmMagazine rightAmmo;

		private Rigidbody leftRB;

		private Rigidbody rightRB;

		private float cooldownLeft = 0f;

		private float cooldownRight = 0f;

		internal static ManualLogSource Logger { get; private set; }

		private void Awake()
		{
			Logger = ((BaseUnityPlugin)this).Logger;
			H3MP = Chainloader.PluginInfos.ContainsKey("VIP.TommySoucy.H3MP");
			supplyRaid = Chainloader.PluginInfos.ContainsKey("com.Packer.SupplyRaid");
		}

		private void FixedUpdate()
		{
			if (timeOut > Time.time)
			{
				return;
			}
			if (foundCharacter && SRManager.gameRunning)
			{
				AmmoUpdate();
				return;
			}
			if ((Object)(object)SRManager == (Object)null || !SRManager.gameRunning)
			{
				foundCharacter = false;
			}
			if ((Object)(object)SRManager == (Object)null && (Object)(object)SR_Manager.instance != (Object)null)
			{
				SRManager = SR_Manager.instance;
			}
			else
			{
				timeOut = Time.time + (float)Random.Range(5, 8);
			}
			if (Object.op_Implicit((Object)(object)SRManager) && SRManager.character != null && SRManager.gameRunning && SRManager.character.name == "John Equilibrium")
			{
				foundCharacter = true;
			}
		}

		private void AmmoUpdate()
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: Unknown result type (might be due to invalid IL or missing references)
			//IL_0171: Unknown result type (might be due to invalid IL or missing references)
			//IL_0182: Unknown result type (might be due to invalid IL or missing references)
			//IL_026d: Unknown result type (might be due to invalid IL or missing references)
			//IL_027c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0286: Unknown result type (might be due to invalid IL or missing references)
			//IL_028b: Unknown result type (might be due to invalid IL or missing references)
			//IL_029a: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0303: Unknown result type (might be due to invalid IL or missing references)
			//IL_0314: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)leftAmmo == (Object)null && cooldownLeft <= Time.time)
			{
				leftAmmo = SpawnAmmo(GM.CurrentPlayerBody.LeftHand.position).GetComponent<FVRFireArmMagazine>();
				leftRB = ((Component)leftAmmo).GetComponent<Rigidbody>();
			}
			else if (Object.op_Implicit((Object)(object)leftAmmo) && cooldownLeft <= Time.time)
			{
				if (((FVRInteractiveObject)leftAmmo).IsHeld || (Object)(object)leftAmmo.FireArm != (Object)null)
				{
					leftAmmo = null;
					cooldownLeft = Time.time + 5f;
				}
				else
				{
					leftRB.MovePosition(GM.CurrentPlayerBody.LeftHand.position - GM.CurrentPlayerBody.LeftHand.forward * 0.15f + GM.CurrentPlayerBody.LeftHand.right * 0.15f + GM.CurrentPlayerBody.LeftHand.up * 0.01f);
					leftRB.MoveRotation(GM.CurrentPlayerBody.LeftHand.rotation * Quaternion.Euler(rotationOffset));
					leftRB.velocity = Vector3.zero;
					leftRB.angularVelocity = Vector3.zero;
				}
			}
			if ((Object)(object)rightAmmo == (Object)null && cooldownRight <= Time.time)
			{
				rightAmmo = SpawnAmmo(GM.CurrentPlayerBody.RightHand.position).GetComponent<FVRFireArmMagazine>();
				rightRB = ((Component)rightAmmo).GetComponent<Rigidbody>();
			}
			else if (Object.op_Implicit((Object)(object)rightAmmo) && cooldownRight <= Time.time)
			{
				if (((FVRInteractiveObject)rightAmmo).IsHeld || (Object)(object)rightAmmo.FireArm != (Object)null)
				{
					rightAmmo = null;
					cooldownRight = Time.time + 5f;
					return;
				}
				rightRB.MovePosition(GM.CurrentPlayerBody.RightHand.position - GM.CurrentPlayerBody.RightHand.forward * 0.15f - GM.CurrentPlayerBody.RightHand.right * 0.15f + GM.CurrentPlayerBody.RightHand.up * 0.01f);
				rightRB.MoveRotation(GM.CurrentPlayerBody.RightHand.rotation * Quaternion.Euler(rotationOffset));
				rightRB.velocity = Vector3.zero;
				rightRB.angularVelocity = Vector3.zero;
			}
		}

		private GameObject SpawnAmmo(Vector3 position)
		{
			//IL_0031: 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_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)ammoObject == (Object)null)
			{
				ammoObject = IM.OD["MagazineCX4"];
			}
			return Object.Instantiate<GameObject>(((AnvilAsset)ammoObject).GetGameObject(), position + -Vector3.up * 0.25f, Quaternion.identity);
		}
	}
}