Decompiled source of VoiceTranqMod v1.0.0

VoiceTranqMod.dll

Decompiled 5 hours ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using Photon.Pun;
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("VoiceTranqMod")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("VoiceTranqMod")]
[assembly: AssemblyCopyright("Copyright ©  2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("eb691512-c1ce-48bb-8f5e-fd8c3d5ce5be")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace VoiceTranqMod;

[BepInPlugin("com.yourname.voicetranqmod", "Voice Tranq Mod", "1.0.0")]
public class VoiceTranqPlugin : BaseUnityPlugin
{
	public static ConfigEntry<KeyCode> ToggleKeyConfig;

	public static bool isFeatureActive = true;

	private void Awake()
	{
		//IL_0027: Unknown result type (might be due to invalid IL or missing references)
		//IL_002d: Expected O, but got Unknown
		ToggleKeyConfig = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Settings", "ToggleKey", (KeyCode)118, "Toggle key to turn the Voice Tranq mod ON/OFF");
		Harmony val = new Harmony("com.yourname.voicetranqmod");
		val.PatchAll();
		((BaseUnityPlugin)this).Logger.LogInfo((object)"Voice Tranq Mod loaded successfully! Default key is V.");
	}

	private void Update()
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		if (Input.GetKeyDown(ToggleKeyConfig.Value))
		{
			isFeatureActive = !isFeatureActive;
			((BaseUnityPlugin)this).Logger.LogInfo((object)("Voice Tranq Mod is now " + (isFeatureActive ? "ON" : "OFF")));
		}
	}
}
[HarmonyPatch(typeof(PlayerAvatar), "Update")]
public class VoiceTranqPatch
{
	private static float rpcTimer;

	[HarmonyPostfix]
	public static void Postfix(PlayerAvatar __instance)
	{
		if (!VoiceTranqPlugin.isFeatureActive || (Object)(object)PlayerAvatar.instance == (Object)null || (Object)(object)__instance != (Object)(object)PlayerAvatar.instance)
		{
			return;
		}
		try
		{
			rpcTimer -= Time.deltaTime;
			if (!(rpcTimer <= 0f))
			{
				return;
			}
			rpcTimer = 2.5f;
			ItemGunTranq val = Object.FindObjectOfType<ItemGunTranq>();
			if ((Object)(object)val != (Object)null)
			{
				PhotonView component = ((Component)val).GetComponent<PhotonView>();
				PhotonView component2 = ((Component)__instance).GetComponent<PhotonView>();
				if ((Object)(object)component != (Object)null && (Object)(object)component2 != (Object)null)
				{
					component.RPC("SlowDownVoiceRPC", (RpcTarget)0, new object[1] { component2.ViewID });
				}
			}
		}
		catch
		{
		}
	}
}