Decompiled source of Spectator V2 v1.0.0

Spectatorv2.dll

Decompiled a month ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using HarmonyLib;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.AddressableAssets;
using UnityEngine.Events;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("ThundergunRevised")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ThundergunRevised")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("5711e2a0-d5a7-4ddf-b8d4-00f355fe9397")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: NeutralResourcesLanguage("en-FI")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace spectatorv2;

[BepInPlugin("vqevs.spectatorv2", "spectatorv2", "1.0.0")]
public class MainCode : BaseUnityPlugin
{
	public class KillTracker
	{
		public static void Postfix(EnemyIdentifier __instance)
		{
			if ((Object)(object)v2Instance != (Object)null && (Object)(object)((Component)__instance).gameObject == (Object)(object)v2Instance)
			{
				__instance.health = 999999f;
			}
		}
	}

	public static GameObject v2Instance;

	private static MainCode instance;

	private bool firstSpawnDone;

	private Vector3 delayedSpawnPos;

	private float posTrackTimer;

	private string lastScene = "";

	private static readonly string[] blacklistedScenes = new string[2] { "Level 1-4", "Level 4-4" };

	public void Start()
	{
		//IL_000d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0013: Expected O, but got Unknown
		//IL_004a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0057: Expected O, but got Unknown
		instance = this;
		try
		{
			Harmony val = new Harmony("vqevs.spectatorv2");
			MethodInfo methodInfo = AccessTools.Method(typeof(EnemyIdentifier), "Death", new Type[0], (Type[])null);
			MethodInfo methodInfo2 = AccessTools.Method(typeof(KillTracker), "Postfix", (Type[])null, (Type[])null);
			val.Patch((MethodBase)methodInfo, (HarmonyMethod)null, new HarmonyMethod(methodInfo2), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		}
		catch (Exception ex)
		{
			Debug.LogError((object)("Harmony Patch failed: " + ex.Message));
		}
	}

	public void Update()
	{
		//IL_002f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0034: Unknown result type (might be due to invalid IL or missing references)
		//IL_016f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0174: Unknown result type (might be due to invalid IL or missing references)
		//IL_0193: Unknown result type (might be due to invalid IL or missing references)
		//IL_0198: Unknown result type (might be due to invalid IL or missing references)
		//IL_0224: Unknown result type (might be due to invalid IL or missing references)
		//IL_0233: Unknown result type (might be due to invalid IL or missing references)
		//IL_023d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0242: Unknown result type (might be due to invalid IL or missing references)
		//IL_0247: Unknown result type (might be due to invalid IL or missing references)
		//IL_0253: Unknown result type (might be due to invalid IL or missing references)
		//IL_0262: Unknown result type (might be due to invalid IL or missing references)
		//IL_027f: Unknown result type (might be due to invalid IL or missing references)
		if (SceneHelper.CurrentScene != lastScene)
		{
			lastScene = SceneHelper.CurrentScene;
			firstSpawnDone = false;
			v2Instance = null;
			delayedSpawnPos = Vector3.zero;
			posTrackTimer = 0f;
			Debug.Log((object)("[SV2] Entered new scene: " + SceneHelper.CurrentScene));
		}
		if (SceneHelper.CurrentScene == "Main Menu" || (Object)(object)MonoSingleton<NewMovement>.Instance == (Object)null)
		{
			return;
		}
		bool flag = false;
		string[] array = blacklistedScenes;
		foreach (string value in array)
		{
			if (SceneHelper.CurrentScene != null && SceneHelper.CurrentScene.Contains(value))
			{
				flag = true;
				break;
			}
		}
		if (flag)
		{
			if (!firstSpawnDone)
			{
				posTrackTimer += Time.deltaTime;
				if (posTrackTimer >= 3f && (Object)(object)MonoSingleton<HudMessageReceiver>.Instance != (Object)null)
				{
					SendMsg("V2 IS WAITING FOR YOU");
					firstSpawnDone = true;
					posTrackTimer = 0f;
				}
			}
			return;
		}
		posTrackTimer += Time.deltaTime;
		if (posTrackTimer >= 3f)
		{
			delayedSpawnPos = ((Component)MonoSingleton<NewMovement>.Instance).transform.position;
			posTrackTimer = 0f;
		}
		if ((Object)(object)v2Instance == (Object)null && delayedSpawnPos != Vector3.zero)
		{
			SpawnV2();
		}
		if (!((Object)(object)v2Instance != (Object)null))
		{
			return;
		}
		if (Input.GetKeyDown((KeyCode)45) || Input.GetKeyDown((KeyCode)269))
		{
			ManualRecall();
		}
		NavMeshAgent component = v2Instance.GetComponent<NavMeshAgent>();
		if ((Object)(object)component != (Object)null && ((Behaviour)component).enabled && component.isOnNavMesh)
		{
			Vector3 destination = ((Component)MonoSingleton<NewMovement>.Instance).transform.position - ((Component)MonoSingleton<NewMovement>.Instance).transform.forward * 2f;
			float num = Vector3.Distance(v2Instance.transform.position, ((Component)MonoSingleton<NewMovement>.Instance).transform.position);
			if (num > 4f)
			{
				component.SetDestination(destination);
			}
			else
			{
				component.ResetPath();
			}
		}
	}

	private void SpawnV2()
	{
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_0008: Unknown result type (might be due to invalid IL or missing references)
		//IL_0009: Unknown result type (might be due to invalid IL or missing references)
		//IL_0013: Unknown result type (might be due to invalid IL or missing references)
		//IL_0018: Unknown result type (might be due to invalid IL or missing references)
		//IL_001d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0053: Unknown result type (might be due to invalid IL or missing references)
		//IL_0058: Unknown result type (might be due to invalid IL or missing references)
		//IL_0061: Unknown result type (might be due to invalid IL or missing references)
		//IL_0062: Unknown result type (might be due to invalid IL or missing references)
		//IL_0034: 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_0043: Unknown result type (might be due to invalid IL or missing references)
		//IL_0048: Unknown result type (might be due to invalid IL or missing references)
		//IL_004d: Unknown result type (might be due to invalid IL or missing references)
		//IL_009d: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a7: Expected O, but got Unknown
		Vector3 val = delayedSpawnPos;
		RaycastHit val2 = default(RaycastHit);
		if (Physics.Raycast(val + Vector3.up * 5f, Vector3.down, ref val2, 20f))
		{
			val = ((RaycastHit)(ref val2)).point + Vector3.up * 0.1f;
		}
		v2Instance = Object.Instantiate<GameObject>(Addressables.LoadAssetAsync<GameObject>((object)"Assets/Prefabs/Enemies/V2.prefab").WaitForCompletion(), val, Quaternion.identity);
		EnemyIdentifier component;
		if ((Object)(object)(component = v2Instance.GetComponent<EnemyIdentifier>()) != (Object)null)
		{
			component.ignorePlayer = false;
			component.health = 999999f;
			component.onDeath = new UnityEvent();
		}
		Transform[] componentsInChildren = v2Instance.GetComponentsInChildren<Transform>(true);
		foreach (Transform val3 in componentsInChildren)
		{
			string text = ((Object)val3).name.ToLower();
			if (text.Contains("gun") || text.Contains("weapon") || text.Contains("pistol") || text.Contains("shotgun") || text.Contains("rocket") || text.Contains("nailgun") || text.Contains("railgun") || text.Contains("revolver"))
			{
				((Component)val3).gameObject.SetActive(false);
			}
		}
		v2Instance.SetActive(true);
		firstSpawnDone = true;
	}

	private void ManualRecall()
	{
		//IL_001f: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: 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_003d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0042: Unknown result type (might be due to invalid IL or missing references)
		//IL_0043: Unknown result type (might be due to invalid IL or missing references)
		//IL_0044: 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_0053: Unknown result type (might be due to invalid IL or missing references)
		//IL_0058: Unknown result type (might be due to invalid IL or missing references)
		//IL_0095: Unknown result type (might be due to invalid IL or missing references)
		//IL_0071: Unknown result type (might be due to invalid IL or missing references)
		//IL_0076: Unknown result type (might be due to invalid IL or missing references)
		//IL_0080: Unknown result type (might be due to invalid IL or missing references)
		//IL_0085: Unknown result type (might be due to invalid IL or missing references)
		//IL_008a: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
		if (!((Object)(object)v2Instance == (Object)null))
		{
			Vector3 val = ((Component)MonoSingleton<NewMovement>.Instance).transform.position + ((Component)MonoSingleton<NewMovement>.Instance).transform.forward * 3f;
			RaycastHit val2 = default(RaycastHit);
			if (Physics.Raycast(val + Vector3.up * 5f, Vector3.down, ref val2, 20f))
			{
				val = ((RaycastHit)(ref val2)).point + Vector3.up * 0.1f;
			}
			v2Instance.transform.position = val;
			NavMeshAgent component = v2Instance.GetComponent<NavMeshAgent>();
			if ((Object)(object)component != (Object)null && ((Behaviour)component).enabled)
			{
				component.Warp(val);
			}
			SendMsg("You are not getting away this time.");
		}
	}

	public static void SendMsg(string content)
	{
		if ((Object)(object)MonoSingleton<HudMessageReceiver>.Instance != (Object)null)
		{
			string text = "<color=#FF0000>" + content + "</color>";
			MonoSingleton<HudMessageReceiver>.Instance.SendHudMessage(text, "", "", 0, true, false, true);
		}
	}
}
public class Spectatorsigma : MonoBehaviour
{
	public Follow follow;

