using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
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.Fields;
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: IgnoresAccessChecksTo("")]
[assembly: AssemblyCompany("DcSchizo")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("DcSchizo")]
[assembly: AssemblyTitle("DcSchizo")]
[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.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 DcSchizo
{
[BepInPlugin("DcSchizo", "DcSchizo", "1.0.0")]
public class DcSchizo : BaseUnityPlugin
{
public static List<object> ActiveList = new List<object>();
public static Dictionary<GameObject, object> DcInfo = new Dictionary<GameObject, object>();
public static Dictionary<object, GameObject[]> DcWave = new Dictionary<object, GameObject[]>();
public static Dictionary<GameObject, List<GameObject>> DcDead = new Dictionary<GameObject, List<GameObject>>();
private static bool Loaded = false;
public static bool Hard = false;
public static bool DebugMode = false;
private PluginConfigurator config;
public static DcSchizo Instance { get; private set; } = null;
internal static ManualLogSource Logger { get; private set; } = null;
internal static Harmony? Harmony { get; set; }
private void Awake()
{
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
//IL_0045: Expected O, but got Unknown
//IL_005b: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: Expected O, but got Unknown
//IL_0077: Unknown result type (might be due to invalid IL or missing references)
//IL_007d: Expected O, but got Unknown
//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
//IL_00c2: Expected O, but got Unknown
//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
//IL_00d5: Expected O, but got Unknown
//IL_00de: Unknown result type (might be due to invalid IL or missing references)
//IL_00e8: Expected O, but got Unknown
Logger = ((BaseUnityPlugin)this).Logger;
Instance = this;
config = PluginConfigurator.Create("DcSchizo", "DcSchizo");
BoolField val = new BoolField(config.rootPanel, "Debug", "SchizoDeathCatcherDebug", false);
BoolField val2 = new BoolField(config.rootPanel, "HardMode Softlock", "SchizoDeathCatcherSoftlock", false);
BoolField val3 = new BoolField(config.rootPanel, "HardMode", "SchizoDeathCatcherHardMode", false);
val.defaultValue = false;
val2.defaultValue = false;
val3.defaultValue = false;
DebugMode = val.value;
val2.value = false;
Hard = val3.value;
val.onValueChange += new BoolValueChangeEventDelegate(UpdateDebug);
val2.onValueChange += new BoolValueChangeEventDelegate(UpdateSoftlock);
val3.onValueChange += new BoolValueChangeEventDelegate(UpdateHard);
SceneManager.sceneLoaded += delegate
{
if (!Loaded)
{
Patch();
Loaded = true;
ActiveList.Clear();
ActiveList.Capacity = 0;
DcWave.Clear();
DcInfo.Clear();
DcDead.Clear();
}
};
Logger.LogInfo((object)"DcSchizo v1.0.0 has loaded!");
}
private static void UpdateDebug(BoolValueChangeEvent isDebug)
{
DebugMode = isDebug.value;
}
private static void UpdateSoftlock(BoolValueChangeEvent Softlock)
{
if (!Softlock.value)
{
return;
}
Softlock.value = false;
foreach (GameObject key in DcInfo.Keys)
{
key.GetComponent<EnemyIdentifier>().Unbless(false);
}
}
private static void UpdateHard(BoolValueChangeEvent isHard)
{
Hard = isHard.value;
}
internal static void Patch()
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Expected O, but got Unknown
if (Harmony == null)
{
Harmony = new Harmony("DcSchizo");
}
Logger.LogDebug((object)"Patching...");
Harmony.PatchAll(Assembly.GetExecutingAssembly());
Logger.LogDebug((object)"Finished patching!");
}
internal static void Unpatch()
{
Logger.LogDebug((object)"Unpatching...");
Harmony? harmony = Harmony;
if (harmony != null)
{
harmony.UnpatchSelf();
}
Logger.LogDebug((object)"Finished unpatching!");
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "DcSchizo";
public const string PLUGIN_NAME = "DcSchizo";
public const string PLUGIN_VERSION = "1.0.0";
}
}
namespace DcSchizo.Patches
{
public class Class1
{
public static void Classs(GameObject[] toActivateObjects)
{
List<GameObject> list = new List<GameObject>();
if (!toActivateObjects.Any())
{
return;
}
for (int i = 0; i < toActivateObjects.Length; i++)
{
if ((Object)(object)toActivateObjects[i] != (Object)null)
{
Enemy componentInParent = toActivateObjects[i].GetComponentInParent<Enemy>(true);
if ((Object)(object)componentInParent == (Object)null)
{
toActivateObjects[i].GetComponentInChildren<Enemy>(true);
}
if (((Object)(object)componentInParent == (Object)null) & ((Object)(object)toActivateObjects[i].transform.parent != (Object)null))
{
((Component)toActivateObjects[i].transform.parent).GetComponentInChildren<Enemy>(true);
}
if ((Object)(object)componentInParent != (Object)null)
{
list.Add(toActivateObjects[i]);
}
}
}
if (list.Any())
{
EnemyFunction.SchizoArena(list.ToArray(), toActivateObjects);
}
}
}
public class EnemyFunction
{
public static object[] FindEnemy(GameObject[] objects, bool dead = true, EnemyIdentifier[] enemies = null)
{
try
{
List<GameObject> list = new List<GameObject>();
List<EnemyIdentifier> list2 = new List<EnemyIdentifier>();
if (enemies == null)
{
for (int i = 0; i < objects.Length; i++)
{
EnemyIdentifier val = objects[i].GetComponentInChildren<EnemyIdentifier>(true);
if ((Object)(object)val == (Object)null)
{
val = objects[i].GetComponentInParent<EnemyIdentifier>(true);
}
if ((Object)(object)objects[i].transform.parent != (Object)null && (Object)(object)val == (Object)null)
{
val = ((Component)objects[i].transform.parent).GetComponentInChildren<EnemyIdentifier>(true);
}
if ((Object)(object)val != (Object)null)
{
if (!dead)
{
list2.Add(val);
}
else
{
list.Add(((Component)val).gameObject);
}
}
}
if (!dead)
{
return list2.ToArray();
}
return list.ToArray();
}
for (int j = 0; j < enemies.Length; j++)
{
if (enemies[j].puppet == dead)
{
list2.Add(enemies[j]);
}
}
return list2.ToArray();
}
catch
{
DcSchizo.Logger.LogWarning((object)"Mod is tweaking about something i cant be bothered to fix");
return null;
}
}
public static GameObject SchizoArena(GameObject[] objects, object __instance)
{
//IL_009a: Unknown result type (might be due to invalid IL or missing references)
//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
//IL_0158: Unknown result type (might be due to invalid IL or missing references)
//IL_015f: Expected O, but got Unknown
if (DcSchizo.ActiveList.Contains(__instance))
{
return null;
}
DcSchizo.ActiveList.Add(__instance);
if (objects.Length == 0)
{
return null;
}
GameObject[] array = (GameObject[])FindEnemy(objects);
if (!array.Any())
{
return null;
}
int num = new Random().Next(0, array.Length - 1);
GameObject val = Object.Instantiate<GameObject>(MonoSingleton<DefaultReferenceManager>.Instance.deathCatcher, array[num].transform.parent);
val.transform.position = array[num].transform.position;
val.transform.rotation = array[num].transform.rotation;
BossHealthBar val2 = array[num].GetComponentInChildren<BossHealthBar>(true);
if ((Object)(object)val2 == (Object)null)
{
val2 = array[num].GetComponentInParent<BossHealthBar>(true);
}
if (((Object)(object)val2 == (Object)null) & ((Object)(object)array[num].transform.parent != (Object)null))
{
val2 = ((Component)array[num].transform.parent).GetComponentInChildren<BossHealthBar>(true);
}
if ((Object)(object)val2 != (Object)null)
{
BossHealthBar val3 = val.AddComponent<BossHealthBar>();
val3.bossName = val2.bossName;
val3.secondaryBar = false;
HealthLayer[] healthLayers = val2.healthLayers;
foreach (HealthLayer val4 in healthLayers)
{
HealthLayer val5 = new HealthLayer();
val5.health = val.GetComponent<EnemyIdentifier>().health / (float)val2.healthLayers.Length;
CollectionExtensions.AddItem<HealthLayer>((IEnumerable<HealthLayer>)val3.healthLayers, val5);
}
val3.source = (IEnemyHealthDetails)(object)val.GetComponent<EnemyIdentifier>();
}
EventOnDestroy val6 = array[num].GetComponentInParent<EventOnDestroy>(true);
if ((Object)(object)val6 == (Object)null)
{
val6 = array[num].GetComponentInChildren<EventOnDestroy>(true);
}
if (((Object)(object)val6 == (Object)null) & ((Object)(object)array[num].transform.parent != (Object)null))
{
val6 = ((Component)array[num].transform.parent).GetComponentInChildren<EventOnDestroy>(true);
}
if ((Object)(object)val6 != (Object)null)
{
EventOnDestroy val7 = val.AddComponent<EventOnDestroy>();
val7.stuff = val6.stuff;
}
Object.Destroy((Object)(object)array[num]);
array[num] = val;
return val;
}
}
[HarmonyPatch(typeof(ActivateArena))]
public class Schizo1
{
[HarmonyPatch("SpawnEnemy")]
[HarmonyPrefix]
private static void SchizoArena(ActivateArena __instance)
{
if (!DcSchizo.ActiveList.Contains(__instance))
{
GameObject val = EnemyFunction.SchizoArena(__instance.enemies, __instance);
if ((Object)(object)val != (Object)null)
{
DcSchizo.DcInfo.Add(val, __instance);
GameObject[] value = (GameObject[])EnemyFunction.FindEnemy(__instance.enemies);
DcSchizo.DcWave.Add(__instance, value);
}
}
}
}
[HarmonyPatch(typeof(ActivateNextWave))]
public class Schizo2
{
[HarmonyPatch("SpawnEnemy")]
[HarmonyPrefix]
private static void SchizoArena2(ActivateNextWave __instance)
{
if (!DcSchizo.ActiveList.Contains(__instance))
{
GameObject val = EnemyFunction.SchizoArena(__instance.nextEnemies, __instance);
if ((Object)(object)val != (Object)null)
{
DcSchizo.DcInfo.Add(val, __instance);
GameObject[] value = (GameObject[])EnemyFunction.FindEnemy(__instance.nextEnemies);
DcSchizo.DcWave.Add(__instance, value);
}
}
}
}
[HarmonyPatch(typeof(UltrakillEvent))]
public class Schizo3
{
[HarmonyPatch("Invoke")]
[HarmonyPrefix]
private static void SchizoArena2(UltrakillEvent __instance)
{
Class1.Classs(__instance.toActivateObjects);
}
}
[HarmonyPatch(typeof(Deathcatcher))]
public class HardMode
{
[HarmonyPatch("Start")]
[HarmonyPrefix]
private static void Hard(Deathcatcher __instance, ref EnemyIdentifier ___eid)
{
if (DcSchizo.Hard && DcSchizo.DcInfo.ContainsKey(((Component)__instance).gameObject))
{
___eid.Bless(false);
__instance.killPuppetsOnDeath = false;
}
}
[HarmonyPatch("Death")]
[HarmonyPrefix]
private static bool PreventDeath(Deathcatcher __instance, ref EnemyIdentifier ___eid)
{
if (___eid.blessed)
{
return false;
}
DcSchizo.DcWave.Remove(DcSchizo.DcInfo[((Component)__instance).gameObject]);
DcSchizo.DcInfo.Remove(((Component)__instance).gameObject);
DcSchizo.DcDead.Remove(((Component)__instance).gameObject);
return true;
}
[HarmonyPatch("Update")]
[HarmonyPrefix]
private static void UpdateHard(Deathcatcher __instance)
{
if (!DcSchizo.Hard || !DcSchizo.DcInfo.ContainsKey(((Component)__instance).gameObject) || !((Component)__instance).GetComponent<EnemyIdentifier>().blessed)
{
return;
}
FieldRef<Deathcatcher, List<CaughtEnemy>> val = AccessTools.FieldRefAccess<Deathcatcher, List<CaughtEnemy>>("deadCaughtEnemies");
List<CaughtEnemy> list = val.Invoke(__instance);
GameObject[] array = DcSchizo.DcWave[DcSchizo.DcInfo[((Component)__instance).gameObject]];
if (!DcSchizo.DcDead.ContainsKey(((Component)__instance).gameObject))
{
List<GameObject> value = new List<GameObject>(1);
DcSchizo.DcDead.Add(((Component)__instance).gameObject, value);
}
if (array == null || !array.Any())
{
return;
}
GameObject[] array2 = array;
foreach (GameObject val2 in array2)
{
if ((Object)(object)val2 != (Object)null && val2.activeInHierarchy && !DcSchizo.DcDead[((Component)__instance).gameObject].Contains(val2))
{
DcSchizo.DcDead[((Component)__instance).gameObject].Add(val2);
}
}
if (!DcSchizo.DcDead[((Component)__instance).gameObject].Contains(((Component)__instance).gameObject))
{
DcSchizo.DcDead[((Component)__instance).gameObject].Add(((Component)__instance).gameObject);
}
if (DcSchizo.DebugMode)
{
DcSchizo.Logger.LogInfo((object)("Dead " + list.Count + " - Count " + DcSchizo.DcDead[((Component)__instance).gameObject].Count + " = Length " + array.Length));
}
if (((array.Length > 1) & (DcSchizo.DcDead[((Component)__instance).gameObject].Capacity > 1) & (list.Count >= DcSchizo.DcDead[((Component)__instance).gameObject].Count - 1)) || array.Length <= 1)
{
((Component)__instance).GetComponent<EnemyIdentifier>().Unbless(false);
AudioClip val3 = Resources.Load<AudioClip>("SisypheanHurtBig");
GameObject val4 = Object.Instantiate<GameObject>(MonoSingleton<HookArm>.Instance.pullDoneSound, ((Component)MonoSingleton<NewMovement>.Instance).transform);
}
}
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}