using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.Events;
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("OopsAllMaurices")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("OopsAllMaurices")]
[assembly: AssemblyTitle("OopsAllMaurices")]
[assembly: AssemblyVersion("1.0.0.0")]
[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 OopsAllMaurices
{
[BepInPlugin("com.yourname.oopsallmaurices", "Oops All Maurices", "1.0.0")]
public class MainPlugin : BaseUnityPlugin
{
public static ManualLogSource Log;
private void Awake()
{
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Expected O, but got Unknown
Log = ((BaseUnityPlugin)this).Logger;
Log.LogInfo((object)"Oops All Maurices mod loaded!");
Harmony val = new Harmony("com.yourname.oopsallmaurices");
val.PatchAll();
}
}
[HarmonyPatch(typeof(EnemyIdentifier), "Start")]
public class EnemyReplacerPatch
{
private static bool isReplacing;
private static GameObject cachedMauricePrefab;
private static void Postfix(EnemyIdentifier __instance)
{
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Invalid comparison between Unknown and I4
//IL_0091: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: Unknown result type (might be due to invalid IL or missing references)
//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
//IL_00b2: 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_00ed: Unknown result type (might be due to invalid IL or missing references)
//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
//IL_021b: Unknown result type (might be due to invalid IL or missing references)
//IL_0265: Unknown result type (might be due to invalid IL or missing references)
//IL_026f: Expected O, but got Unknown
if (isReplacing || (Object)(object)__instance == (Object)null || (int)__instance.enemyType == 4)
{
return;
}
if ((Object)(object)cachedMauricePrefab == (Object)null)
{
cachedMauricePrefab = FindMauricePrefab();
}
if (!((Object)(object)cachedMauricePrefab != (Object)null))
{
return;
}
isReplacing = true;
Vector3 position = ((Component)__instance).transform.position;
Quaternion rotation = ((Component)__instance).transform.rotation;
RaycastHit val = default(RaycastHit);
if (Physics.Raycast(position, Vector3.up, ref val, 6f))
{
position.y = ((RaycastHit)(ref val)).point.y - 3f;
}
GameObject newMaurice = Object.Instantiate<GameObject>(cachedMauricePrefab, position, rotation);
Renderer[] componentsInChildren = ((Component)__instance).GetComponentsInChildren<Renderer>();
foreach (Renderer val2 in componentsInChildren)
{
val2.enabled = false;
}
Component[] componentsInChildren2 = ((Component)__instance).GetComponentsInChildren<Component>();
foreach (Component val3 in componentsInChildren2)
{
if ((Object)(object)val3 != (Object)null && ((object)val3).GetType().Name == "AudioSource")
{
Behaviour val4 = (Behaviour)(object)((val3 is Behaviour) ? val3 : null);
if (val4 != null)
{
val4.enabled = false;
}
}
}
Collider[] componentsInChildren3 = ((Component)__instance).GetComponentsInChildren<Collider>();
foreach (Collider val5 in componentsInChildren3)
{
val5.enabled = false;
}
Rigidbody component = ((Component)__instance).GetComponent<Rigidbody>();
if ((Object)(object)component != (Object)null)
{
component.isKinematic = true;
component.useGravity = false;
component.velocity = Vector3.zero;
}
__instance.dead = true;
EnemyIdentifier component2 = newMaurice.GetComponent<EnemyIdentifier>();
if ((Object)(object)component2 != (Object)null)
{
component2.onDeath.AddListener((UnityAction)delegate
{
if ((Object)(object)__instance != (Object)null)
{
__instance.dead = false;
__instance.InstaKill();
}
DisableCorpseHitboxes(newMaurice);
});
}
isReplacing = false;
}
private static void DisableCorpseHitboxes(GameObject mauriceGo)
{
if ((Object)(object)mauriceGo == (Object)null)
{
return;
}
Collider[] componentsInChildren = mauriceGo.GetComponentsInChildren<Collider>();
foreach (Collider val in componentsInChildren)
{
if ((Object)(object)val != (Object)null)
{
val.enabled = false;
}
}
}
private static GameObject FindMauricePrefab()
{
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: Invalid comparison between Unknown and I4
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
//IL_0097: Unknown result type (might be due to invalid IL or missing references)
//IL_009d: Invalid comparison between Unknown and I4
//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
EnemyIdentifier[] array = Object.FindObjectsOfType<EnemyIdentifier>();
EnemyIdentifier[] array2 = array;
foreach (EnemyIdentifier val in array2)
{
if ((Object)(object)val != (Object)null && (int)val.enemyType == 4 && (Object)(object)((Component)val).gameObject != (Object)null)
{
Scene scene = ((Component)val).gameObject.scene;
if (((Scene)(ref scene)).IsValid())
{
return ((Component)val).gameObject;
}
}
}
EnemyIdentifier[] array3 = Resources.FindObjectsOfTypeAll<EnemyIdentifier>();
EnemyIdentifier[] array4 = array3;
foreach (EnemyIdentifier val2 in array4)
{
if ((Object)(object)val2 != (Object)null && (int)val2.enemyType == 4 && (Object)(object)((Component)val2).gameObject != (Object)null)
{
Scene scene2 = ((Component)val2).gameObject.scene;
if (!((Scene)(ref scene2)).IsValid())
{
return ((Component)val2).gameObject;
}
}
}
return null;
}
}
}