using System;
using System.Collections.Generic;
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 HarmonyLib;
using Microsoft.CodeAnalysis;
using ProximityChat;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: IgnoresAccessChecksTo("GameAssembly")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("SBG-VoiceOverlay")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+c4116cae25dd57ca92bdc8edd61d9fbb2b8cd331")]
[assembly: AssemblyProduct("Voice Overlay")]
[assembly: AssemblyTitle("SBG-VoiceOverlay")]
[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.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace PiPBallCam
{
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "SBG-VoiceOverlay";
public const string PLUGIN_NAME = "Voice Overlay";
public const string PLUGIN_VERSION = "1.0.0";
}
}
namespace VoiceActivityOverlay
{
[BepInPlugin("com.kingcox22.sbg.voiceoverlay", "SBG-Voice Overlay", "1.0.0")]
public class VoiceOverlayPlugin : BaseUnityPlugin
{
[HarmonyPatch(typeof(VoiceNetworker), "OnStartClient")]
public static class VoiceNetworker_Patch
{
private static void Postfix(VoiceNetworker __instance)
{
if (!_allNetworkers.Contains(__instance))
{
_allNetworkers.Add(__instance);
}
}
}
private static List<VoiceNetworker> _allNetworkers = new List<VoiceNetworker>();
private static GUIStyle _labelStyle;
private static MemberInfo _volumeMember;
private static bool _searched = false;
private ConfigEntry<float> _offsetX;
private ConfigEntry<float> _offsetY;
private ConfigEntry<int> _fontSize;
private void Awake()
{
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_0045: Expected O, but got Unknown
//IL_006b: Unknown result type (might be due to invalid IL or missing references)
//IL_0075: Expected O, but got Unknown
//IL_0098: Unknown result type (might be due to invalid IL or missing references)
//IL_00a2: Expected O, but got Unknown
//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
AcceptableValueRange<int> val = new AcceptableValueRange<int>(1, 32);
AcceptableValueRange<float> val2 = new AcceptableValueRange<float>(0f, 3000f);
_offsetX = ((BaseUnityPlugin)this).Config.Bind<float>("General", "X Offset", 20f, new ConfigDescription("Horizontal position.", (AcceptableValueBase)(object)val2, Array.Empty<object>()));
_offsetY = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Y Offset", 20f, new ConfigDescription("Vertical starting position.", (AcceptableValueBase)(object)val2, Array.Empty<object>()));
_fontSize = ((BaseUnityPlugin)this).Config.Bind<int>("General", "Font Size", 18, new ConfigDescription("Size of the text.", (AcceptableValueBase)(object)val, Array.Empty<object>()));
new Harmony("com.kingcox22.sbg.voiceoverlay").PatchAll();
((BaseUnityPlugin)this).Logger.LogInfo((object)"Voice Activity Overlay Loaded!");
}
private void OnGUI()
{
//IL_0123: Unknown result type (might be due to invalid IL or missing references)
//IL_0128: Unknown result type (might be due to invalid IL or missing references)
//IL_0130: Unknown result type (might be due to invalid IL or missing references)
//IL_013d: Expected O, but got Unknown
//IL_0289: Unknown result type (might be due to invalid IL or missing references)
//IL_02ac: Unknown result type (might be due to invalid IL or missing references)
//IL_02be: Unknown result type (might be due to invalid IL or missing references)
//IL_02d5: Unknown result type (might be due to invalid IL or missing references)
if (_allNetworkers.Count == 0)
{
return;
}
if (!_searched)
{
_searched = true;
Type typeFromHandle = typeof(VoiceNetworker);
string[] array = new string[3] { "SlowSmoothedNormalizedVolume", "SmoothedNormalizedVolume", "normalizedVolume" };
string[] array2 = array;
foreach (string name in array2)
{
_volumeMember = typeFromHandle.GetProperty(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
if (_volumeMember != null)
{
break;
}
_volumeMember = typeFromHandle.GetField(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
if (_volumeMember != null)
{
break;
}
}
if (_volumeMember != null)
{
((BaseUnityPlugin)this).Logger.LogInfo((object)("Found volume member: " + _volumeMember.Name + " via reflection."));
}
else
{
((BaseUnityPlugin)this).Logger.LogError((object)"Could not find any volume property/field on VoiceNetworker.");
}
}
if (_labelStyle == null)
{
_labelStyle = new GUIStyle(GUI.skin.label)
{
fontStyle = (FontStyle)1,
richText = true
};
}
_labelStyle.fontSize = _fontSize.Value;
float value = _offsetX.Value;
float num = _offsetY.Value;
_allNetworkers.RemoveAll((VoiceNetworker v) => (Object)(object)v == (Object)null);
foreach (VoiceNetworker allNetworker in _allNetworkers)
{
if (allNetworker.IsTalking)
{
PlayerGolfer componentInParent = ((Component)allNetworker).GetComponentInParent<PlayerGolfer>();
string text = (((Object)(object)componentInParent != (Object)null) ? GetPlayerName(componentInParent.PlayerInfo) : "Unknown");
float num2 = 0f;
if (_volumeMember is PropertyInfo propertyInfo)
{
num2 = (float)propertyInfo.GetValue(allNetworker);
}
else if (_volumeMember is FieldInfo fieldInfo)
{
num2 = (float)fieldInfo.GetValue(allNetworker);
}
int count = Mathf.Max(1, (int)(num2 * 20f));
string text2 = new string('|', count);
string text3 = "[VOICE] " + text + " " + text2;
string text4 = "<color=#00FF00>[VOICE]</color> " + text + " " + text2;
GUI.color = Color.black;
GUI.Label(new Rect(value + 2f, num + 2f, 600f, 35f), text3, _labelStyle);
GUI.color = Color.white;
GUI.Label(new Rect(value, num, 600f, 35f), text4, _labelStyle);
num += (float)(_fontSize.Value + 7);
}
}
}
private string GetPlayerName(PlayerInfo info)
{
if ((Object)(object)info == (Object)null)
{
return "Unknown";
}
Type type = ((object)info).GetType();
FieldInfo field = type.GetField("playerName", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
if (field != null)
{
return field.GetValue(info)?.ToString() ?? "Unknown";
}
Component component = ((Component)info).GetComponent("PlayerId");
if ((Object)(object)component != (Object)null)
{
FieldInfo field2 = ((object)component).GetType().GetField("playerName", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
if (field2 != null)
{
return field2.GetValue(component)?.ToString() ?? "Unknown";
}
}
return "Golfer";
}
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}