Decompiled source of InterventionHunter v1.0.0

BepInEx/plugins/CouchSalesman.InterventionHunter/InterventionHunter.dll

Decompiled a week 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.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
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(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp-firstpass")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: IgnoresAccessChecksTo("Autodesk.Fbx")]
[assembly: IgnoresAccessChecksTo("Facepunch.Steamworks.Win64")]
[assembly: IgnoresAccessChecksTo("FbxBuildTestAssets")]
[assembly: IgnoresAccessChecksTo("Klattersynth")]
[assembly: IgnoresAccessChecksTo("Photon3Unity3D")]
[assembly: IgnoresAccessChecksTo("PhotonChat")]
[assembly: IgnoresAccessChecksTo("PhotonRealtime")]
[assembly: IgnoresAccessChecksTo("PhotonUnityNetworking")]
[assembly: IgnoresAccessChecksTo("PhotonUnityNetworking.Utilities")]
[assembly: IgnoresAccessChecksTo("PhotonVoice.API")]
[assembly: IgnoresAccessChecksTo("PhotonVoice")]
[assembly: IgnoresAccessChecksTo("PhotonVoice.PUN")]
[assembly: IgnoresAccessChecksTo("SingularityGroup.HotReload.Runtime")]
[assembly: IgnoresAccessChecksTo("SingularityGroup.HotReload.Runtime.Public")]
[assembly: IgnoresAccessChecksTo("Sirenix.OdinInspector.Attributes")]
[assembly: IgnoresAccessChecksTo("Sirenix.Serialization.Config")]
[assembly: IgnoresAccessChecksTo("Sirenix.Serialization")]
[assembly: IgnoresAccessChecksTo("Sirenix.Utilities")]
[assembly: IgnoresAccessChecksTo("Unity.AI.Navigation")]
[assembly: IgnoresAccessChecksTo("Unity.Formats.Fbx.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem.ForUI")]
[assembly: IgnoresAccessChecksTo("Unity.Postprocessing.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.ShaderLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.ShaderGraph.ShaderGraphLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.TextMeshPro")]
[assembly: IgnoresAccessChecksTo("Unity.Timeline")]
[assembly: IgnoresAccessChecksTo("Unity.VisualScripting.Antlr3.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.VisualScripting.Core")]
[assembly: IgnoresAccessChecksTo("Unity.VisualScripting.Flow")]
[assembly: IgnoresAccessChecksTo("Unity.VisualScripting.State")]
[assembly: IgnoresAccessChecksTo("UnityEngine.ARModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.NVIDIAModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UI")]
[assembly: IgnoresAccessChecksTo("websocket-sharp")]
[assembly: AssemblyCompany("CouchSalesman")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("InterventionHunter")]
[assembly: AssemblyTitle("InterventionHunter")]
[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.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[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 InterventionHunter
{
	[BepInPlugin("CouchSalesman.InterventionHunter", "InterventionHunter", "1.0")]
	public class InterventionHunter : BaseUnityPlugin
	{
		private const string modUID = "CouchSalesman.InterventionHunter";

		private const string modName = "InterventionHunter";

		private const string modVersion = "1.0.0";

		private readonly Harmony harmony = new Harmony("CouchSalesman.InterventionHunter");

		internal static InterventionHunter instance;

		internal ManualLogSource logger;

		internal static AudioClip[] SoundGunShortNew;

		internal static AudioClip[] hitmarker;

		internal static GameObject InterventionModel;

		private void Awake()
		{
			logger = Logger.CreateLogSource("InterventionHunter");
			logger.LogInfo((object)"Loading InterventionHunter mod...");
			if ((Object)(object)instance == (Object)null)
			{
				instance = this;
			}
			else
			{
				Object.Destroy((Object)(object)this);
			}
			harmony.PatchAll();
			string location = ((BaseUnityPlugin)instance).Info.Location;
			location = location.TrimEnd("InterventionHunter.dll".ToCharArray());
			AssetBundle val = AssetBundle.LoadFromFile(location + "interventionbundle");
			if ((Object)(object)val == (Object)null)
			{
				logger.LogError((object)"Failed to load asset bundle!");
				return;
			}
			SoundGunShortNew = (AudioClip[])(object)new AudioClip[1] { val.LoadAsset<AudioClip>("interventionSound") };
			hitmarker = (AudioClip[])(object)new AudioClip[1] { val.LoadAsset<AudioClip>("hitmarkerSound") };
			InterventionModel = val.LoadAsset<GameObject>("Intervention");
			logger.LogInfo((object)"Successfully loaded assets and started Intervention Hunter mod!");
		}
	}
}
namespace InterventionHunter.Patches
{
	[HarmonyPatch(typeof(EnemyHunter))]
	internal class EnemyHunterPatch
	{
		[HarmonyPatch("Awake")]
		[HarmonyPostfix]
		private static void ReplaceAssets(EnemyHunter __instance, ref EnemyHunterAnim ___enemyHunterAnim)
		{
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: 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_011a: 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)
			InterventionHunter.instance.logger.LogInfo((object)"Attempting to replace assets for EnemyHunter...");
			if ((Object)(object)InterventionHunter.InterventionModel == (Object)null)
			{
				InterventionHunter.instance.logger.LogError((object)"Failed to load visuals for EnemyHunter! Aborting asset replacement...");
				return;
			}
			Transform child = ((Component)__instance).transform.parent.GetChild(2).GetChild(0).GetChild(0)
				.GetChild(0)
				.GetChild(1)
				.GetChild(0)
				.GetChild(0)
				.GetChild(0)
				.GetChild(0)
				.GetChild(0)
				.GetChild(0)
				.GetChild(0)
				.GetChild(1)
				.GetChild(0)
				.GetChild(1)
				.GetChild(0)
				.GetChild(3)
				.GetChild(0);
			InterventionHunter.instance.logger.LogInfo((object)("Target object: " + ((Object)child).name));
			GameObject val = Object.Instantiate<GameObject>(InterventionHunter.InterventionModel, child);
			Transform transform = val.transform;
			transform.localPosition += new Vector3(0.1f, 0f, -0.7f);
			Transform transform2 = val.transform;
			transform2.localScale *= 0.75f;
			Renderer[] componentsInChildren = ((Component)child).gameObject.GetComponentsInChildren<Renderer>();
			componentsInChildren[0].enabled = false;
			__instance.soundShoot.Sounds = InterventionHunter.SoundGunShortNew;
			__instance.soundShootGlobal.Sounds = InterventionHunter.SoundGunShortNew;
			__instance.soundHit.Sounds = InterventionHunter.hitmarker;
			InterventionHunter.instance.logger.LogInfo((object)"Replaced assets for EnemyHunter");
		}

		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void Update(EnemyHunter __instance, ref EnemyHunterAnim ___enemyHunterAnim)
		{
		}
	}
}