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.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Realtime;
using Photon.Voice;
using Photon.Voice.Unity;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("com.github.ront-tv.SilentSummit")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("com.github.ront-tv.SilentSummit")]
[assembly: AssemblyTitle("SilentSummit")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
internal sealed class NullableAttribute : Attribute
{
public readonly byte[] NullableFlags;
public NullableAttribute(byte P_0)
{
NullableFlags = new byte[1] { P_0 };
}
public NullableAttribute(byte[] P_0)
{
NullableFlags = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
internal sealed class NullableContextAttribute : Attribute
{
public readonly byte Flag;
public NullableContextAttribute(byte P_0)
{
Flag = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.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 BepInEx
{
[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
[Conditional("CodeGeneration")]
internal sealed class BepInAutoPluginAttribute : Attribute
{
public BepInAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
{
}
}
}
namespace BepInEx.Preloader.Core.Patching
{
[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
[Conditional("CodeGeneration")]
internal sealed class PatcherAutoPluginAttribute : Attribute
{
public PatcherAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
{
}
}
}
namespace SilentSummit
{
[BepInPlugin("com.github.ront-tv.SilentSummit", "SilentSummit", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
private readonly Harmony harmony = new Harmony("com.github.ront-tv.SilentSummit");
public const string Id = "com.github.ront-tv.SilentSummit";
internal static ManualLogSource Log { get; private set; }
public static string Name => "SilentSummit";
public static string Version => "1.0.0";
private void Awake()
{
Log = ((BaseUnityPlugin)this).Logger;
Log.LogInfo((object)("Plugin " + Name + " is loaded!"));
harmony.PatchAll(Assembly.GetExecutingAssembly());
}
}
}
namespace SilentSummit.Patches
{
[HarmonyPatch(typeof(CharacterVoiceHandler))]
public class VoicePatch
{
public const byte ALIVE_VOICE_GROUP = 1;
public const byte GHOST_VOICE_GROUP = 2;
private static bool? previousGhostState;
[HarmonyPatch("Update")]
[HarmonyPostfix]
public static void UpdatePatch(CharacterVoiceHandler __instance)
{
if ((Object)(object)__instance.m_character == (Object)null || !__instance.m_character.IsLocal || __instance.m_character.isBot)
{
return;
}
Recorder recorder = __instance.m_Recorder;
if (!((Object)(object)recorder == (Object)null))
{
bool flag = (Object)(object)__instance.m_character.Ghost != (Object)null;
byte b = (byte)((!flag) ? 1 : 2);
if (recorder.InterestGroup != b)
{
recorder.InterestGroup = b;
Plugin.Log.LogInfo((object)string.Format("[VOICE MOD] Set voice transmission group for {0} to {1} (group {2})", __instance.m_character.characterName, flag ? "GHOST" : "ALIVE", b));
}
if (previousGhostState != flag)
{
previousGhostState = flag;
Plugin.Log.LogInfo((object)("[VOICE MOD] Ghost state changed to: " + (flag ? "GHOST" : "ALIVE") + " - updating listening groups"));
UpdateLocalPlayerListeningGroups(flag);
}
}
}
[HarmonyPatch("Start")]
[HarmonyPostfix]
public static void StartPatch(CharacterVoiceHandler __instance)
{
if (!((Object)(object)__instance.m_character == (Object)null) && __instance.m_character.IsLocal && !__instance.m_character.isBot)
{
Plugin.Log.LogInfo((object)("[VOICE MOD] Starting voice handler for local character: " + __instance.m_character.characterName));
Player localPlayer = Player.localPlayer;
Character val = ((localPlayer != null) ? localPlayer.character : null);
if (!((Object)(object)val == (Object)null))
{
bool flag = (Object)(object)val.Ghost != (Object)null;
Plugin.Log.LogInfo((object)("[VOICE MOD] Initial state - Character is: " + (flag ? "GHOST" : "ALIVE")));
UpdateLocalPlayerListeningGroups(flag);
}
}
}
private static void UpdateLocalPlayerListeningGroups(bool isGhost)
{
Plugin.Log.LogInfo((object)("[VOICE MOD] Attempting to update listening groups for " + (isGhost ? "ghost" : "alive") + " player"));
VoiceConnection voiceConnection = VoiceClientHandler.m_VoiceConnection;
object obj;
if (voiceConnection == null)
{
obj = null;
}
else
{
LoadBalancingTransport client = voiceConnection.Client;
obj = ((client != null) ? ((LoadBalancingClient)client).LoadBalancingPeer : null);
}
if (obj != null)
{
byte[] array;
if (isGhost)
{
array = new byte[2] { 1, 2 };
Plugin.Log.LogInfo((object)"[VOICE MOD] Local player is now a ghost - can hear both alive and ghost voices");
}
else
{
array = new byte[1] { 1 };
Plugin.Log.LogInfo((object)"[VOICE MOD] Local player is alive - can only hear alive voices");
}
Plugin.Log.LogInfo((object)("[VOICE MOD] Setting listening groups to: [" + string.Join(", ", array) + "]"));
((LoadBalancingClient)VoiceClientHandler.m_VoiceConnection.Client).LoadBalancingPeer.OpChangeGroups(new byte[0], array);
Plugin.Log.LogInfo((object)"[VOICE MOD] Successfully updated listening groups");
}
else
{
Plugin.Log.LogWarning((object)"[VOICE MOD] VoiceConnection is null or not ready");
}
}
}
[HarmonyPatch(typeof(VoiceClientHandler))]
public class VoiceClientHandlerPatch
{
[HarmonyPatch("InitNetworkVoice")]
[HarmonyPostfix]
public static void InitNetworkVoicePatch()
{
Plugin.Log.LogInfo((object)"[VOICE MOD] InitNetworkVoice called - setting up initial listening groups");
Player localPlayer = Player.localPlayer;
Character val = ((localPlayer != null) ? localPlayer.character : null);
if ((Object)(object)val != (Object)null)
{
bool flag = (Object)(object)val.Ghost != (Object)null;
byte[] array = ((!flag) ? new byte[1] { 1 } : new byte[2] { 1, 2 });
VoiceConnection voiceConnection = VoiceClientHandler.m_VoiceConnection;
object obj;
if (voiceConnection == null)
{
obj = null;
}
else
{
LoadBalancingTransport client = voiceConnection.Client;
obj = ((client != null) ? ((LoadBalancingClient)client).LoadBalancingPeer : null);
}
if (obj != null)
{
((LoadBalancingClient)VoiceClientHandler.m_VoiceConnection.Client).LoadBalancingPeer.OpChangeGroups(new byte[0], array);
Plugin.Log.LogInfo((object)("[VOICE MOD] Initialized voice listening groups for " + (flag ? "ghost" : "alive") + " player"));
}
}
}
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}