	public NewMovement player;

	public AlwaysLookAtCamera ALAC;

	public bool dead;

	public V2 mindflayYergh;

	private void Start()
	{
		follow = ((Component)this).gameObject.GetComponent<Follow>();
		mindflayYergh = ((Component)this).gameObject.GetComponent<V2>();
		ALAC = ((Component)this).gameObject.GetComponent<AlwaysLookAtCamera>();
		player = MonoSingleton<NewMovement>.Instance;
	}

	private void Update()
	{
	}
}
public class StaticCoroutine : MonoBehaviour
{
	[CompilerGenerated]
	private sealed class <Execute>d__1 : IEnumerator<object>, IDisposable, IEnumerator
	{
		private int <>1__state;

		private object <>2__current;

		public Action action;

		public float delay;

		public GameObject runner;

		object IEnumerator<object>.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		object IEnumerator.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		[DebuggerHidden]
		public <Execute>d__1(int <>1__state)
		{
			this.<>1__state = <>1__state;
		}

		[DebuggerHidden]
		void IDisposable.Dispose()
		{
			<>1__state = -2;
		}

		private bool MoveNext()
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Expected O, but got Unknown
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				<>2__current = (object)new WaitForSeconds(delay);
				<>1__state = 1;
				return true;
			case 1:
				<>1__state = -1;
				action();
				Object.Destroy((Object)(object)runner);
				return false;
			}
		}

