Decompiled source of RemoteRemastered v1.0.2

RemoteRemaster.dll

Decompiled a year ago
using System.Collections;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using RemoteRemaster.Patches;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("RemoteRemaster")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("RemoteRemaster")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("2430fe76-5a6d-4896-8561-0e409525ff6f")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace RemoteRemaster
{
	[BepInPlugin("SZAKI.RemoteRemaster", "Remote Remaster", "1.0.1.0")]
	public class RemoteRemasterBase : BaseUnityPlugin
	{
		private const string modGUID = "SZAKI.RemoteRemaster";

		private const string modName = "Remote Remaster";

		private const string modVersion = "1.0.1.0";

		private readonly Harmony harmony = new Harmony("SZAKI.RemoteRemaster");

		private static RemoteRemasterBase Instance;

		public static ManualLogSource mls;

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			mls = Logger.CreateLogSource("SZAKI.RemoteRemaster");
			mls.LogInfo((object)"Successfully awaken!");
			harmony.PatchAll(typeof(RemoteRemasterBase));
			harmony.PatchAll(typeof(RemotePropPatch));
		}
	}
}
namespace RemoteRemaster.Patches
{
	[HarmonyPatch(typeof(RemoteProp))]
	internal class RemotePropPatch
	{
		public class RemotePropPatchMB : MonoBehaviour
		{
		}

		private static RemotePropPatchMB remotePropPatchMB;

		public static bool isTurretFount = true;

		public static bool isLandmineFount = true;

		public static float minDistance = 15f;

		[HarmonyPatch(typeof(RemoteProp), "ItemActivate")]
		[HarmonyPrefix]
		public static bool ItemActivatePatch(ref RemoteProp __instance, ref AudioSource ___remoteAudio, bool used, bool buttonDown = true)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Expected O, but got Unknown
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0172: Unknown result type (might be due to invalid IL or missing references)
			//IL_0178: 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_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0260: Unknown result type (might be due to invalid IL or missing references)
			//IL_0266: Unknown result type (might be due to invalid IL or missing references)
			//IL_0244: Unknown result type (might be due to invalid IL or missing references)
			//IL_024a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0318: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)remotePropPatchMB == (Object)null)
			{
				GameObject val = new GameObject("RemotePropMB");
				remotePropPatchMB = val.AddComponent<RemotePropPatchMB>();
			}
			StartOfRound val2 = Object.FindObjectOfType<StartOfRound>();
			Transform transform = ((Component)val2.localPlayerController).transform;
			AudioSource obj = ___remoteAudio;
			if (obj != null)
			{
				obj.PlayOneShot(___remoteAudio.clip);
			}
			WalkieTalkie.TransmitOneShotAudio(___remoteAudio, ___remoteAudio.clip, 0.7f);
			RoundManager.Instance.PlayAudibleNoise(transform.position, 8f, 0.4f, 0, StartOfRound.Instance.hangarDoorsClosed, 0);
			Turret[] array = Object.FindObjectsOfType<Turret>();
			if (array.Count() == 0)
			{
				ManualLogSource mls = RemoteRemasterBase.mls;
				if (mls != null)
				{
					mls.LogInfo((object)" No Turrent found on this map!");
				}
				isTurretFount = false;
			}
			Landmine[] array2 = Object.FindObjectsOfType<Landmine>();
			if (array2.Count() == 0)
			{
				ManualLogSource mls2 = RemoteRemasterBase.mls;
				if (mls2 != null)
				{
					mls2.LogInfo((object)" No landmines found on this map!");
				}
				isLandmineFount = false;
			}
			if (!isTurretFount && !isLandmineFount)
			{
				return false;
			}
			if (isTurretFount)
			{
				Turret val3 = array[0];
				float num = -1f;
				Turret[] array3 = array;
				foreach (Turret val4 in array3)
				{
					if (num == -1f)
					{
						num = Vector3.Distance(((Component)val4).transform.position, transform.position);
						continue;
					}
					float num2 = Vector3.Distance(((Component)val4).transform.position, transform.position);
					if (num > num2)
					{
						val3 = val4;
						num = num2;
					}
				}
				ManualLogSource mls3 = RemoteRemasterBase.mls;
				if (mls3 != null)
				{
					mls3.LogInfo((object)(" Closest turret is " + num + " away!"));
				}
				if (num <= minDistance && val3.turretActive)
				{
					((MonoBehaviour)remotePropPatchMB).StartCoroutine(TurnOffAndOnTurret(val3, __instance));
				}
			}
			if (isLandmineFount)
			{
				Landmine val5 = array2[0];
				float num3 = -1f;
				Landmine[] array4 = array2;
				foreach (Landmine val6 in array4)
				{
					if (num3 == -1f)
					{
						num3 = Vector3.Distance(((Component)val6).transform.position, transform.position);
						continue;
					}
					float num4 = Vector3.Distance(((Component)val6).transform.position, transform.position);
					if (num3 > num4)
					{
						val5 = val6;
						num3 = num4;
					}
				}
				ManualLogSource mls4 = RemoteRemasterBase.mls;
				if (mls4 != null)
				{
					mls4.LogInfo((object)(" Closest landmine is " + num3 + " away!"));
				}
				if (num3 <= minDistance && ((Behaviour)val5).isActiveAndEnabled)
				{
					AudioSource obj2 = ___remoteAudio;
					if (obj2 != null)
					{
						obj2.PlayOneShot(val5.mineAudio.clip);
					}
					WalkieTalkie.TransmitOneShotAudio(val5.mineAudio, val5.mineAudio.clip, 0.7f);
					RoundManager.Instance.PlayAudibleNoise(transform.position, 8f, 0.4f, 0, StartOfRound.Instance.hangarDoorsClosed, 0);
					((MonoBehaviour)remotePropPatchMB).StartCoroutine(TurnOffAndOnLandmine(val5, __instance));
				}
			}
			return false;
		}

		public static IEnumerator TurnOffAndOnTurret(Turret _turret, RemoteProp _remote)
		{
			((GrabbableObject)_remote).UseItemBatteries();
			_turret.ToggleTurretEnabled(false);
			yield return (object)new WaitForSeconds(5f);
			_turret.ToggleTurretEnabled(true);
		}

		public static IEnumerator TurnOffAndOnLandmine(Landmine _landmine, RemoteProp _remote)
		{
			((GrabbableObject)_remote).UseItemBatteries();
			_landmine.ToggleMine(false);
			yield return (object)new WaitForSeconds(5f);
			_landmine.ToggleMine(true);
		}
	}
}