using System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; 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("DeadVoiceChat")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("Dead Voice Chat")] [assembly: AssemblyTitle("DeadVoiceChat")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [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 DeadVoiceChat { public static class PluginInfo { public const string PLUGIN_GUID = "com.axiom.deadvoicechat"; public const string PLUGIN_NAME = "Dead Voice Chat"; public const string PLUGIN_VERSION = "3.0.0"; public const string AUTHOR = "3udah"; public const string DISCORD = "75b"; } [BepInPlugin("com.axiom.deadvoicechat", "Dead Voice Chat", "3.0.0")] public class Plugin : BaseUnityPlugin { internal static ManualLogSource Logger; internal static ConfigEntry ModEnabled; internal static ConfigEntry DeadPlayerVolume; internal static ConfigEntry GhostPitchEffect; internal static ConfigEntry GhostPitchAmount; internal static ConfigEntry ProximityMuffling; internal static ConfigEntry ProximityMaxDistance; internal static ConfigEntry DeadHearAlive; internal static ConfigEntry AliveHearDead; internal static ConfigEntry SpectatorOnlyChat; internal static ConfigEntry ShowAuthorInConsole; internal static Type PlayerDeathHeadType; internal static Type PlayerAvatarType; internal static bool TypesResolved; private static Harmony _harmony; private void Awake() { //IL_02a7: Unknown result type (might be due to invalid IL or missing references) //IL_02b1: Expected O, but got Unknown Logger = ((BaseUnityPlugin)this).Logger; ModEnabled = ((BaseUnityPlugin)this).Config.Bind("General", "Enabled", true, "Toggle the mod on or off"); DeadPlayerVolume = ((BaseUnityPlugin)this).Config.Bind("Audio", "DeadPlayerVolume", 1f, "Volume multiplier for dead players (0.0 to 2.0)"); GhostPitchEffect = ((BaseUnityPlugin)this).Config.Bind("Audio", "GhostPitchEffect", false, "Shifts pitch of dead players' voices"); GhostPitchAmount = ((BaseUnityPlugin)this).Config.Bind("Audio", "GhostPitchAmount", 0.7f, "Pitch multiplier (0.5 = deep, 1.5 = high)"); ProximityMuffling = ((BaseUnityPlugin)this).Config.Bind("Audio", "ProximityMuffling", false, "Dead players quieter based on distance"); ProximityMaxDistance = ((BaseUnityPlugin)this).Config.Bind("Audio", "ProximityMaxDistance", 20f, "Max distance for proximity muffling"); DeadHearAlive = ((BaseUnityPlugin)this).Config.Bind("Chat Rules", "DeadHearAlive", true, "Dead players can hear alive players"); AliveHearDead = ((BaseUnityPlugin)this).Config.Bind("Chat Rules", "AliveHearDead", true, "Alive players can hear dead players"); SpectatorOnlyChat = ((BaseUnityPlugin)this).Config.Bind("Chat Rules", "SpectatorOnlyChat", false, "Dead players can only hear other dead players"); ShowAuthorInConsole = ((BaseUnityPlugin)this).Config.Bind("Credits", "ShowAuthorInConsole", true, "Display author credit on startup"); ((BaseUnityPlugin)this).Config.Bind("Credits", "Author", "3udah", "Mod author (read-only)"); ((BaseUnityPlugin)this).Config.Bind("Credits", "Discord", "75b", "Author Discord (read-only)"); PlayerDeathHeadType = AccessTools.TypeByName("PlayerDeathHead"); PlayerAvatarType = AccessTools.TypeByName("PlayerAvatar"); TypesResolved = PlayerDeathHeadType != null && PlayerAvatarType != null; Logger.LogInfo((object)$"Type resolution: PlayerDeathHead={PlayerDeathHeadType != null}, PlayerAvatar={PlayerAvatarType != null}"); if (!ModEnabled.Value) { Logger.LogInfo((object)"Dead Voice Chat is disabled in config."); return; } if (ShowAuthorInConsole.Value) { Logger.LogInfo((object)"==========================================="); Logger.LogInfo((object)" Dead Voice Chat v3.0.0"); Logger.LogInfo((object)" Author: 3udah"); Logger.LogInfo((object)" Discord: 75b"); Logger.LogInfo((object)"==========================================="); } Logger.LogInfo((object)"Plugin Dead Voice Chat is loaded! Fuck yeah."); _harmony = new Harmony("com.axiom.deadvoicechat"); _harmony.PatchAll(); } } [HarmonyPatch(typeof(PlayerVoiceChat))] internal static class PlayerVoiceChatPatches { private static float _volumeTimer; private const float VOLUME_INTERVAL = 0.2f; [HarmonyPostfix] [HarmonyPatch("Update")] private static void UpdatePostfix(PlayerVoiceChat __instance, AudioSource ___audioSource) { if (!Plugin.ModEnabled.Value || (Object)(object)___audioSource == (Object)null || (Object)(object)__instance == (Object)null) { return; } try { if ((Object)(object)___audioSource.outputAudioMixerGroup != (Object)(object)__instance.mixerMicrophoneSound) { ___audioSource.outputAudioMixerGroup = __instance.mixerMicrophoneSound; } _volumeTimer -= Time.deltaTime; if (_volumeTimer <= 0f) { _volumeTimer = 0.2f; float value = Plugin.DeadPlayerVolume.Value; if (!Mathf.Approximately(___audioSource.volume, value)) { ___audioSource.volume = value; } if (Plugin.ProximityMuffling.Value) { ApplyProximityMuffling(__instance, ___audioSource); } } if (Plugin.GhostPitchEffect.Value) { ___audioSource.pitch = Plugin.GhostPitchAmount.Value; } else if (!Mathf.Approximately(___audioSource.pitch, 1f)) { ___audioSource.pitch = 1f; } } catch { } } private static void ApplyProximityMuffling(PlayerVoiceChat voiceChat, AudioSource audioSource) { //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) try { if (Plugin.PlayerAvatarType == null) { return; } Object obj = Object.FindObjectOfType(Plugin.PlayerAvatarType); Component val = (Component)(object)((obj is Component) ? obj : null); if ((Object)(object)val == (Object)null) { return; } Transform transform = val.transform; Component componentInParent = ((Component)voiceChat).GetComponentInParent(Plugin.PlayerAvatarType); if (!((Object)(object)componentInParent == (Object)null) && !((Object)(object)((Component)(Behaviour)componentInParent).transform == (Object)null) && !((Object)(object)componentInParent == (Object)(object)val)) { float num = Vector3.Distance(transform.position, ((Component)(Behaviour)componentInParent).transform.position); float value = Plugin.ProximityMaxDistance.Value; if (num >= value) { audioSource.volume = 0f; return; } float num2 = 1f - num / value; audioSource.volume = Plugin.DeadPlayerVolume.Value * num2; } } catch { } } } public static class MyPluginInfo { public const string PLUGIN_GUID = "DeadVoiceChat"; public const string PLUGIN_NAME = "Dead Voice Chat"; public const string PLUGIN_VERSION = "1.0.0"; } }