		bool IEnumerator.MoveNext()
		{
			//ILSpy generated this explicit interface implementation from .override directive in MoveNext
			return this.MoveNext();
		}

		[DebuggerHidden]
		void IEnumerator.Reset()
		{
			throw new NotSupportedException();
		}
	}

	public static void DoAfter(Action action, float delay)
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: Expected O, but got Unknown
		GameObject val = new GameObject("DelayRunner");
		((MonoBehaviour)val.AddComponent<StaticCoroutine>()).StartCoroutine(Execute(action, delay, val));
	}

	[IteratorStateMachine(typeof(<Execute>d__1))]
	private static IEnumerator Execute(Action action, float delay, GameObject runner)
	{
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <Execute>d__1(0)
		{
			action = action,
			delay = delay,
			runner = runner
		};
	}
}
public class StaticCoroutine__0 : MonoBehaviour
{
	[CompilerGenerated]
	private sealed class <Execute>d__1 : IEnumerator<object>, IDisposable, IEnumerator
	{
		private int <>1__state;

		private object <>2__current;

		public Action action;

		public float delay;

		public GameObject runner;

		object IEnumerator<object>.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		object IEnumerator.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		[DebuggerHidden]
		public <Execute>d__1(int <>1__state)
		{
			this.<>1__state = <>1__state;
		}

		[DebuggerHidden]
		void IDisposable.Dispose()
		{
			<>1__state = -2;
		}

