using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using LC_API.BundleAPI;
using Microsoft.CodeAnalysis;
using Mono.Cecil.Cil;
using MonoMod.Cil;
using MonoMod.RuntimeDetour;
using UnityEngine;
[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: AssemblyCompany("MetalPipe")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("MetalPipe")]
[assembly: AssemblyTitle("MetalPipe")]
[assembly: AssemblyVersion("1.0.0.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.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
internal sealed class NullableAttribute : Attribute
{
public readonly byte[] NullableFlags;
public NullableAttribute(byte P_0)
{
NullableFlags = new byte[1] { P_0 };
}
public NullableAttribute(byte[] P_0)
{
NullableFlags = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
internal sealed class NullableContextAttribute : Attribute
{
public readonly byte Flag;
public NullableContextAttribute(byte P_0)
{
Flag = P_0;
}
}
[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 MetalPipe
{
[BepInPlugin("Isbjorn52.MetalPipe", "Metal Pipe", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
[CompilerGenerated]
private static class <>O
{
public static Manipulator <0>__IL_Shovel_Hit;
}
public void Awake()
{
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_0063: Unknown result type (might be due to invalid IL or missing references)
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
//IL_0063: Expected O, but got Unknown
//IL_0099: Unknown result type (might be due to invalid IL or missing references)
//IL_008e: Unknown result type (might be due to invalid IL or missing references)
//IL_0093: Unknown result type (might be due to invalid IL or missing references)
//IL_0099: Expected O, but got Unknown
BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;
new Hook((MethodBase)typeof(Shovel).GetMethod("Start", bindingAttr), typeof(Plugin).GetMethod("Shovel_Start"));
MethodInfo? method = typeof(Shovel).GetMethod("HitShovelClientRpc", bindingAttr);
object obj = <>O.<0>__IL_Shovel_Hit;
if (obj == null)
{
Manipulator val = IL_Shovel_Hit;
<>O.<0>__IL_Shovel_Hit = val;
obj = (object)val;
}
new ILHook((MethodBase)method, (Manipulator)obj);
MethodInfo? method2 = typeof(Shovel).GetMethod("HitShovel", bindingAttr);
object obj2 = <>O.<0>__IL_Shovel_Hit;
if (obj2 == null)
{
Manipulator val2 = IL_Shovel_Hit;
<>O.<0>__IL_Shovel_Hit = val2;
obj2 = (object)val2;
}
new ILHook((MethodBase)method2, (Manipulator)obj2);
}
public static void IL_Shovel_Hit(ILContext il)
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: Expected O, but got Unknown
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
ILCursor val = new ILCursor(il);
val.GotoNext(new Func<Instruction, bool>[1]
{
(Instruction x) => ILPatternMatchingExt.MatchCall<RoundManager>(x, "PlayRandomClip")
});
val.Index -= 7;
float maxDistance = 1f;
val.Emit(OpCodes.Ldarg_0);
val.EmitDelegate<Action<Shovel>>((Action<Shovel>)delegate(Shovel self)
{
maxDistance = self.shovelAudio.maxDistance;
self.shovelAudio.maxDistance = 50f;
});
val.GotoNext(new Func<Instruction, bool>[1]
{
(Instruction x) => ILPatternMatchingExt.MatchCall<RoundManager>(x, "PlayRandomClip")
});
val.Index += 2;
val.Emit(OpCodes.Ldarg_0);
val.EmitDelegate<Action<Shovel>>((Action<Shovel>)delegate(Shovel self)
{
self.shovelAudio.maxDistance = maxDistance;
});
}
public static void Shovel_Start(Action<Shovel> orig, Shovel self)
{
orig(self);
if ((Object)(object)((Component)self).transform.Find("mesh") != (Object)null)
{
self.hitSFX = (AudioClip[])(object)new AudioClip[1] { BundleLoader.GetLoadedAsset<AudioClip>("Assets/MetalPipe.mp3") };
Material material = ((Renderer)((Component)((Component)self).transform.Find("mesh")).GetComponent<MeshRenderer>()).materials[0];
Object.Destroy((Object)(object)((Component)((Component)self).transform.Find("mesh")).gameObject);
GameObject val = Object.Instantiate<GameObject>(BundleLoader.GetLoadedAsset<GameObject>("Assets/MetalPipe.prefab"), ((Component)self).transform);
((Renderer)val.GetComponentInChildren<MeshRenderer>()).material = material;
}
}
}
}