using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using SilentLandmines.Patches;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("SilentLandmines")]
[assembly: AssemblyDescription("Silences the occasional beeps of landmines, and suppresses the idle animation from playing.")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("SilentLandmines")]
[assembly: AssemblyCopyright("Copyright © 2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("FA3F219D-1CA1-475B-AF79-1933F0D7CD81")]
[assembly: AssemblyFileVersion("1.0.*")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.8768.38098")]
namespace SilentLandmines
{
[BepInPlugin("Vee.SilentLandmines", "Vee's Silent Landmines", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
internal ManualLogSource Logger;
private readonly Harmony _harmony = new Harmony("Vee.SilentLandmines");
public static Plugin Instance { get; private set; }
private void Awake()
{
if (!((Object)(object)Instance != (Object)null))
{
Instance = this;
Logger = Logger.CreateLogSource("Vee.SilentLandmines");
Logger.LogInfo((object)"Vee's Silent Landmines 1.0.0 has awakened.");
_harmony.PatchAll(typeof(LandminePatch));
}
}
}
internal static class PluginData
{
internal const string ModGUID = "Vee.SilentLandmines";
internal const string ModName = "Vee's Silent Landmines";
internal const string ModVersion = "1.0.0";
}
}
namespace SilentLandmines.Patches
{
[HarmonyPatch(typeof(Landmine))]
public class LandminePatch
{
[HarmonyPatch("Start")]
[HarmonyPostfix]
private static void SilenceLandmine(ref AudioSource ___mineAudio, ref AudioSource ___mineFarAudio, ref Animator ___mineAnimator)
{
((Behaviour)___mineAudio).enabled = false;
((Behaviour)___mineFarAudio).enabled = false;
___mineAnimator.speed = 0f;
Plugin.Instance.Logger.LogDebug((object)"A landmine has been silenced.");
}
[HarmonyPatch("PressMineServerRpc")]
[HarmonyPrefix]
private static void RestoreLandmineAnimator(ref AudioSource ___mineAudio, ref AudioSource ___mineFarAudio, ref Animator ___mineAnimator)
{
___mineAnimator.speed = 1f;
((Behaviour)___mineAudio).enabled = true;
((Behaviour)___mineFarAudio).enabled = true;
}
}
}