using System;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using MicIndicator;
using Microsoft.CodeAnalysis;
using Photon.Voice;
using Photon.Voice.PUN;
using UnityEngine;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.1", FrameworkDisplayName = ".NET Framework 4.7.1")]
[assembly: AssemblyCompany("MicIndicator")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.1.0")]
[assembly: AssemblyInformationalVersion("1.0.1+bd85f4333f96a49d69afe1d68fa647bf6067186f")]
[assembly: AssemblyProduct("MicIndicator")]
[assembly: AssemblyTitle("MicIndicator")]
[assembly: AssemblyVersion("1.0.1.0")]
[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;
}
}
}
internal class ConstantFields
{
private static FieldInfo ampPeak;
private static FieldInfo ampPeakShort;
public static FieldInfo GetVoiceAudioField()
{
if (ampPeak == null)
{
FieldInfo[] fields = typeof(LevelMeterFloat).GetFields(BindingFlags.Instance | BindingFlags.NonPublic);
foreach (FieldInfo fieldInfo in fields)
{
if (fieldInfo.Name.ToLower().Contains("amppeak"))
{
ampPeak = fieldInfo;
break;
}
}
}
return ampPeak;
}
public static FieldInfo GetVoiceAudioFieldShort()
{
if (ampPeakShort == null)
{
FieldInfo[] fields = typeof(LevelMeterShort).GetFields(BindingFlags.Instance | BindingFlags.NonPublic);
foreach (FieldInfo fieldInfo in fields)
{
if (fieldInfo.Name.ToLower().Contains("amppeak"))
{
ampPeakShort = fieldInfo;
break;
}
}
}
return ampPeakShort;
}
}
public class EventComponent : MonoBehaviour
{
private RawImage micIcon;
private PhotonVoiceView micView;
private void Update()
{
//IL_012c: Unknown result type (might be due to invalid IL or missing references)
//IL_0072: Unknown result type (might be due to invalid IL or missing references)
//IL_0081: Unknown result type (might be due to invalid IL or missing references)
//IL_008b: Unknown result type (might be due to invalid IL or missing references)
//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
if (!Plugin.itsTimeXD)
{
return;
}
if ((Object)(object)micIcon == (Object)null)
{
GameObject val = GameObject.Find("/GAME/GUIManager/Canvas_HUD/Inventory/Layout/UI_InventoryBackpack/Icon/");
GameObject val2 = GameObject.Find("/GAME/GUIManager/Canvas_HUD/");
if ((Object)(object)val != (Object)null && (Object)(object)val2 != (Object)null)
{
val = Object.Instantiate<GameObject>(val);
val.transform.parent = val2.transform;
Transform transform = val.transform;
Transform obj = ((transform is RectTransform) ? transform : null);
((RectTransform)obj).anchoredPosition = new Vector2(Plugin.configPosition.Value.x, Plugin.configPosition.Value.y);
((RectTransform)obj).sizeDelta = new Vector2(Plugin.configScale.Value, Plugin.configScale.Value);
((RectTransform)obj).anchorMax = new Vector2(0f, 0f);
((RectTransform)obj).anchorMin = new Vector2(0f, 0f);
obj.localScale = new Vector3(1f, 1f, 1f);
RawImage component = val.GetComponent<RawImage>();
if ((Object)(object)component != (Object)null)
{
micIcon = component;
((Behaviour)micIcon).enabled = Plugin.configIsActive.Value;
}
}
return;
}
if (Input.GetKeyDown(Plugin.configToggleKey.Value))
{
ConfigEntry<bool> configIsActive = Plugin.configIsActive;
configIsActive.Value = !configIsActive.Value;
((Behaviour)micIcon).enabled = Plugin.configIsActive.Value;
}
if ((Object)(object)micView != (Object)null)
{
ILevelMeter levelMeter = micView.RecorderInUse.LevelMeter;
if (levelMeter == null)
{
return;
}
if (levelMeter is LevelMeterShort)
{
if (micView.IsRecording && (float)ConstantFields.GetVoiceAudioFieldShort().GetValue(levelMeter) > Plugin.configMicDetectionThreshold.Value)
{
micIcon.texture = (Texture)(object)Plugin.micOnTex;
}
else
{
micIcon.texture = (Texture)(object)Plugin.micOffTex;
}
}
else if (levelMeter is LevelMeterFloat)
{
if (micView.IsRecording && (float)ConstantFields.GetVoiceAudioField().GetValue(levelMeter) > Plugin.configMicDetectionThreshold.Value)
{
micIcon.texture = (Texture)(object)Plugin.micOnTex;
}
else
{
micIcon.texture = (Texture)(object)Plugin.micOffTex;
}
}
else
{
Plugin.Logger.LogInfo((object)"Zamn ;-; Thats crazy my man");
}
}
else if ((Object)(object)Character.localCharacter != (Object)null)
{
Character localCharacter = Character.localCharacter;
PhotonVoiceView val3 = ((localCharacter != null) ? ((Component)localCharacter).GetComponent<PhotonVoiceView>() : null);
if ((Object)(object)val3 != (Object)null)
{
micView = val3;
}
}
}
private void OnGUI()
{
}
private void LateUpdate()
{
}
private void Start()
{
}
}
namespace MicIndicator
{
[BepInPlugin("MicIndicator", "MicIndicator", "1.0.1")]
public class Plugin : BaseUnityPlugin
{
internal static ManualLogSource Logger;
internal static EventComponent Component;
public static ConfigEntry<KeyCode> configToggleKey;
public static ConfigEntry<bool> configIsActive;
public static ConfigEntry<Vector2> configPosition;
public static ConfigEntry<float> configScale;
public static ConfigEntry<float> configMicDetectionThreshold;
internal static Texture2D micOnTex;
internal static Texture2D micOffTex;
internal static bool itsTimeXD;
private void Awake()
{
//IL_005e: Unknown result type (might be due to invalid IL or missing references)
configToggleKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Keybinds", "ToggleKey", (KeyCode)279, "The key used to toggle the GUI on and off");
configIsActive = ((BaseUnityPlugin)this).Config.Bind<bool>("GUI", "IsActive", true, "If the icon is showing");
configPosition = ((BaseUnityPlugin)this).Config.Bind<Vector2>("GUI", "Position", new Vector2(100f, 160f), "The position of the icon");
configScale = ((BaseUnityPlugin)this).Config.Bind<float>("GUI", "Scale", 100f, "The scale of the icon");
configMicDetectionThreshold = ((BaseUnityPlugin)this).Config.Bind<float>("Mic", "MicDetectionThreshold", 0.001f, "Mic Detection Min Value. Increase to make mic detection less sensitive. Decrease to make it more sensitive");
Logger = ((BaseUnityPlugin)this).Logger;
Logger.LogInfo((object)"Plugin MicIndicator is loaded!");
string[] commandLineArgs = Environment.GetCommandLineArgs();
foreach (string text in commandLineArgs)
{
Logger.LogInfo((object)("Launch Options " + text + ".!"));
}
Component = ((Component)this).gameObject.AddComponent<EventComponent>();
micOnTex = GetTextureFromAssemImage("MicIndicator.Images.MicOn.png");
micOffTex = GetTextureFromAssemImage("MicIndicator.Images.MicOff.png");
itsTimeXD = true;
}
internal Texture2D GetTextureFromAssemImage(string imageName)
{
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_003b: Expected O, but got Unknown
using Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(imageName);
if (stream == null)
{
Logger.LogError((object)"COULD NOT FIND MIC ICON. REPORT THIS TO MOD MAKER");
return null;
}
Image val = Image.FromStream(stream);
Texture2D val2 = new Texture2D(val.Width, val.Height);
using (MemoryStream memoryStream = new MemoryStream())
{
val.Save((Stream)memoryStream, ImageFormat.Png);
ImageConversion.LoadImage(val2, memoryStream.ToArray());
val2.Apply();
}
return val2;
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "MicIndicator";
public const string PLUGIN_NAME = "MicIndicator";
public const string PLUGIN_VERSION = "1.0.1";
}
}