Decompiled source of CoilheadStareCementNoiseRedux v1.1.1

CoilheadStareUASoundRedux.dll

Decompiled a month ago
using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using LCSoundTool;
using Microsoft.CodeAnalysis;
using TDP.CoilHeadStare.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(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("CoilheadStareUASoundRedux")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("A template for Lethal Company")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+62d1b1ea45c1ba9ac3e7d26a450ccb981c25a03d")]
[assembly: AssemblyProduct("CoilheadStareUASoundRedux")]
[assembly: AssemblyTitle("CoilheadStareUASoundRedux")]
[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 CoilheadStareUASoundRedux
{
	[BepInPlugin("CoilheadStareUASoundRedux", "CoilheadStareUASoundRedux", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		private readonly Harmony _harmony = new Harmony("CoilheadStareUASoundRedux");

		public AudioClip audioClip;

		public static Plugin Instance { get; set; }

		public static ManualLogSource Log => ((BaseUnityPlugin)Instance).Logger;

		public Plugin()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected O, but got Unknown
			Instance = this;
		}

		private void Awake()
		{
			audioClip = SoundTool.GetAudioClip(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "zelensky.wav");
			Log.LogInfo((object)"Applying patches...");
			ApplyPluginPatch();
			Log.LogInfo((object)"Patches applied");
		}

		private void ApplyPluginPatch()
		{
			_harmony.PatchAll(typeof(CoilHeadStarePatch));
		}
	}
	[HarmonyPatch(typeof(Stare))]
	public class CoilHeadStarePatch
	{
		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void UpdatePlaySound(PlayerControllerB ___stareTarget, bool ___isTurningHead, SpringManAI ___coilHeadInstance)
		{
			if (___isTurningHead && (Object)(object)___stareTarget != (Object)null && (Object)(object)___coilHeadInstance != (Object)null && !((EnemyAI)___coilHeadInstance).creatureVoice.isPlaying)
			{
				((EnemyAI)___coilHeadInstance).creatureVoice.clip = Plugin.Instance.audioClip;
				((EnemyAI)___coilHeadInstance).creatureVoice.Play();
			}
			else if (!___isTurningHead && (Object)(object)___coilHeadInstance != (Object)null && ((EnemyAI)___coilHeadInstance).creatureVoice.isPlaying)
			{
				((EnemyAI)___coilHeadInstance).creatureVoice.Stop();
			}
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "CoilheadStareUASoundRedux";

		public const string PLUGIN_NAME = "CoilheadStareUASoundRedux";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}