Decompiled source of ChineseTurret v1.1.1

ChineseTurret.dll

Decompiled 11 months ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using ChineseTurret.Patches;
using HarmonyLib;
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("ChineseTurret")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ChineseTurret")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("44358973-1ffb-4a59-af3d-bd89056a6085")]
[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 ChineseTurret
{
	[BepInPlugin("Botpa.ChineseTurret", "Chinese Turret", "1.0.0")]
	public class ChineseTurretBase : BaseUnityPlugin
	{
		private const string modGUID = "Botpa.ChineseTurret";

		private const string modName = "Chinese Turret";

		private const string modVersion = "1.0.0";

		private readonly Harmony harmony = new Harmony("Botpa.ChineseTurret");

		private static ChineseTurretBase instance;

		internal ManualLogSource mls;

		internal static AudioClip detectPlayerSFX;

		internal static AudioClip firingSFX;

		internal static AudioClip phoneSFX;

		private void Awake()
		{
			if ((Object)(object)instance == (Object)null)
			{
				instance = this;
			}
			mls = Logger.CreateLogSource("Botpa.ChineseTurret");
			mls.LogInfo((object)"Loading Chinese Turret (your phone linguin).");
			string text = ((BaseUnityPlugin)this).Info.Location.TrimEnd("ChineseTurret.dll".ToCharArray());
			string text2 = text + "chinese";
			AssetBundle val = AssetBundle.LoadFromFile(text2);
			if ((Object)(object)val == (Object)null)
			{
				mls.LogError((object)"Failed to load Chinese Turret assets.");
				return;
			}
			detectPlayerSFX = val.LoadAsset<AudioClip>("assets/chinese-turret-detect-player.wav");
			firingSFX = val.LoadAsset<AudioClip>("assets/chinese-turret-firing.wav");
			phoneSFX = val.LoadAsset<AudioClip>("assets/chinese-phone.wav");
			harmony.PatchAll(typeof(ChineseTurretBase));
			harmony.PatchAll(typeof(ChineseTurretPatch));
			harmony.PatchAll(typeof(ChinesePhonePatch));
			mls.LogInfo((object)"Chinese Turret loaded successfully.");
		}
	}
}
namespace ChineseTurret.Patches
{
	[HarmonyPatch(typeof(GrabbableObject))]
	internal class ChinesePhonePatch
	{
		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		public static void phoneAudioPatch(ref Item ___itemProperties)
		{
			if (!(___itemProperties.itemName != "Old phone"))
			{
				___itemProperties.pocketSFX = ChineseTurretBase.phoneSFX;
			}
		}
	}
	[HarmonyPatch(typeof(Turret))]
	internal class ChineseTurretPatch
	{
		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		public static void turretAudioPatch(ref AudioClip ___detectPlayerSFX, ref AudioClip ___firingSFX, ref AudioClip ___firingFarSFX)
		{
			___detectPlayerSFX = ChineseTurretBase.detectPlayerSFX;
			___firingSFX = ChineseTurretBase.firingSFX;
			___firingFarSFX = ChineseTurretBase.firingSFX;
		}
	}
}