		private bool MoveNext()
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Expected O, but got Unknown
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				<>2__current = (object)new WaitForSeconds(delay);
				<>1__state = 1;
				return true;
			case 1:
				<>1__state = -1;
				action();
				Object.Destroy((Object)(object)runner);
				return false;
			}
		}

		bool IEnumerator.MoveNext()
		{
			//ILSpy generated this explicit interface implementation from .override directive in MoveNext
			return this.MoveNext();
		}

		[DebuggerHidden]
		void IEnumerator.Reset()
		{
			throw new NotSupportedException();
		}
	}

	public static void DoAfter(Action action, float delay)
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: Expected O, but got Unknown
		GameObject val = new GameObject("DelayRunner");
		((MonoBehaviour)val.AddComponent<StaticCoroutine__0>()).StartCoroutine(Execute(action, delay, val));
	}

	[IteratorStateMachine(typeof(<Execute>d__1))]
	private static IEnumerator Execute(Action action, float delay, GameObject runner)
	{
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <Execute>d__1(0)
		{
			action = action,
			delay = delay,
			runner = runner
		};
	}
}
public class StaticCoroutine__1 : MonoBehaviour
{
	[CompilerGenerated]
	private sealed class <Execute>d__1 : IEnumerator<object>, IDisposable, IEnumerator
	{
		private int <>1__state;

		private object <>2__current;

		public Action action;

		public float delay;

		public GameObject runner;

		object IEnumerator<object>.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		object IEnumerator.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		[DebuggerHidden]
		public <Execute>d__1(int <>1__state)
		{
			this.<>1__state = <>1__state;
		}

		[DebuggerHidden]
		void IDisposable.Dispose()
		{
			<>1__state = -2;
		}

		private bool MoveNext()
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Expected O, but got Unknown
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				<>2__current = (object)new WaitForSeconds(delay);
				<>1__state = 1;
				return true;
			case 1:
				<>1__state = -1;
				action();
				Object.Destroy((Object)(object)runner);
				return false;
			}
		}

		bool IEnumerator.MoveNext()
		{
			//ILSpy generated this explicit interface implementation from .override directive in MoveNext
			return this.MoveNext();
		}

		[DebuggerHidden]
		void IEnumerator.Reset()
		{
			throw new NotSupportedException();
		}
	}

	public static void DoAfter(Action action, float delay)
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: Expected O, but got Unknown
		GameObject val = new GameObject("DelayRunner");
		((MonoBehaviour)val.AddComponent<StaticCoroutine__1>()).StartCoroutine(Execute(action, delay, val));
	}

	[IteratorStateMachine(typeof(<Execute>d__1))]
	private static IEnumerator Execute(Action action, float delay, GameObject runner)
	{
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <Execute>d__1(0)
		{
			action = action,
			delay = delay,
			runner = runner
		};
	}
}
public class StaticCoroutine__2 : MonoBehaviour
{
	[CompilerGenerated]
	private sealed class <Execute>d__1 : IEnumerator<object>, IDisposable, IEnumerator
	{
		private int <>1__state;

		private object <>2__current;

		public Action action;

		public float delay;

		public GameObject runner;

		object IEnumerator<object>.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		object IEnumerator.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		[DebuggerHidden]
		public <Execute>d__1(int <>1__state)
		{
			this.<>1__state = <>1__state;
		}

		[DebuggerHidden]
		void IDisposable.Dispose()
		{
			<>1__state = -2;
		}

		private bool MoveNext()
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Expected O, but got Unknown
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				<>2__current = (object)new WaitForSeconds(delay);
				<>1__state = 1;
				return true;
			case 1:
				<>1__state = -1;
				action();
				Object.Destroy((Object)(object)runner);
				return false;
			}
		}

		bool IEnumerator.MoveNext()
		{
			//ILSpy generated this explicit interface implementation from .override directive in MoveNext
			return this.MoveNext();
		}

		[DebuggerHidden]
		void IEnumerator.Reset()
		{
			throw new NotSupportedException();
		}
	}

	public static void DoAfter(Action action, float delay)
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: Expected O, but got Unknown
		GameObject val = new GameObject("DelayRunner");
		((MonoBehaviour)val.AddComponent<StaticCoroutine__2>()).StartCoroutine(Execute(action, delay, val));
	}

	[IteratorStateMachine(typeof(<Execute>d__1))]
	private static IEnumerator Execute(Action action, float delay, GameObject runner)
	{
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <Execute>d__1(0)
		{
			action = action,
			delay = delay,
			runner = runner
		};
	}
}