using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using UnityEngine;
using Zorro.Settings;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("0.0.0.0")]
[BepInPlugin("com.yourname.peaktoggle", "PEAK Mic Toggle", "1.0.0")]
public class PeakTogglePlugin : BaseUnityPlugin
{
[CompilerGenerated]
private sealed class <WaitForSettings>d__3 : IEnumerator<object>, IDisposable, IEnumerator
{
private int <>1__state;
private object <>2__current;
public PeakTogglePlugin <>4__this;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <WaitForSettings>d__3(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Expected O, but got Unknown
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<>2__current = (object)new WaitForSeconds(1f);
<>1__state = 1;
return true;
case 1:
<>1__state = -1;
<>4__this._settingHandler = (ISettingHandler)(object)SettingsHandler.Instance;
if (<>4__this._settingHandler == null)
{
((BaseUnityPlugin)<>4__this).Logger.LogError((object)"SettingsHandler.Instance is still null after delay.");
return false;
}
<>4__this._pttSetting = <>4__this._settingHandler.GetSetting<PushToTalkSetting>();
if (<>4__this._pttSetting == null)
{
((BaseUnityPlugin)<>4__this).Logger.LogError((object)"Failed to find PushToTalkSetting.");
return false;
}
((BaseUnityPlugin)<>4__this).Logger.LogInfo((object)"PEAK Mic Toggle initialized successfully.");
return false;
}
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
private PushToTalkSetting _pttSetting;
private ISettingHandler _settingHandler;
private void Start()
{
((MonoBehaviour)this).StartCoroutine(WaitForSettings());
}
[IteratorStateMachine(typeof(<WaitForSettings>d__3))]
private IEnumerator WaitForSettings()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <WaitForSettings>d__3(0)
{
<>4__this = this
};
}
private void Update()
{
if (_pttSetting != null && _settingHandler != null && Input.GetKeyDown((KeyCode)118))
{
int value = ((EnumSetting<PushToTalkType>)(object)_pttSetting).GetValue();
List<string> unlocalizedChoices = ((EnumSetting<PushToTalkType>)(object)_pttSetting).GetUnlocalizedChoices();
if (unlocalizedChoices == null || unlocalizedChoices.Count < 2)
{
((BaseUnityPlugin)this).Logger.LogError((object)("Unexpected PushToTalkSetting choices: " + ((unlocalizedChoices == null) ? "null" : unlocalizedChoices.Count.ToString())));
return;
}
int num = (value + 1) % unlocalizedChoices.Count;
((EnumSetting<PushToTalkType>)(object)_pttSetting).SetValue(num, _settingHandler, false);
((BaseUnityPlugin)this).Logger.LogInfo((object)("[PEAK TOGGLE] Mic mode switched to: " + unlocalizedChoices[num]));
}
}
}