using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Reflection.Emit;
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 UnityEngine;
using qwcan.patch;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("")]
[assembly: AssemblyCompany("Template")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.3.0")]
[assembly: AssemblyInformationalVersion("1.0.3-alpha.0.8+a1ccc2c16122cc6702a54ed79c3187eed19a4d4c")]
[assembly: AssemblyProduct("Template")]
[assembly: AssemblyTitle("Template")]
[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 qwcan
{
[BepInPlugin("OldBirdAudioRpcPatch", "OldBirdAudioRpcPatch", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
private readonly Harmony _harmony = new Harmony("OldBirdAudioRpcPatch");
public static Plugin Instance { get; set; }
public static ManualLogSource Log => ((BaseUnityPlugin)Instance).Logger;
public Plugin()
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Expected O, but got Unknown
Instance = this;
}
private void Awake()
{
Log.LogInfo((object)"Applying patches...");
ApplyPluginPatch();
Log.LogInfo((object)"Patches applied");
}
private void ApplyPluginPatch()
{
_harmony.PatchAll(typeof(RadMechPatch));
}
}
public static class PluginInfo
{
public const string PLUGIN_GUID = "Template";
public const string PLUGIN_NAME = "Template";
public const string PLUGIN_VERSION = "1.0.0";
}
}
namespace qwcan.patch
{
[HarmonyPatch(typeof(RadMechAI))]
public class RadMechPatch
{
[CompilerGenerated]
private sealed class <Transpiler>d__1 : IEnumerable<CodeInstruction>, IEnumerable, IEnumerator<CodeInstruction>, IEnumerator, IDisposable
{
private int <>1__state;
private CodeInstruction <>2__current;
private int <>l__initialThreadId;
private IEnumerable<CodeInstruction> instructions;
public IEnumerable<CodeInstruction> <>3__instructions;
private List<CodeInstruction> <code>5__2;
private FieldInfo <alertTimerField>5__3;
private int <i>5__4;
private CodeInstruction <instr>5__5;
CodeInstruction IEnumerator<CodeInstruction>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <Transpiler>d__1(int <>1__state)
{
this.<>1__state = <>1__state;
<>l__initialThreadId = Environment.CurrentManagedThreadId;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<code>5__2 = null;
<alertTimerField>5__3 = null;
<instr>5__5 = null;
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0106: Unknown result type (might be due to invalid IL or missing references)
//IL_0110: Expected O, but got Unknown
//IL_014e: Unknown result type (might be due to invalid IL or missing references)
//IL_0158: Expected O, but got Unknown
//IL_017e: Unknown result type (might be due to invalid IL or missing references)
//IL_0188: Expected O, but got Unknown
//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
//IL_01bc: Expected O, but got Unknown
//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
//IL_01f2: Expected O, but got Unknown
//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
//IL_00eb: Expected O, but got Unknown
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
Plugin.Log.LogInfo((object)"Patching SetMechAlertedClientRpc");
<code>5__2 = new List<CodeInstruction>(instructions);
<alertTimerField>5__3 = AccessTools.Field(typeof(RadMechAI), "alertTimer");
<i>5__4 = 0;
break;
case 1:
<>1__state = -1;
if (CodeInstructionExtensions.StoresField(<instr>5__5, <alertTimerField>5__3))
{
<>2__current = new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(Plugin), "get_Log", (Type[])null, (Type[])null));
<>1__state = 2;
return true;
}
goto IL_0202;
case 2:
<>1__state = -1;
<>2__current = new CodeInstruction(OpCodes.Ldstr, (object)"Calling LocalLRADAudio.Play()");
<>1__state = 3;
return true;
case 3:
<>1__state = -1;
<>2__current = new CodeInstruction(OpCodes.Callvirt, (object)AccessTools.Method(typeof(ManualLogSource), "LogInfo", new Type[1] { typeof(object) }, (Type[])null));
<>1__state = 4;
return true;
case 4:
<>1__state = -1;
Plugin.Log.LogInfo((object)"Found alertTimer ldfld, inserting call to LocalLRADAudio.Play()");
<>2__current = new CodeInstruction(OpCodes.Ldarg_0, (object)null);
<>1__state = 5;
return true;
case 5:
<>1__state = -1;
<>2__current = new CodeInstruction(OpCodes.Ldfld, (object)AccessTools.Field(typeof(RadMechAI), "LocalLRADAudio"));
<>1__state = 6;
return true;
case 6:
<>1__state = -1;
<>2__current = new CodeInstruction(OpCodes.Callvirt, (object)AccessTools.Method(typeof(AudioSource), "Play", (Type[])null, (Type[])null));
<>1__state = 7;
return true;
case 7:
{
<>1__state = -1;
goto IL_0202;
}
IL_0202:
<instr>5__5 = null;
<i>5__4++;
break;
}
if (<i>5__4 < <code>5__2.Count)
{
<instr>5__5 = <code>5__2[<i>5__4];
<>2__current = <instr>5__5;
<>1__state = 1;
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();
}
[DebuggerHidden]
IEnumerator<CodeInstruction> IEnumerable<CodeInstruction>.GetEnumerator()
{
<Transpiler>d__1 <Transpiler>d__;
if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId)
{
<>1__state = 0;
<Transpiler>d__ = this;
}
else
{
<Transpiler>d__ = new <Transpiler>d__1(0);
}
<Transpiler>d__.instructions = <>3__instructions;
return <Transpiler>d__;
}
[DebuggerHidden]
IEnumerator IEnumerable.GetEnumerator()
{
return ((IEnumerable<CodeInstruction>)this).GetEnumerator();
}
}
[HarmonyPatch("SetMechAlertedToThreat")]
[HarmonyPrefix]
private static void OnSetMechAlertedToThreat(ref RadMechAI __instance, object[] __args)
{
Plugin.Log.LogInfo((object)"Sending ClientRPC");
if (!__instance.isAlerted)
{
__instance.SetMechAlertedClientRpc();
}
}
[IteratorStateMachine(typeof(<Transpiler>d__1))]
[HarmonyPatch("SetMechAlertedClientRpc")]
[HarmonyTranspiler]
private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <Transpiler>d__1(-2)
{
<>3__instructions = instructions
};
}
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}