using System;
using System.Diagnostics;
using System.IO;
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 PluginConfig.API;
using PluginConfig.API.Decorators;
using PluginConfig.API.Fields;
using PluginConfig.API.Functionals;
using UnityEngine;
using UnityEngine.SceneManagement;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("bitmotte.MauriceBaller")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+7931b45fecc38a1ed8ee7b85671fb1f90c3f108a")]
[assembly: AssemblyProduct("Maurice Baller")]
[assembly: AssemblyTitle("bitmotte.MauriceBaller")]
[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 MauriceBaller
{
public static class AccessibleConfigs
{
public static bool CanBreakDeadMaurice = true;
public static float MauriceMass = 5f;
public static float MauriceFriction = 0.6f;
public static float MauriceBounciness = 0f;
public static bool CanRollKill = false;
}
public static class MauriceConfigurator
{
[CompilerGenerated]
private static class <>O
{
public static OnClick <0>__CleanDeadMaurices;
public static PostBoolValueChangeEvent <1>__ChangeAccessibleConfigBreakable;
public static PostFloatValueChangeEvent <2>__ChangeAccessibleConfigMass;
public static PostFloatValueChangeEvent <3>__ChangeAccessibleConfigBounciness;
public static PostBoolValueChangeEvent <4>__ChangeAccessibleConfigRollKill;
}
public static PluginConfigurator CreateConfigurator()
{
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
//IL_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_0077: Expected O, but got Unknown
//IL_0087: Unknown result type (might be due to invalid IL or missing references)
//IL_008e: Expected O, but got Unknown
//IL_0099: Unknown result type (might be due to invalid IL or missing references)
//IL_00a0: Expected O, but got Unknown
//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
//IL_00b8: Expected O, but got Unknown
//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
//IL_00d4: Expected O, but got Unknown
//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
//IL_00f0: Expected O, but got Unknown
//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
//IL_0104: Expected O, but got Unknown
//IL_0115: Unknown result type (might be due to invalid IL or missing references)
//IL_011c: Expected O, but got Unknown
//IL_012e: Unknown result type (might be due to invalid IL or missing references)
//IL_0133: Unknown result type (might be due to invalid IL or missing references)
//IL_0139: Expected O, but got Unknown
//IL_0151: Unknown result type (might be due to invalid IL or missing references)
//IL_0156: Unknown result type (might be due to invalid IL or missing references)
//IL_015c: Expected O, but got Unknown
//IL_0174: Unknown result type (might be due to invalid IL or missing references)
//IL_0179: Unknown result type (might be due to invalid IL or missing references)
//IL_017f: Expected O, but got Unknown
//IL_0197: Unknown result type (might be due to invalid IL or missing references)
//IL_019c: Unknown result type (might be due to invalid IL or missing references)
//IL_01a2: Expected O, but got Unknown
//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
//IL_01c5: Expected O, but got Unknown
PluginConfigurator val = PluginConfigurator.Create("Maurice Baller", "bitmotte.MauriceBaller");
Texture2D val2 = LoadPNG(GetPluginPath() + "/icon.png");
Sprite image = Sprite.Create(val2, new Rect(0f, 0f, (float)((Texture)val2).width, (float)((Texture)val2).height), new Vector2(0.5f, 0.5f), 100f);
val.image = image;
ConfigSpace val3 = new ConfigSpace(val.rootPanel, 15f);
ButtonField val4 = new ButtonField(val.rootPanel, "Clean up Maurice corpses", "clean_maurice");
ConfigSpace val5 = new ConfigSpace(val.rootPanel, 15f);
BoolField val6 = new BoolField(val.rootPanel, "Maurices can be broken", "can_break_dead_maurice", true);
FloatField val7 = new FloatField(val.rootPanel, "Maurice Mass", "maurice_mass", 5f);
FloatField val8 = new FloatField(val.rootPanel, "Maurice Bounciness", "maurice_bounciness", 0f);
ConfigHeader val9 = new ConfigHeader(val.rootPanel, "Cheats (Disable when playing campaign)", 24);
BoolField val10 = new BoolField(val.rootPanel, "Enemies can be MAURICED by rolling", "can_roll_kill", false);
object obj = <>O.<0>__CleanDeadMaurices;
if (obj == null)
{
OnClick val11 = CleanDeadMaurices;
<>O.<0>__CleanDeadMaurices = val11;
obj = (object)val11;
}
val4.onClick += (OnClick)obj;
object obj2 = <>O.<1>__ChangeAccessibleConfigBreakable;
if (obj2 == null)
{
PostBoolValueChangeEvent val12 = ChangeAccessibleConfigBreakable;
<>O.<1>__ChangeAccessibleConfigBreakable = val12;
obj2 = (object)val12;
}
val6.postValueChangeEvent += (PostBoolValueChangeEvent)obj2;
object obj3 = <>O.<2>__ChangeAccessibleConfigMass;
if (obj3 == null)
{
PostFloatValueChangeEvent val13 = ChangeAccessibleConfigMass;
<>O.<2>__ChangeAccessibleConfigMass = val13;
obj3 = (object)val13;
}
val7.postValueChangeEvent += (PostFloatValueChangeEvent)obj3;
object obj4 = <>O.<3>__ChangeAccessibleConfigBounciness;
if (obj4 == null)
{
PostFloatValueChangeEvent val14 = ChangeAccessibleConfigBounciness;
<>O.<3>__ChangeAccessibleConfigBounciness = val14;
obj4 = (object)val14;
}
val8.postValueChangeEvent += (PostFloatValueChangeEvent)obj4;
object obj5 = <>O.<4>__ChangeAccessibleConfigRollKill;
if (obj5 == null)
{
PostBoolValueChangeEvent val15 = ChangeAccessibleConfigRollKill;
<>O.<4>__ChangeAccessibleConfigRollKill = val15;
obj5 = (object)val15;
}
val10.postValueChangeEvent += (PostBoolValueChangeEvent)obj5;
val6.TriggerPostValueChangeEvent();
val7.TriggerPostValueChangeEvent();
val10.TriggerPostValueChangeEvent();
return val;
}
private static void ChangeAccessibleConfigBreakable(bool value)
{
AccessibleConfigs.CanBreakDeadMaurice = value;
}
private static void ChangeAccessibleConfigMass(float value)
{
AccessibleConfigs.MauriceMass = value;
for (int i = 0; i < SceneUtility.mauricePool.childCount; i++)
{
Rigidbody component = ((Component)SceneUtility.mauricePool.GetChild(i).GetChild(0)).gameObject.GetComponent<Rigidbody>();
component.mass = AccessibleConfigs.MauriceMass;
}
}
private static void ChangeAccessibleConfigBounciness(float value)
{
AccessibleConfigs.MauriceBounciness = value;
for (int i = 0; i < SceneUtility.mauricePool.childCount; i++)
{
PhysicMaterial material = ((Collider)((Component)SceneUtility.mauricePool.GetChild(i).GetChild(0)).gameObject.GetComponent<SphereCollider>()).material;
material.bounciness = AccessibleConfigs.MauriceBounciness;
}
}
private static void ChangeAccessibleConfigRollKill(bool value)
{
AccessibleConfigs.CanRollKill = value;
}
private static void CleanDeadMaurices()
{
for (int i = 0; i < SceneUtility.mauricePool.childCount; i++)
{
Object.Destroy((Object)(object)((Component)SceneUtility.mauricePool.GetChild(i)).gameObject);
}
}
public static Texture2D LoadPNG(string filePath)
{
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Expected O, but got Unknown
Texture2D val = null;
if (File.Exists(filePath))
{
byte[] array = File.ReadAllBytes(filePath);
val = new Texture2D(2, 2);
ImageConversion.LoadImage(val, array);
}
return val;
}
public static string GetPluginPath()
{
string codeBase = Assembly.GetExecutingAssembly().CodeBase;
UriBuilder uriBuilder = new UriBuilder(codeBase);
string path = Uri.UnescapeDataString(uriBuilder.Path);
return Path.GetDirectoryName(path);
}
}
[HarmonyPatch(typeof(SpiderBody), "Die")]
public class MauriceDeathPatch : MonoBehaviour
{
private static void Postfix(SpiderBody __instance)
{
//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)((Component)__instance).transform.parent.parent).name.Contains("Disgrace"))
{
Rigidbody componentInChildren = ((Component)__instance).GetComponentInChildren<Rigidbody>();
componentInChildren.constraints = (RigidbodyConstraints)0;
componentInChildren.isKinematic = false;
componentInChildren.collisionDetectionMode = (CollisionDetectionMode)2;
componentInChildren.interpolation = (RigidbodyInterpolation)1;
componentInChildren.mass = AccessibleConfigs.MauriceMass;
PhysicMaterial material = ((Collider)((Component)__instance).GetComponentInChildren<SphereCollider>()).material;
material.dynamicFriction = AccessibleConfigs.MauriceFriction;
material.staticFriction = AccessibleConfigs.MauriceFriction;
material.bounciness = AccessibleConfigs.MauriceBounciness;
((Component)__instance).gameObject.AddComponent<BallerInfo>();
((Component)__instance).transform.localRotation = Quaternion.Euler(15f, 0f, 0f);
((Component)__instance).transform.parent.parent = SceneUtility.mauricePool;
}
}
}
[HarmonyPatch(typeof(SpiderBody), "OnCollisionEnter")]
public class MauriceRubblePatch : MonoBehaviour
{
private static bool Prefix(SpiderBody __instance, Collision other)
{
//IL_009c: Unknown result type (might be due to invalid IL or missing references)
//IL_00a3: Expected O, but got Unknown
//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
//IL_010e: Unknown result type (might be due to invalid IL or missing references)
//IL_0124: Unknown result type (might be due to invalid IL or missing references)
//IL_0140: Unknown result type (might be due to invalid IL or missing references)
//IL_015a: Unknown result type (might be due to invalid IL or missing references)
//IL_015c: Unknown result type (might be due to invalid IL or missing references)
//IL_0179: Unknown result type (might be due to invalid IL or missing references)
//IL_0184: Unknown result type (might be due to invalid IL or missing references)
//IL_0195: Unknown result type (might be due to invalid IL or missing references)
//IL_0197: Unknown result type (might be due to invalid IL or missing references)
Traverse val = Traverse.Create((object)__instance);
bool flag = (bool)val.Field("falling").GetValue();
if (((Component)__instance).gameObject.GetComponent<BallerInfo>().hitGround)
{
return false;
}
if (!flag)
{
return false;
}
if (other.gameObject.CompareTag("Floor") || other.gameObject.CompareTag("Untagged"))
{
((Component)__instance).gameObject.GetComponent<BallerInfo>().hitGround = true;
GoreZone val2 = (GoreZone)val.Field("gz").GetValue();
Quaternion val3 = default(Quaternion);
((Quaternion)(ref val3)).eulerAngles = new Vector3(((ContactPoint)(ref other.contacts[0])).normal.x + 90f, ((ContactPoint)(ref other.contacts[0])).normal.y, ((ContactPoint)(ref other.contacts[0])).normal.z);
Vector3 val4 = default(Vector3);
((Vector3)(ref val4))..ctor(((ContactPoint)(ref other.contacts[0])).point.x, ((ContactPoint)(ref other.contacts[0])).point.y + 0.1f, ((ContactPoint)(ref other.contacts[0])).point.z);
AudioSource componentInChildren = Object.Instantiate<GameObject>(AddressablesExtensions.ToAsset(__instance.shockwave), val4, Quaternion.identity).GetComponentInChildren<AudioSource>();
Object.Instantiate<GameObject>(__instance.impactParticle, ((Component)__instance).transform.position, ((Component)__instance).transform.rotation);
Object.Instantiate<GameObject>(__instance.impactSprite, val4, val3).transform.SetParent(val2.goreZone, true);
Breakable val5 = default(Breakable);
if (other.gameObject.TryGetComponent<Breakable>(ref val5) && !val5.playerOnly && !val5.specialCaseOnly)
{
val5.Break();
}
}
return false;
}
}
[HarmonyPatch(typeof(SpiderBody), "FallKillEnemy")]
public class MauriceFriendlyFirePatch : MonoBehaviour
{
private static bool Prefix(SpiderBody __instance)
{
BallerInfo component = ((Component)__instance).gameObject.GetComponent<BallerInfo>();
if (AccessibleConfigs.CanRollKill)
{
return true;
}
if (component.hitGround)
{
return false;
}
return true;
}
}
[HarmonyPatch(typeof(SpiderBody), "BreakCorpse")]
public class MauriceRubbleBreakPatch : MonoBehaviour
{
private static bool Prefix()
{
if (AccessibleConfigs.CanBreakDeadMaurice)
{
return true;
}
return false;
}
}
[HarmonyPatch(typeof(Bloodsplatter), "Awake")]
public class BloodsplatterNoDeadMauricePatch : MonoBehaviour
{
private static void Postfix(Bloodsplatter __instance)
{
((Component)__instance).gameObject.AddComponent<DontSplattermaurice>();
}
}
public class BallerInfo : MonoBehaviour
{
public bool hitGround = false;
public GameObject cgParent;
}
public class DontSplattermaurice : MonoBehaviour
{
private void Update()
{
if ((Object)(object)((Component)this).gameObject.transform.parent.parent != (Object)null)
{
if (((Object)((Component)this).gameObject.transform.parent.parent).name.Contains("Spider") && (Object)(object)((Component)this).gameObject != (Object)null)
{
Object.Destroy((Object)(object)((Component)this).gameObject);
}
((Behaviour)this).enabled = false;
}
}
}
[BepInPlugin("bitmotte.MauriceBaller", "Maurice Baller", "1.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Plugin : BaseUnityPlugin
{
internal static ManualLogSource Logger;
public static PluginConfigurator config;
private void Awake()
{
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Expected O, but got Unknown
Logger = ((BaseUnityPlugin)this).Logger;
Logger.LogInfo((object)"Plugin bitmotte.MauriceBaller is loaded!");
Harmony val = new Harmony("bitmotte.MauriceBaller");
val.PatchAll();
config = MauriceConfigurator.CreateConfigurator();
SceneManager.sceneLoaded += SceneUtility.OnSceneLoad;
}
}
public static class SceneUtility
{
public static string sceneName;
public static Transform mauricePool = new GameObject("tmp").transform;
public static Transform cgArena;
public static void OnSceneLoad(Scene scene, LoadSceneMode mode)
{
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
sceneName = ((Scene)(ref scene)).name;
mauricePool = new GameObject("MauricePool").transform;
mauricePool.parent = null;
if (!(sceneName != "9240e656c89994d44b21940f65ab57da"))
{
cgArena = GameObject.Find("Everything").transform.GetChild(2);
}
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "bitmotte.MauriceBaller";
public const string PLUGIN_NAME = "Maurice Baller";
public const string PLUGIN_VERSION = "1.0.0";
}
}