Decompiled source of PortalTurretSoundsMod v0.1.0

PortalTurret/PortalTurret.dll

Decompiled 10 months ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using HarmonyLib;
using PortalTurret.Patches;
using PortalTurretSoundsMod;
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("PortalTurret")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("PortalTurret")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("51e9fb40-0ce5-444e-bf0b-25eadb43b695")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace PortalTurretSoundsMod
{
	[BepInPlugin("PortalTurretSounds", "PortalTurretSounds", "0.1.0")]
	public class PortalTurretSounds : BaseUnityPlugin
	{
		private readonly Harmony harmony = new Harmony("PortalTurretSounds");

		private static PortalTurretSounds Instance;

		internal static AudioClip activated_sound;

		internal static AudioClip deactivated_sound;

		internal static AudioClip target_aquired_sound;

		private void Awake()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Expected O, but got Unknown
			if ((Object)Instance == (Object)null)
			{
				Instance = this;
			}
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Portal Turret Sounds is Activating.");
			string location = ((BaseUnityPlugin)Instance).Info.Location;
			if (string.IsNullOrEmpty(location))
			{
				((BaseUnityPlugin)this).Logger.LogError((object)"Failed to locate the file.");
				return;
			}
			string text = "PortalTurret.dll";
			string text2 = location.TrimEnd(text.ToCharArray());
			AssetBundle val = AssetBundle.LoadFromFile(text2 + "portalsounds");
			if ((Object)val == (Object)null)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)"Failed to load the audio files in the assets.");
				return;
			}
			activated_sound = val.LoadAsset<AudioClip>("Assets/activated.wav");
			deactivated_sound = val.LoadAsset<AudioClip>("Assets/sleep_mode.wav");
			target_aquired_sound = val.LoadAsset<AudioClip>("Assets/target_aquired.wav");
			harmony.PatchAll(typeof(TurretPatch));
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Portal Turret Sounds Now Activated.");
		}
	}
}
namespace PortalTurret.Patches
{
	[HarmonyPatch(typeof(Turret))]
	internal class TurretPatch
	{
		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		public static void turretSoundPatch(ref AudioClip ___turretActivate, ref AudioClip ___turretDeactivate, ref AudioClip ___detectPlayerSFX)
		{
			___turretActivate = PortalTurretSounds.activated_sound;
			___turretDeactivate = PortalTurretSounds.deactivated_sound;
			___detectPlayerSFX = PortalTurretSounds.target_aquired_sound;
		}
	}
}