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 GameNetcodeStuff;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using qwcanNutcracker;
using qwcannutcracker.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("qwcan")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.3.0")]
[assembly: AssemblyInformationalVersion("1.0.3-alpha.0.10+47cf4555e83a12084a38a3284a49c2ff95f24d5f")]
[assembly: AssemblyProduct("NutcrackerPatch")]
[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 qwcanNutcracker
{
[BepInPlugin("NutcrackerDontKickWhenNotAggrod", "NutcrackerDontKickWhenNotAggrod", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
private readonly Harmony _harmony = new Harmony("NutcrackerDontKickWhenNotAggrod");
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(NutcrackerPatch));
}
}
public static class PluginInfo
{
public const string PLUGIN_GUID = "Template";
public const string PLUGIN_NAME = "NutcrackerPatch";
public const string PLUGIN_VERSION = "1.0.0";
}
}
namespace qwcannutcracker.patch
{
[HarmonyPatch(typeof(NutcrackerEnemyAI))]
public class NutcrackerPatch
{
[CompilerGenerated]
private sealed class <Transpiler>d__0 : 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 ILGenerator il;
public ILGenerator <>3__il;
private List<CodeInstruction> <code>5__2;
private FieldInfo <timeSinceHittingPlayerField>5__3;
private Label <kickLabel>5__4;
private int <i>5__5;
private CodeInstruction <instr>5__6;
CodeInstruction IEnumerator<CodeInstruction>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <Transpiler>d__0(int <>1__state)
{
this.<>1__state = <>1__state;
<>l__initialThreadId = Environment.CurrentManagedThreadId;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<code>5__2 = null;
<timeSinceHittingPlayerField>5__3 = null;
<instr>5__6 = null;
<>1__state = -2;
}
private bool MoveNext()
{
//IL_017d: Unknown result type (might be due to invalid IL or missing references)
//IL_0187: Expected O, but got Unknown
//IL_019e: Unknown result type (might be due to invalid IL or missing references)
//IL_01a8: Expected O, but got Unknown
//IL_01c9: Unknown result type (might be due to invalid IL or missing references)
//IL_01d3: Expected O, but got Unknown
//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
//IL_0209: Expected O, but got Unknown
//IL_0224: Unknown result type (might be due to invalid IL or missing references)
//IL_022e: Expected O, but got Unknown
//IL_026c: Unknown result type (might be due to invalid IL or missing references)
//IL_0276: Expected O, but got Unknown
//IL_028d: Unknown result type (might be due to invalid IL or missing references)
//IL_0297: Expected O, but got Unknown
//IL_02af: Unknown result type (might be due to invalid IL or missing references)
//IL_02b9: Expected O, but got Unknown
//IL_02e4: Unknown result type (might be due to invalid IL or missing references)
//IL_02ee: Expected O, but got Unknown
//IL_0306: Unknown result type (might be due to invalid IL or missing references)
//IL_0310: Expected O, but got Unknown
//IL_0328: Unknown result type (might be due to invalid IL or missing references)
//IL_0332: Expected O, but got Unknown
//IL_035f: Unknown result type (might be due to invalid IL or missing references)
//IL_0369: Expected O, but got Unknown
//IL_0381: Unknown result type (might be due to invalid IL or missing references)
//IL_038b: Expected O, but got Unknown
//IL_0149: Unknown result type (might be due to invalid IL or missing references)
//IL_0153: Expected O, but got Unknown
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
Plugin.Log.LogInfo((object)"Patching NutcrackerEnemyAI");
<code>5__2 = new List<CodeInstruction>(instructions);
<timeSinceHittingPlayerField>5__3 = AccessTools.Field(typeof(NutcrackerEnemyAI), "timeSinceHittingPlayer");
Plugin.Log.LogInfo((object)$"Found timeSinceHittingPlayer field: {<timeSinceHittingPlayerField>5__3}");
<kickLabel>5__4 = il.DefineLabel();
<i>5__5 = 0;
break;
case 1:
<>1__state = -1;
if (CodeInstructionExtensions.StoresField(<instr>5__6, <timeSinceHittingPlayerField>5__3))
{
Plugin.Log.LogInfo((object)"Found timeSinceHittingPlayer ldfld, inserting code");
<code>5__2[<i>5__5 + 1].labels.Add(<kickLabel>5__4);
<>2__current = new CodeInstruction(OpCodes.Ldarg_0, (object)null);
<>1__state = 2;
return true;
}
goto IL_039c;
case 2:
<>1__state = -1;
<>2__current = new CodeInstruction(OpCodes.Ldfld, (object)AccessTools.Field(typeof(EnemyAI), "currentBehaviourStateIndex"));
<>1__state = 3;
return true;
case 3:
<>1__state = -1;
<>2__current = new CodeInstruction(OpCodes.Ldc_I4_2, (object)null);
<>1__state = 4;
return true;
case 4:
<>1__state = -1;
<>2__current = new CodeInstruction(OpCodes.Beq_S, (object)<kickLabel>5__4);
<>1__state = 5;
return true;
case 5:
<>1__state = -1;
<>2__current = new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(Plugin), "get_Log", (Type[])null, (Type[])null));
<>1__state = 6;
return true;
case 6:
<>1__state = -1;
<>2__current = new CodeInstruction(OpCodes.Ldstr, (object)"Starting aggro (touched while wandering)");
<>1__state = 7;
return true;
case 7:
<>1__state = -1;
<>2__current = new CodeInstruction(OpCodes.Callvirt, (object)AccessTools.Method(typeof(ManualLogSource), "LogInfo", new Type[1] { typeof(object) }, (Type[])null));
<>1__state = 8;
return true;
case 8:
<>1__state = -1;
<>2__current = new CodeInstruction(OpCodes.Ldarg_0, (object)null);
<>1__state = 9;
return true;
case 9:
<>1__state = -1;
<>2__current = new CodeInstruction(OpCodes.Ldloc_0, (object)null);
<>1__state = 10;
return true;
case 10:
<>1__state = -1;
<>2__current = new CodeInstruction(OpCodes.Ldfld, (object)AccessTools.Field(typeof(PlayerControllerB), "playerClientId"));
<>1__state = 11;
return true;
case 11:
<>1__state = -1;
<>2__current = new CodeInstruction(OpCodes.Conv_I4, (object)null);
<>1__state = 12;
return true;
case 12:
<>1__state = -1;
<>2__current = new CodeInstruction(OpCodes.Ldc_I4_1, (object)null);
<>1__state = 13;
return true;
case 13:
<>1__state = -1;
<>2__current = new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(NutcrackerEnemyAI), "SeeMovingThreatServerRpc", (Type[])null, (Type[])null));
<>1__state = 14;
return true;
case 14:
<>1__state = -1;
<>2__current = new CodeInstruction(OpCodes.Ret, (object)null);
<>1__state = 15;
return true;
case 15:
{
<>1__state = -1;
goto IL_039c;
}
IL_039c:
<instr>5__6 = null;
<i>5__5++;
break;
}
if (<i>5__5 < <code>5__2.Count)
{
<instr>5__6 = <code>5__2[<i>5__5];
<>2__current = <instr>5__6;
<>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__0 <Transpiler>d__;
if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId)
{
<>1__state = 0;
<Transpiler>d__ = this;
}
else
{
<Transpiler>d__ = new <Transpiler>d__0(0);
}
<Transpiler>d__.instructions = <>3__instructions;
<Transpiler>d__.il = <>3__il;
return <Transpiler>d__;
}
[DebuggerHidden]
IEnumerator IEnumerable.GetEnumerator()
{
return ((IEnumerable<CodeInstruction>)this).GetEnumerator();
}
}
[IteratorStateMachine(typeof(<Transpiler>d__0))]
[HarmonyPatch("OnCollideWithPlayer")]
[HarmonyTranspiler]
private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator il)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <Transpiler>d__0(-2)
{
<>3__instructions = instructions,
<>3__il = il
};
}
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}