using System;
using System.Diagnostics;
using System.Reflection;
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;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("Template description")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[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 MBF
{
internal class Patches
{
[HarmonyPatch(typeof(ConsoleScript))]
internal static class ConsolePatch
{
[HarmonyPatch("Start")]
[HarmonyPostfix]
private static void StartPatch()
{
ConsoleScript.instance.LogToConsole("Loaded Mae's Bug Fixes (v0.1.0)");
}
}
internal static void Log(string str)
{
ConsoleScript.instance.LogToConsole(str);
}
}
internal static class BodyPatches
{
[HarmonyPatch(typeof(Body), "DropItem", new Type[] { typeof(Item) })]
internal static class BodyDropItem
{
[HarmonyPostfix]
private static void Postfix(Body __instance, Item item)
{
if (item.Stats.wearable)
{
__instance.DropWearable(item);
}
}
}
[HarmonyPatch(typeof(Body))]
internal static class BodyNoclip
{
[HarmonyPatch("FixedUpdate")]
[HarmonyPostfix]
private static void BodyUpdate(Body __instance)
{
if (!__instance.standing && ConsoleScript.instance.noClip)
{
__instance.Stand(true);
}
}
[HarmonyPatch("Ragdoll")]
[HarmonyPrefix]
private static bool RagdollPrefix()
{
return !ConsoleScript.instance.noClip;
}
[HarmonyPatch(/*Could not decode attribute arguments.*/)]
[HarmonyPostfix]
private static void PlacePostfix(Body __instance, ref bool __result)
{
if (!__result)
{
__result = ConsoleScript.instance.noClip;
}
}
}
}
internal static class GunJamPatch
{
[HarmonyPatch(typeof(GunScript), "JamChance")]
internal static class GunJam
{
[HarmonyPrefix]
private static bool Prefix(GunScript __instance, ref float __result)
{
float num = ((!(__instance.it.condition > 0.5f)) ? Body.Remap(__instance.it.condition, 0f, 0.5f, 0.1f, 0.0025f) : Body.Remap(__instance.it.condition, 0.5f, 1f, 0.0025f, 0f));
if (__instance.it.isWet)
{
num += 0.045f;
}
__result = num;
return false;
}
}
}
internal static class RagdollPatch
{
[HarmonyPatch(typeof(JumpPadScript), "OnCollisionEnter2D")]
internal static class JumpPadCollide
{
[HarmonyPrefix]
private static bool Prefix(JumpPadScript __instance, Collision2D collision)
{
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
//IL_0161: Unknown result type (might be due to invalid IL or missing references)
//IL_016b: Unknown result type (might be due to invalid IL or missing references)
//IL_0182: Unknown result type (might be due to invalid IL or missing references)
//IL_0187: Unknown result type (might be due to invalid IL or missing references)
//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
//IL_0107: Unknown result type (might be due to invalid IL or missing references)
//IL_010c: Unknown result type (might be due to invalid IL or missing references)
if (__instance.disabled || !(__instance.cooldown <= 0f) || !Object.op_Implicit((Object)(object)collision.rigidbody) || collision.rigidbody.isKinematic)
{
return false;
}
GameObject gameObject = collision.gameObject;
ContactPoint2D contact = collision.GetContact(0);
Limb val = Body.LimbFromObject(gameObject, ((ContactPoint2D)(ref contact)).point);
if (Object.op_Implicit((Object)(object)val) && __instance.cooldown <= 0f)
{
val.body.Ragdoll();
__instance.light.intensity = 1f;
Limb[] limbs = val.body.limbs;
Limb[] array = limbs;
foreach (Limb val2 in array)
{
val2.rb.velocity = new Vector2(val2.rb.velocity.x, 65f);
}
val.body.Scream();
Sound.Play("jumppad", Vector2.op_Implicit(((Component)__instance).transform.position), false, true, (Transform)null, 1f, 1f, false, false);
__instance.cooldown = 15f;
PlayerCamera.main.shaker.Shake(70f);
}
else
{
__instance.light.intensity = 1f;
collision.rigidbody.AddForce(Vector2.up * 350f, (ForceMode2D)1);
Sound.Play("jumppad", Vector2.op_Implicit(((Component)__instance).transform.position), false, true, (Transform)null, 1f, 1f, false, false);
__instance.cooldown = 15f;
}
return false;
}
}
[HarmonyPatch(typeof(BarbedFence), "OnTriggerEnter2D")]
internal static class WireCollide
{
[HarmonyPrefix]
private static bool Prefix(BarbedFence __instance, Collider2D collision)
{
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
Body val = default(Body);
if (((Component)collision).TryGetComponent<Body>(ref val) && __instance.soundPlayCooldown <= 0f)
{
val.Ragdoll();
BarbedFenceCut(__instance, Body.LimbFromObject(((Component)val).gameObject, Vector2.op_Implicit(((Component)__instance).transform.position)));
}
Limb limb = default(Limb);
if (((Component)collision).TryGetComponent<Limb>(ref limb))
{
BarbedFenceCut(__instance, limb);
}
return false;
}
}
[HarmonyPatch(typeof(CoilScript), "OnCollisionEnter2D")]
internal static class CoilCollide
{
[HarmonyPrefix]
private static bool CoilScriptCollide(CoilScript __instance, Collision2D collision)
{
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
if (__instance.cooldown <= 0f)
{
GameObject gameObject = collision.gameObject;
ContactPoint2D contact = collision.GetContact(0);
Limb val = Body.LimbFromObject(gameObject, ((ContactPoint2D)(ref contact)).point);
if (Object.op_Implicit((Object)(object)val))
{
__instance.Shock(val);
}
}
return false;
}
}
private static void BarbedFenceCut(BarbedFence __instance, Limb limb)
{
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
if (__instance.soundPlayCooldown <= 0f)
{
__instance.soundPlayCooldown = 10f;
Sound.Play("fence", Vector2.op_Implicit(((Component)__instance).transform.position), false, true, (Transform)null, 1f, 1f, false, false);
}
limb.skinHealth -= Random.Range(10f, 25f) / limb.GetArmorReduction();
limb.bleedAmount += Random.Range(1f, 3f) / limb.GetArmorReduction();
limb.pain += Random.Range(20f, 60f) / limb.GetArmorReduction();
limb.DamageWearables(0.2f);
limb.body.Scream();
((Component)__instance).GetComponent<SpriteRenderer>().sprite = __instance.hitSprite;
}
}
[BepInPlugin("com.mayzmae.MBF", "Mae's Bug Fixes", "0.1.0")]
public class Plugin : BaseUnityPlugin
{
public const string ModGUID = "com.mayzmae.MBF";
public const string ModName = "Mae's Bug Fixes";
public const string ModVersion = "0.1.0";
internal static ManualLogSource Logger;
private readonly Harmony _harmony = new Harmony("com.mayzmae.MBF");
public static Plugin Instance { get; private set; }
private void Awake()
{
Logger = ((BaseUnityPlugin)this).Logger;
Instance = this;
_harmony.PatchAll(Assembly.GetExecutingAssembly());
Logger.LogInfo((object)"Loaded Mae's Bug Fixes v0.1.0");
}
private void OnDestroy()
{
Harmony harmony = _harmony;
if (harmony != null)
{
harmony.UnpatchSelf();
}
Instance = null;
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "MBF";
public const string PLUGIN_NAME = "Template description";
public const string PLUGIN_VERSION = "1.0.0";
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}