using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using Dissonance;
using HarmonyLib;
using MageArenaSpanishVoiceMod;
using Recognissimo;
using Recognissimo.Components;
using UnityEngine;
using UnityEngine.Events;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("MageArenaSpanish")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("MageArenaSpanish")]
[assembly: AssemblyCopyright("Copyright © 2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("87fca07c-36fd-431f-b9bf-5a2d6252e2ad")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace MageArenaSpanishVoice.Patches
{
[HarmonyPatch(typeof(VoiceControlListener))]
public static class VoiceControlListenerPatch
{
[CompilerGenerated]
private sealed class <>c__DisplayClass13_0
{
public VoiceControlListener instance;
internal void <CoResetMicLong>b__0(Result res)
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
try
{
tryresultMethod.Invoke(instance, new object[1] { res.text ?? string.Empty });
}
catch (Exception ex)
{
global::MageArenaSpanishVoiceMod.MageArenaSpanishVoiceMod.Log.LogError((object)("Error invoking tryresult (resetmiclong): " + ex));
}
}
}
[CompilerGenerated]
private sealed class <>c__DisplayClass1_0
{
public VoiceControlListener __instance;
internal void <CoWaitGetPlayer>b__0(Result r)
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
try
{
tryresultMethod.Invoke(__instance, new object[1] { r.text ?? string.Empty });
}
catch (Exception ex)
{
global::MageArenaSpanishVoiceMod.MageArenaSpanishVoiceMod.Log.LogError((object)("Error invoking tryresult: " + ex));
}
}
}
[CompilerGenerated]
private sealed class <CoResetMicLong>d__13 : IEnumerator<object>, IDisposable, IEnumerator
{
private int <>1__state;
private object <>2__current;
public VoiceControlListener instance;
private <>c__DisplayClass13_0 <>8__1;
private SpeechRecognizer <oldSr>5__2;
private SpeechRecognizer <newSr>5__3;
private DissonanceSpeechSource <source>5__4;
private StreamingAssetsLanguageModelProvider <provider>5__5;
private Exception <e>5__6;
private List<ISpellCommand>.Enumerator <>s__7;
private ISpellCommand <p>5__8;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <CoResetMicLong>d__13(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>8__1 = null;
<oldSr>5__2 = null;
<newSr>5__3 = null;
<source>5__4 = null;
<provider>5__5 = null;
<e>5__6 = null;
<>s__7 = default(List<ISpellCommand>.Enumerator);
<p>5__8 = null;
<>1__state = -2;
}
private bool MoveNext()
{
//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
//IL_00f6: Expected O, but got Unknown
//IL_0128: Unknown result type (might be due to invalid IL or missing references)
//IL_0132: Expected O, but got Unknown
//IL_0200: Unknown result type (might be due to invalid IL or missing references)
//IL_0213: Unknown result type (might be due to invalid IL or missing references)
//IL_021d: Unknown result type (might be due to invalid IL or missing references)
//IL_0238: Unknown result type (might be due to invalid IL or missing references)
//IL_033e: Unknown result type (might be due to invalid IL or missing references)
//IL_0348: Expected O, but got Unknown
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<>8__1 = new <>c__DisplayClass13_0();
<>8__1.instance = instance;
<oldSr>5__2 = GetOrBindSpeechRecognizer(<>8__1.instance);
if ((Object)(object)<oldSr>5__2 != (Object)null)
{
try
{
((SpeechProcessor)<oldSr>5__2).StopProcessing();
}
catch (ObjectDisposedException)
{
}
catch (Exception ex2)
{
<e>5__6 = ex2;
global::MageArenaSpanishVoiceMod.MageArenaSpanishVoiceMod.Log.LogInfo((object)("StopProcessing old SR: " + <e>5__6.Message));
}
}
try
{
SrField?.SetValue(<>8__1.instance, null);
}
catch
{
}
<>2__current = (object)new WaitForSeconds(0.5f);
<>1__state = 1;
return true;
case 1:
<>1__state = -1;
if ((Object)(object)<oldSr>5__2 != (Object)null)
{
Object.Destroy((Object)(object)<oldSr>5__2);
}
<>2__current = (object)new WaitForSeconds(0.5f);
<>1__state = 2;
return true;
case 2:
<>1__state = -1;
<newSr>5__3 = ((Component)<>8__1.instance).gameObject.AddComponent<SpeechRecognizer>();
try
{
SrField?.SetValue(<>8__1.instance, <newSr>5__3);
}
catch
{
}
<source>5__4 = ((Component)<>8__1.instance).GetComponent<DissonanceSpeechSource>() ?? ((Component)<>8__1.instance).gameObject.AddComponent<DissonanceSpeechSource>();
((SpeechProcessor)<newSr>5__3).SpeechSource = (SpeechSource)(object)<source>5__4;
<provider>5__5 = ((Component)<>8__1.instance).GetComponent<StreamingAssetsLanguageModelProvider>() ?? ((Component)<>8__1.instance).gameObject.AddComponent<StreamingAssetsLanguageModelProvider>();
<provider>5__5.language = (SystemLanguage)34;
<provider>5__5.languageModels = new List<StreamingAssetsLanguageModel>
{
new StreamingAssetsLanguageModel
{
language = (SystemLanguage)34,
path = "LanguageModels/" + modelName
}
};
((SpeechProcessor)<newSr>5__3).LanguageModelProvider = (LanguageModelProvider)(object)<provider>5__5;
<newSr>5__3.Vocabulary = new List<string>();
addSpellsToVocabulary(<newSr>5__3);
if (<>8__1.instance.SpellPages != null)
{
<>s__7 = <>8__1.instance.SpellPages.GetEnumerator();
try
{
while (<>s__7.MoveNext())
{
<p>5__8 = <>s__7.Current;
ISpellCommand obj2 = <p>5__8;
if (obj2 != null)
{
obj2.ResetVoiceDetect();
}
<p>5__8 = null;
}
}
finally
{
((IDisposable)<>s__7).Dispose();
}
<>s__7 = default(List<ISpellCommand>.Enumerator);
}
((UnityEventBase)<newSr>5__3.ResultReady).RemoveAllListeners();
((UnityEvent<Result>)(object)<newSr>5__3.ResultReady).AddListener((UnityAction<Result>)delegate(Result res)
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
try
{
tryresultMethod.Invoke(<>8__1.instance, new object[1] { res.text ?? string.Empty });
}
catch (Exception ex3)
{
global::MageArenaSpanishVoiceMod.MageArenaSpanishVoiceMod.Log.LogError((object)("Error invoking tryresult (resetmiclong): " + ex3));
}
});
<>2__current = (object)new WaitForSeconds(0.1f);
<>1__state = 3;
return true;
case 3:
<>1__state = -1;
((SpeechProcessor)<newSr>5__3).StartProcessing();
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();
}
}
[CompilerGenerated]
private sealed class <CoRestartSr>d__10 : IEnumerator<object>, IDisposable, IEnumerator
{
private int <>1__state;
private object <>2__current;
public VoiceControlListener inst;
private SpeechRecognizer <sr>5__1;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <CoRestartSr>d__10(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<sr>5__1 = null;
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Invalid comparison between Unknown and I4
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<sr>5__1 = GetOrBindSpeechRecognizer(inst);
if ((Object)(object)<sr>5__1 == (Object)null)
{
return false;
}
break;
case 1:
<>1__state = -1;
break;
}
if ((int)((SpeechProcessor)<sr>5__1).State > 0)
{
<>2__current = null;
<>1__state = 1;
return true;
}
((SpeechProcessor)<sr>5__1).StartProcessing();
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();
}
}
[CompilerGenerated]
private sealed class <CoWaitGetPlayer>d__1 : IEnumerator<object>, IDisposable, IEnumerator
{
private int <>1__state;
private object <>2__current;
public VoiceControlListener __instance;
private <>c__DisplayClass1_0 <>8__1;
private SetUpModelProvider <setup>5__2;
private SpeechRecognizer <sr>5__3;
private PlayerInventory <pi>5__4;
private VoiceBroadcastTrigger <vbt>5__5;
private SpeechRecognizer <currentSr>5__6;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <CoWaitGetPlayer>d__1(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>8__1 = null;
<setup>5__2 = null;
<sr>5__3 = null;
<pi>5__4 = null;
<vbt>5__5 = null;
<currentSr>5__6 = null;
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0121: Unknown result type (might be due to invalid IL or missing references)
//IL_012b: Expected O, but got Unknown
//IL_021d: Unknown result type (might be due to invalid IL or missing references)
//IL_0227: Expected O, but got Unknown
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<>8__1 = new <>c__DisplayClass1_0();
<>8__1.__instance = __instance;
goto IL_00e7;
case 1:
<>1__state = -1;
<pi>5__4 = null;
goto IL_00e7;
case 2:
<>1__state = -1;
<>2__current = (object)new WaitForSeconds(0.5f);
<>1__state = 3;
return true;
case 3:
<>1__state = -1;
<setup>5__2 = ((Component)<>8__1.__instance).GetComponent<SetUpModelProvider>() ?? ((Component)<>8__1.__instance).gameObject.AddComponent<SetUpModelProvider>();
<setup>5__2.Setup();
<>2__current = null;
<>1__state = 4;
return true;
case 4:
<>1__state = -1;
<sr>5__3 = GetOrBindSpeechRecognizer(<>8__1.__instance);
if ((Object)(object)<sr>5__3 == (Object)null)
{
global::MageArenaSpanishVoiceMod.MageArenaSpanishVoiceMod.Log.LogError((object)"SpeechRecognizer not found.");
return false;
}
addSpellsToVocabulary(<sr>5__3);
((UnityEventBase)<sr>5__3.ResultReady).RemoveAllListeners();
((UnityEvent<Result>)(object)<sr>5__3.ResultReady).AddListener((UnityAction<Result>)delegate(Result r)
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
try
{
tryresultMethod.Invoke(<>8__1.__instance, new object[1] { r.text ?? string.Empty });
}
catch (Exception ex2)
{
global::MageArenaSpanishVoiceMod.MageArenaSpanishVoiceMod.Log.LogError((object)("Error invoking tryresult: " + ex2));
}
});
((SpeechProcessor)<sr>5__3).StartProcessing();
break;
case 5:
{
<>1__state = -1;
<vbt>5__5 = GetOrBindVbt(<>8__1.__instance);
<currentSr>5__6 = GetOrBindSpeechRecognizer(<>8__1.__instance);
if ((Object)(object)<currentSr>5__6 != (Object)null && (Object)(object)<vbt>5__5 != (Object)null && !<vbt>5__5.IsTransmitting)
{
try
{
((SpeechProcessor)<currentSr>5__6).StopProcessing();
}
catch (ObjectDisposedException)
{
}
((MonoBehaviour)<>8__1.__instance).StartCoroutine((IEnumerator)restartsrMethod.Invoke(<>8__1.__instance, null));
}
<vbt>5__5 = null;
<currentSr>5__6 = null;
break;
}
IL_00e7:
if ((Object)(object)<>8__1.__instance.pi == (Object)null)
{
if ((Object)(object)Camera.main != (Object)null && (Object)(object)((Component)Camera.main).transform.parent != (Object)null && ((Component)((Component)Camera.main).transform.parent).TryGetComponent<PlayerInventory>(ref <pi>5__4))
{
<>8__1.__instance.pi = <pi>5__4;
}
<>2__current = null;
<>1__state = 1;
return true;
}
<>2__current = null;
<>1__state = 2;
return true;
}
if (((Behaviour)<>8__1.__instance).isActiveAndEnabled)
{
<>2__current = (object)new WaitForSeconds(30f);
<>1__state = 5;
return true;
}
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();
}
}
[CompilerGenerated]
private sealed class <RestartRecognizerCoroutine>d__6 : IEnumerator<object>, IDisposable, IEnumerator
{
private int <>1__state;
private object <>2__current;
public VoiceControlListener inst;
private SpeechRecognizer <sr>5__1;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <RestartRecognizerCoroutine>d__6(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<sr>5__1 = null;
<>1__state = -2;
}
private bool MoveNext()
{
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<sr>5__1 = GetOrBindSpeechRecognizer(inst);
if ((Object)(object)<sr>5__1 == (Object)null)
{
global::MageArenaSpanishVoiceMod.MageArenaSpanishVoiceMod.Log.LogError((object)"Sr is null");
return false;
}
((SpeechProcessor)<sr>5__1).StopProcessing();
<>2__current = null;
<>1__state = 1;
return true;
case 1:
<>1__state = -1;
((SpeechProcessor)<sr>5__1).StartProcessing();
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 static string modelName = "vosk-model-small-es-0.42";
private static readonly MethodInfo tryresultMethod = AccessTools.Method(typeof(VoiceControlListener), "tryresult", new Type[1] { typeof(string) }, (Type[])null);
private static readonly FieldInfo ResetMicCooldownField = AccessTools.Field(typeof(VoiceControlListener), "resetmiccooldown");
private static readonly FieldInfo SrField = AccessTools.Field(typeof(VoiceControlListener), "sr");
private static readonly Dictionary<string[], Action<VoiceControlListener>> spanishCommandMap = new Dictionary<string[], Action<VoiceControlListener>>
{
{
new string[5] { "bola", "fuego", "juego", "vola", "fuegos" },
delegate(VoiceControlListener v)
{
v.CastFireball();
}
},
{
new string[3] { "congelar", "congela", "congelado" },
delegate(VoiceControlListener v)
{
v.CastFrostBolt();
}
},
{
new string[2] { "entrada", "entrar" },
delegate(VoiceControlListener v)
{
v.CastWorm();
}
},
{
new string[2] { "salida", "salir" },
delegate(VoiceControlListener v)
{
v.CastHole();
}
},
{
new string[3] { "misil", "mágico", "magico" },
delegate(VoiceControlListener v)
{
v.CastMagicMissle();
}
},
{
new string[1] { "espejito espejito" },
delegate(VoiceControlListener v)
{
v.ActivateMirror();
}
}
};
private static readonly Dictionary<string, string[]> spanishAdditionalCommandMap = new Dictionary<string, string[]>
{
{
"rock",
new string[2] { "roca", "piedra" }
},
{
"wisp",
new string[4] { "errante", "espectro", "ánima", "anima" }
},
{
"blast",
new string[3] { "ráfaga", "oscura", "rafaga" }
},
{
"divine",
new string[2] { "luz", "divina" }
},
{
"blink",
new string[3] { "destello", "teletransporte", "parpadeo" }
},
{
"thunderbolt",
new string[2] { "rayo", "trueno" }
},
{
"Testicular Torsion",
new string[3] { "torsion", "testicular", "torsión" }
},
{
"Magic Shield",
new string[4] { "escudo", "mágico", "barrera", "mágica" }
},
{
"Echo Location",
new string[3] { "ecolocalización", "eco", "localización" }
}
};
private static readonly MethodInfo restartsrMethod = AccessTools.Method(typeof(VoiceControlListener), "restartsr", (Type[])null, (Type[])null);
private static readonly string[] SrFieldNames = new string[1] { "sr" };
[HarmonyPatch("OnStartClient")]
[HarmonyPostfix]
private static void OnStartClient_Postfix(VoiceControlListener __instance)
{
((MonoBehaviour)__instance).StartCoroutine(CoWaitGetPlayer(__instance));
}
[IteratorStateMachine(typeof(<CoWaitGetPlayer>d__1))]
private static IEnumerator CoWaitGetPlayer(VoiceControlListener __instance)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <CoWaitGetPlayer>d__1(0)
{
__instance = __instance
};
}
[HarmonyPatch(/*Could not decode attribute arguments.*/)]
[HarmonyPrefix]
public static void LanguageModel_Ctor_Prefix(ref string path)
{
string location = ((BaseUnityPlugin)global::MageArenaSpanishVoiceMod.MageArenaSpanishVoiceMod.Instance).Info.Location;
string directoryName = Path.GetDirectoryName(location);
string text = Path.Combine(directoryName, "LanguageModels", modelName);
path = text;
global::MageArenaSpanishVoiceMod.MageArenaSpanishVoiceMod.Log.LogInfo((object)("Loading language model from: " + path));
}
[HarmonyPatch("tryresult")]
[HarmonyPrefix]
private static bool TryResultPrefix(VoiceControlListener __instance, string res)
{
if (string.IsNullOrWhiteSpace(res))
{
return false;
}
res = res.ToLowerInvariant().Trim();
foreach (KeyValuePair<string[], Action<VoiceControlListener>> item in spanishCommandMap)
{
if (item.Key.Any((string keyword) => res.Contains(keyword)))
{
item.Value(__instance);
}
}
int num = __instance.SpellPages?.Count ?? (-1);
foreach (ISpellCommand spellPage in __instance.SpellPages)
{
string spellName = spellPage.GetSpellName();
foreach (KeyValuePair<string, string[]> item2 in spanishAdditionalCommandMap)
{
bool flag = false;
string[] value = item2.Value;
foreach (string value2 in value)
{
if (res.Contains(value2))
{
flag = true;
break;
}
}
if (flag && string.Equals(spellName, item2.Key, StringComparison.OrdinalIgnoreCase))
{
spellPage.TryCastSpell();
}
}
if (res.Contains(spellName.ToLowerInvariant()))
{
spellPage.TryCastSpell();
}
}
return false;
}
[IteratorStateMachine(typeof(<RestartRecognizerCoroutine>d__6))]
private static IEnumerator RestartRecognizerCoroutine(VoiceControlListener inst)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <RestartRecognizerCoroutine>d__6(0)
{
inst = inst
};
}
[HarmonyPatch("restartsr")]
[HarmonyPrefix]
private static bool RestartSrPrefix(VoiceControlListener __instance, ref IEnumerator __result)
{
__result = CoRestartSr(__instance);
return false;
}
[IteratorStateMachine(typeof(<CoRestartSr>d__10))]
private static IEnumerator CoRestartSr(VoiceControlListener inst)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <CoRestartSr>d__10(0)
{
inst = inst
};
}
[HarmonyPatch("resetmic")]
[HarmonyPrefix]
private static bool ResetMicPrefix(VoiceControlListener __instance)
{
if (ResetMicCooldownField != null)
{
float num = (float)(ResetMicCooldownField.GetValue(__instance) ?? ((object)0f));
if (Time.time - num > 10f)
{
ResetMicCooldownField.SetValue(__instance, Time.time);
((MonoBehaviour)__instance).StartCoroutine(CoResetMicLong(__instance));
}
}
else
{
((MonoBehaviour)__instance).StartCoroutine(CoResetMicLong(__instance));
}
return false;
}
[HarmonyPatch("resetmiclong")]
[HarmonyPrefix]
private static bool ResetMicLongPrefix(VoiceControlListener __instance, ref IEnumerator __result)
{
__result = CoResetMicLong(__instance);
return false;
}
[IteratorStateMachine(typeof(<CoResetMicLong>d__13))]
private static IEnumerator CoResetMicLong(VoiceControlListener instance)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <CoResetMicLong>d__13(0)
{
instance = instance
};
}
private static void addSpellsToVocabulary(SpeechRecognizer recognizer)
{
foreach (KeyValuePair<string[], Action<VoiceControlListener>> item in spanishCommandMap)
{
string[] key = item.Key;
foreach (string text in key)
{
recognizer.Vocabulary.Add(text);
global::MageArenaSpanishVoiceMod.MageArenaSpanishVoiceMod.Log.LogInfo((object)("Adding " + text + " to vocabulary"));
}
}
foreach (KeyValuePair<string, string[]> item2 in spanishAdditionalCommandMap)
{
string[] value = item2.Value;
foreach (string text2 in value)
{
recognizer.Vocabulary.Add(text2);
global::MageArenaSpanishVoiceMod.MageArenaSpanishVoiceMod.Log.LogInfo((object)("Adding " + text2 + " to vocabulary"));
}
}
}
private static SpeechRecognizer GetOrBindSpeechRecognizer(VoiceControlListener inst)
{
FieldInfo fieldInfo = null;
FieldInfo fieldInfo2 = AccessTools.Field(((object)inst).GetType(), "sr");
if (fieldInfo2 != null && typeof(SpeechRecognizer).IsAssignableFrom(fieldInfo2.FieldType))
{
object? value = fieldInfo2.GetValue(inst);
SpeechRecognizer val = (SpeechRecognizer)((value is SpeechRecognizer) ? value : null);
if ((Object)(object)val != (Object)null)
{
return val;
}
fieldInfo = fieldInfo2;
}
SpeechRecognizer val2 = ((Component)inst).GetComponent<SpeechRecognizer>() ?? ((Component)inst).GetComponentInChildren<SpeechRecognizer>(true);
if ((Object)(object)val2 != (Object)null && fieldInfo != null)
{
fieldInfo.SetValue(inst, val2);
}
return val2;
}
private static VoiceBroadcastTrigger GetOrBindVbt(VoiceControlListener inst)
{
FieldInfo fieldInfo = null;
FieldInfo fieldInfo2 = AccessTools.Field(((object)inst).GetType(), "vbt");
if (fieldInfo2 != null && typeof(VoiceBroadcastTrigger).IsAssignableFrom(fieldInfo2.FieldType))
{
object? value = fieldInfo2.GetValue(inst);
VoiceBroadcastTrigger val = (VoiceBroadcastTrigger)((value is VoiceBroadcastTrigger) ? value : null);
if ((Object)(object)val != (Object)null)
{
return val;
}
fieldInfo = fieldInfo2;
}
VoiceBroadcastTrigger val2 = ((Component)inst).GetComponent<VoiceBroadcastTrigger>() ?? ((Component)inst).GetComponentInChildren<VoiceBroadcastTrigger>(true);
if ((Object)(object)val2 != (Object)null && fieldInfo != null)
{
fieldInfo.SetValue(inst, val2);
}
return val2;
}
}
}
namespace MageArenaSpanishVoiceMod
{
[BepInPlugin("spanish.mage.arena", "Spanish Mod", "1.1.2")]
public class MageArenaSpanishVoiceMod : BaseUnityPlugin
{
private static Harmony Harmony;
private ManualLogSource _log;
internal static MageArenaSpanishVoiceMod Instance { get; private set; }
internal static ManualLogSource Log => Instance._log;
private void Awake()
{
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Expected O, but got Unknown
_log = ((BaseUnityPlugin)this).Logger;
Instance = this;
Harmony = new Harmony("spanish.mage.arena");
Harmony.PatchAll();
Log.LogWarning((object)"Spanish Translation Loaded");
}
}
}