Decompiled source of Savage Difficulty v0.3.1

SavageDifficulty.dll

Decompiled 2 days ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using AngryLevelLoader.Managers;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using SavageDifficulty.Compat;
using SavageDifficulty.Patches;
using TMPro;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.SceneManagement;
using UnityEngine.UIElements.Collections;

[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("SavageDifficulty")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("A custom difficulty mod that aims to be harder than Brutal, within reason.")]
[assembly: AssemblyFileVersion("0.3.1.0")]
[assembly: AssemblyInformationalVersion("0.3.1+2722d64552c3acfd7bb449774366359ab7830450")]
[assembly: AssemblyProduct("SavageDifficulty")]
[assembly: AssemblyTitle("SavageDifficulty")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.3.1.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 SavageDifficulty
{
	public class AlgalDifficulty
	{
		public readonly string name;

		public readonly int difficulty;

		public readonly int baseDifficulty;

		public bool isEnabled => DifficultyHelper.CurrentDifficulty == difficulty;

		public AlgalDifficulty(string name, int difficulty, int? baseDifficulty = null)
		{
			this.name = name;
			this.difficulty = difficulty;
			this.baseDifficulty = ((!baseDifficulty.HasValue) ? difficulty : baseDifficulty.Value);
		}

		public void Enable()
		{
			DifficultyHelper.CurrentDifficulty = difficulty;
		}

		public AngryDifficulty IntoAngryDifficulty()
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Expected O, but got Unknown
			if (!Angry.AngryLoaded)
			{
				return null;
			}
			return new AngryDifficulty(name, difficulty);
		}
	}
	public static class DifficultyHelper
	{
		public static readonly AlgalDifficulty Harmless;

		public static readonly AlgalDifficulty Lenient;

		public static readonly AlgalDifficulty Standard;

		public static readonly AlgalDifficulty Violent;

		public static readonly AlgalDifficulty Brutal;

		public static readonly AlgalDifficulty Savage;

		public static List<AlgalDifficulty> KnownDifficulties;

		public const int MAX_DIFFICULTY_VAL = 24;

		public static int CurrentDifficulty
		{
			get
			{
				return MonoSingleton<PrefsManager>.Instance.GetInt("difficulty", -1);
			}
			set
			{
				MonoSingleton<PrefsManager>.Instance.SetInt("difficulty", value);
			}
		}

		public static bool IsCustom => CurrentDifficulty > 4;

		static DifficultyHelper()
		{
			Harmless = new AlgalDifficulty("HARMLESS", 0);
			Lenient = new AlgalDifficulty("LENIENT", 1);
			Standard = new AlgalDifficulty("STANDARD", 2);
			Violent = new AlgalDifficulty("VIOLENT", 3);
			Brutal = new AlgalDifficulty("BRUTAL", 4);
			Savage = new AlgalDifficulty("SAVAGE", 12, 4);
			KnownDifficulties = new List<AlgalDifficulty>();
			KnownDifficulties.Add(Harmless);
			KnownDifficulties.Add(Lenient);
			KnownDifficulties.Add(Standard);
			KnownDifficulties.Add(Violent);
			KnownDifficulties.Add(Brutal);
			KnownDifficulties.Add(Savage);
		}
	}
	[BepInPlugin("com.whyis2plus2.SavageDifficulty", "SavageDifficulty", "0.3.1")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		public const string PLUGIN_GUID = "com.whyis2plus2.SavageDifficulty";

		public const string PLUGIN_NAME = "SavageDifficulty";

		public const string PLUGIN_VERSION = "0.3.1";

		public static Plugin instance;

		public GameObject difficultyButton = null;

		public GameObject difficultyInfo = null;

		public readonly Harmony harmony = new Harmony("com.whyis2plus2.SavageDifficulty");

		public GameObject homingProjectile;

		public GameObject providenceProjectile;

		public GameObject virtueInsignia;

		public GameObject enrageEffect;

		private static bool addressablesInit;

		public Transform interactables { get; private set; }

		public Transform canvas { get; private set; }

		public ManualLogSource logger => ((BaseUnityPlugin)this).Logger;

		private T LoadAsset<T>(string path)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			if (!addressablesInit)
			{
				Addressables.InitializeAsync().WaitForCompletion();
				addressablesInit = true;
			}
			return Addressables.LoadAssetAsync<T>((object)path).WaitForCompletion();
		}

		private void Awake()
		{
			instance = this;
			SceneManager.activeSceneChanged += delegate
			{
				OnSceneChange();
			};
			homingProjectile = LoadAsset<GameObject>("Assets/Prefabs/Attacks and Projectiles/Projectile Homing.prefab");
			providenceProjectile = LoadAsset<GameObject>("Assets/Prefabs/Attacks and Projectiles/Projectile Providence.prefab");
			virtueInsignia = LoadAsset<GameObject>("f53d12327d16b8c4cb8c0ddd759db126");
			enrageEffect = LoadAsset<GameObject>("Assets/Particles/Enemies/RageEffect.prefab");
			harmony.PatchAll(typeof(PresenceControllerPatch));
			harmony.PatchAll(typeof(DifficultyTitlePatch));
			harmony.PatchAll(typeof(PrefsManagerPatch));
			harmony.PatchAll(typeof(RankDataPatch));
			harmony.PatchAll(typeof(GameProgressSaverPatch));
			harmony.PatchAll(typeof(EnemyPatch));
			harmony.PatchAll(typeof(ProvidencePatch));
			harmony.PatchAll(typeof(SentryPatch));
			harmony.PatchAll(typeof(EarthmoverTimerFix));
			harmony.PatchAll(typeof(SisyphusPrimePatch));
			Angry.Init();
			logger.LogInfo((object)"Loaded SavageDifficulty");
		}

		private void OnSceneChange()
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			if (!(SceneHelper.CurrentScene != "Main Menu"))
			{
				Scene activeScene = SceneManager.GetActiveScene();
				canvas = (from obj in ((Scene)(ref activeScene)).GetRootGameObjects()
					where ((Object)obj).name == "Canvas"
					select obj).First().transform;
				interactables = canvas.Find("Difficulty Select (1)/Interactables");
				AddInfo();
				AddButton();
			}
		}

		private void AddButton()
		{
			//IL_0180: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01db: Unknown result type (might be due to invalid IL or missing references)
			logger.LogInfo((object)"Adding difficulty button...");
			Dictionary<string, GameObject> dictionary = new Dictionary<string, GameObject>(new <>z__ReadOnlyArray<KeyValuePair<string, GameObject>>(new KeyValuePair<string, GameObject>[6]
			{
				FindElem("Casual Easy"),
				FindElem("Casual Hard"),
				FindElem("Standard"),
				FindElem("Violent"),
				FindElem("Brutal"),
				FindElem("V1 Must Die")
			}));
			Dictionary<string, GameObject> infos = new Dictionary<string, GameObject>(new <>z__ReadOnlyArray<KeyValuePair<string, GameObject>>(new KeyValuePair<string, GameObject>[5]
			{
				FindElem("Harmless Info"),
				FindElem("Lenient Info"),
				FindElem("Standard Info"),
				FindElem("Violent Info"),
				FindElem("Brutal Info")
			}));
			difficultyButton = Object.Instantiate<GameObject>(GeneralExtensions.GetValueSafe<string, GameObject>(dictionary, "Brutal"), interactables);
			difficultyButton.GetComponent<DifficultySelectButton>().difficulty = 12;
			((Component)difficultyButton.transform.Find("Name")).GetComponent<TMP_Text>().text = DifficultyHelper.Savage.name;
			difficultyButton.transform.position = GeneralExtensions.GetValueSafe<string, GameObject>(dictionary, "V1 Must Die").transform.position;
			difficultyButton.transform.position = new Vector3(difficultyButton.transform.position.x + 600f, difficultyButton.transform.position.y, difficultyButton.transform.position.z);
			((Object)difficultyButton).name = DifficultyHelper.Savage.name ?? "";
			GeneralExtensions.GetValueSafe<string, GameObject>(dictionary, "V1 Must Die").gameObject.SetActive(false);
			EventTrigger component = difficultyButton.GetComponent<EventTrigger>();
			component.triggers.Clear();
			if (!Object.op_Implicit((Object)(object)difficultyInfo))
			{
				AddInfo();
			}
			foreach (GameObject value in dictionary.Values)
			{
				EventTrigger component2 = value.GetComponent<EventTrigger>();
				if (Object.op_Implicit((Object)(object)component2))
				{
					component2.triggers.Add(Tools.CreateTriggerEntry((EventTriggerType)0, delegate
					{
						difficultyInfo.SetActive(false);
					}));
				}
			}
			component.triggers.AddRange(new <>z__ReadOnlyArray<Entry>((Entry[])(object)new Entry[3]
			{
				Tools.CreateTriggerEntry((EventTriggerType)0, delegate
				{
					difficultyInfo.SetActive(true);
					foreach (GameObject value2 in infos.Values)
					{
						value2.SetActive(false);
					}
				}),
				Tools.CreateTriggerEntry((EventTriggerType)1, delegate
				{
					difficultyInfo.SetActive(false);
				}),
				Tools.CreateTriggerEntry((EventTriggerType)4, delegate
				{
					MonoSingleton<PrefsManager>.Instance.SetInt("difficulty", 12);
					difficultyInfo.SetActive(false);
				})
			}));
			ObjectActivateInSequence component3 = ((Component)interactables).GetComponent<ObjectActivateInSequence>();
			component3.objectsToActivate = CollectionExtensions.AddItem<GameObject>((IEnumerable<GameObject>)component3.objectsToActivate, difficultyButton).ToArray();
			logger.LogInfo((object)"Added difficulty button");
			KeyValuePair<string, GameObject> FindElem(string name)
			{
				return new KeyValuePair<string, GameObject>(name, ((Component)interactables.Find(name)).gameObject);
			}
		}

		private void AddInfo()
		{
			logger.LogInfo((object)"Adding difficulty Info...");
			difficultyInfo = Object.Instantiate<GameObject>(((Component)interactables.Find("Brutal Info")).gameObject, interactables);
			((Object)difficultyInfo).name = DifficultyHelper.Savage.name + " Info";
			TMP_Text component = ((Component)difficultyInfo.transform.Find("Title (1)")).GetComponent<TMP_Text>();
			component.text = "--" + DifficultyHelper.Savage.name + "--";
			((Component)difficultyInfo.transform.Find("Text")).GetComponent<TMP_Text>().text = "<color=white>Extremely aggressive enemies and very high damage.\n\nA full arsenal, quick thinking, and a well-versed playstyle are expected. Even a tiny mistake can be fatal.</color>\n\n<b>Recommended for those who are used to the difficulty of Brutal and are looking for a new challenge.</b>";
			logger.LogInfo((object)"Added difficulty Info");
		}
	}
	public static class Tools
	{
		public static Entry CreateTriggerEntry(EventTriggerType id, UnityAction<BaseEventData> call)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Expected O, but got Unknown
			Entry val = new Entry
			{
				eventID = id
			};
			((UnityEvent<BaseEventData>)(object)val.callback).AddListener(call);
			return val;
		}
	}
}
namespace SavageDifficulty.Patches
{
	public static class DifficultyTitlePatch
	{
		[HarmonyPrefix]
		[HarmonyPatch(typeof(DifficultyTitle), "Check")]
		public static bool DifficultyTitle_Check_Prefix(ref DifficultyTitle __instance, ref TMP_Text ___txt2)
		{
			if (!DifficultyHelper.Savage.isEnabled)
			{
				return true;
			}
			string text = DifficultyHelper.Savage.name;
			if (__instance.lines)
			{
				text = "-- " + text + " --";
			}
			if (!Object.op_Implicit((Object)(object)___txt2))
			{
				___txt2 = ((Component)__instance).GetComponent<TMP_Text>();
			}
			___txt2.text = text;
			return false;
		}
	}
	public static class EarthmoverTimerFix
	{
		[HarmonyPrefix]
		[HarmonyPatch(typeof(Countdown), "GetCountdownLength")]
		public static bool Coundown_GetCountdownLength_Prefix(ref float __result)
		{
			if (!DifficultyHelper.Savage.isEnabled)
			{
				return true;
			}
			__result = 40f;
			return false;
		}
	}
	public static class EnemyPatch
	{
		[HarmonyPostfix]
		[HarmonyPatch(typeof(EnemyIdentifier), "UpdateModifiers")]
		public static void StatsScaling(ref EnemyIdentifier __instance)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Invalid comparison between Unknown and I4
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Invalid comparison between Unknown and I4
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Invalid comparison between Unknown and I4
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Invalid comparison between Unknown and I4
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Invalid comparison between Unknown and I4
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Invalid comparison between Unknown and I4
			if (!DifficultyHelper.Savage.isEnabled)
			{
				return;
			}
			EnemyType enemyType = __instance.enemyType;
			bool flag = (((int)enemyType == 21 || (int)enemyType == 39) ? true : false);
			if (flag || __instance.puppet)
			{
				return;
			}
			EnemyIdentifier obj = __instance;
			obj.totalDamageModifier *= 1.2f;
			if ((int)__instance.enemyType != 3)
			{
				EnemyIdentifier val = __instance;
				EnemyIdentifier val2 = val;
				float totalSpeedModifier = val.totalSpeedModifier;
				EnemyType enemyType2 = __instance.enemyType;
				if (1 == 0)
				{
				}
				float num = (((int)enemyType2 == 3) ? 1f : (((int)enemyType2 == 13) ? 1.2f : (((int)enemyType2 != 14) ? 1.05f : 1.2f)));
				if (1 == 0)
				{
				}
				val2.totalSpeedModifier = totalSpeedModifier * num;
				EnemyIdentifier obj2 = __instance;
				obj2.totalHealthModifier *= (__instance.isBoss ? 1.25f : 1.05f);
			}
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(Enemy), "InitializeDifficulty")]
		public static bool ForceDifficultyOverride(ref int __result)
		{
			if (!DifficultyHelper.Savage.isEnabled)
			{
				return true;
			}
			__result = DifficultyHelper.Savage.baseDifficulty;
			return false;
		}
	}
	public static class GameProgressSaverPatch
	{
		private static MethodInfo methodInfo_GetGameProgress = typeof(GameProgressSaver).GetMethod("GetGameProgress", BindingFlags.Static | BindingFlags.NonPublic, null, new Type[1] { typeof(int) }, null);

		private static MethodInfo methodInfo_ReadFile = typeof(GameProgressSaver).GetMethod("ReadFile", BindingFlags.Static | BindingFlags.NonPublic, null, new Type[1] { typeof(string) }, null);

		private static GameProgressData GetGameProgress(int difficulty = -1)
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Expected O, but got Unknown
			return (GameProgressData)methodInfo_GetGameProgress.Invoke(null, new object[1] { difficulty });
		}

		private static object ReadFile(string path)
		{
			return methodInfo_ReadFile.Invoke(null, new object[1] { path });
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(GameProgressSaver), "GetProgress")]
		public static bool GameProgressSaver_GetProgress_Prefix(ref int __result, ref int difficulty)
		{
			int num = 1;
			for (int i = difficulty; i < 25; i++)
			{
				GameProgressData gameProgress = GetGameProgress(i);
				if (gameProgress != null && gameProgress.difficulty == i && gameProgress.levelNum > num)
				{
					num = gameProgress.levelNum;
				}
			}
			__result = num;
			return false;
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(GameProgressSaver), "GetEncoreProgress")]
		public static bool GameProgressSaver_GetEncoreProgress_Prefix(ref int __result, ref int difficulty)
		{
			int num = 0;
			for (int i = difficulty; i < 25; i++)
			{
				GameProgressData gameProgress = GetGameProgress(i);
				if (gameProgress != null && gameProgress.difficulty == i && gameProgress.encores > num)
				{
					num = gameProgress.encores;
				}
			}
			__result = num;
			return false;
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(GameProgressSaver), "GetPrime")]
		public static bool GameProgressSaver_GetPrime_Prefix(ref int __result, ref int difficulty, ref int level)
		{
			if (SceneHelper.IsPlayingCustom)
			{
				__result = 0;
				return false;
			}
			level--;
			int num = 0;
			for (int i = difficulty; i < 25; i++)
			{
				GameProgressData gameProgress = GetGameProgress(i);
				if (gameProgress != null && gameProgress.difficulty == i && gameProgress.primeLevels != null && gameProgress.primeLevels.Length > level && gameProgress.primeLevels[level] > num)
				{
					if (gameProgress.primeLevels[level] >= 2)
					{
						__result = 2;
						return false;
					}
					num = gameProgress.primeLevels[level];
				}
			}
			__result = num;
			return false;
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(GameProgressSaver), "GetCyberRankData")]
		public static bool GameProgressSaver_GetCyberRankData_Prefix(ref CyberRankData __result)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Expected O, but got Unknown
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Expected O, but got Unknown
			string path = Path.Combine(GameProgressSaver.SavePath, "cybergrindhighscore.bepis");
			CyberRankData val = (CyberRankData)ReadFile(path);
			if (val == null)
			{
				val = new CyberRankData();
			}
			if (val.preciseWavesByDifficulty == null)
			{
				val.preciseWavesByDifficulty = new float[25];
			}
			else if (val.preciseWavesByDifficulty.Length < 25)
			{
				Array.Resize(ref val.preciseWavesByDifficulty, 25);
			}
			if (val.style == null)
			{
				val.style = new int[25];
			}
			else if (val.style.Length < 25)
			{
				Array.Resize(ref val.style, 25);
			}
			if (val.kills == null)
			{
				val.kills = new int[25];
			}
			else if (val.kills.Length < 25)
			{
				Array.Resize(ref val.kills, 25);
			}
			if (val.time == null)
			{
				val.time = new float[25];
			}
			else if (val.time.Length < 25)
			{
				Array.Resize(ref val.time, 25);
			}
			__result = val;
			return false;
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(GameProgressSaver), "GetRank", new Type[]
		{
			typeof(int),
			typeof(bool)
		})]
		public static void GameProgressSaver_GetRank_Postfix(ref RankData __result)
		{
			Array.Resize(ref __result.majorAssists, 25);
			Array.Resize(ref __result.ranks, 25);
			Array.Resize(ref __result.stats, 25);
		}
	}
	public static class PrefsManagerPatch
	{
		[HarmonyPostfix]
		[HarmonyPatch(/*Could not decode attribute arguments.*/)]
		public static void PrefsManager_Ctor_Postfix(ref Dictionary<string, Func<object, object>> ___propertyValidators)
		{
			___propertyValidators.Remove("difficulty");
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(PrefsManager), "EnsureValid")]
		public static bool PrefsManager_EnsureValid_Prefix(ref object __result, string __0, object __1)
		{
			__result = __1;
			return false;
		}
	}
	public static class PresenceControllerPatch
	{
		[HarmonyPostfix]
		[HarmonyPatch(typeof(PresenceController), "Start")]
		public static void PresenceController_Start_Postfix(ref PresenceController __instance)
		{
			Array.Resize(ref __instance.diffNames, 25);
			int i = 5;
			while (i < 25)
			{
				AlgalDifficulty algalDifficulty = DifficultyHelper.KnownDifficulties.Find((AlgalDifficulty d) => d.difficulty == i);
				if (algalDifficulty != null)
				{
					__instance.diffNames[i] = algalDifficulty.name;
				}
				int num = i + 1;
				i = num;
			}
		}
	}
	public static class ProvidencePatch
	{
		[HarmonyPostfix]
		[HarmonyPatch(typeof(Drone), "Awake")]
		public static void Drone_Awake_Postfix(ref Drone __instance, ref EnemyIdentifier ___eid)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Invalid comparison between Unknown and I4
			if ((int)___eid.enemyType == 38)
			{
				__instance.enrageEffect = Plugin.instance.enrageEffect;
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(Drone), "Enrage")]
		public static void Providence_Enrage_Postfix(ref Drone __instance, ref EnemyIdentifier ___eid)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Invalid comparison between Unknown and I4
			//IL_0027: 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)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
			if ((int)___eid.enemyType != 38)
			{
				return;
			}
			Transform transform = __instance.currentEnrageEffect.transform;
			transform.localScale *= 4f;
			GameObject gameObject = ((Component)((Component)__instance).transform.Find("Providence")).gameObject;
			if ((Object)(object)gameObject == (Object)null)
			{
				return;
			}
			GameObject gameObject2 = ((Component)gameObject.transform.Find("Primary Wings")).gameObject;
			if ((Object)(object)gameObject2 == (Object)null)
			{
				return;
			}
			((Renderer)gameObject2.GetComponent<SkinnedMeshRenderer>()).material.color = new Color(1f, 0f, 0f);
			GameObject gameObject3 = ((Component)gameObject.transform.Find("SecondaryWings")).gameObject;
			if ((Object)(object)gameObject3 == (Object)null)
			{
				return;
			}
			((Renderer)gameObject3.GetComponent<SkinnedMeshRenderer>()).material.color = new Color(1f, 0.5f, 0f);
			GameObject gameObject4 = ((Component)gameObject.transform.Find("Rainbow_Large")).gameObject;
			if (!Object.op_Implicit((Object)(object)gameObject4))
			{
				return;
			}
			gameObject4.SetActive(false);
			GameObject gameObject5 = ((Component)gameObject.transform.Find("Rainbow_Small")).gameObject;
			if (Object.op_Implicit((Object)(object)gameObject5))
			{
				gameObject5.SetActive(false);
				GameObject gameObject6 = ((Component)gameObject.transform.Find("Plane")).gameObject;
				if (Object.op_Implicit((Object)(object)gameObject6))
				{
					((Renderer)gameObject6.GetComponent<MeshRenderer>()).material.color = new Color(1f, 0.5f, 0f);
				}
			}
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(Drone), "Death")]
		public static void EnrageOthersOnDeath(ref Drone __instance, ref EnemyIdentifier ___eid, ref GoreZone ___gz)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Invalid comparison between Unknown and I4
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Invalid comparison between Unknown and I4
			if (!DifficultyHelper.Savage.isEnabled || (int)___eid.enemyType != 38 || __instance.Enemy.health > 0f)
			{
				return;
			}
			Drone[] componentsInChildren = ((Component)___gz).GetComponentsInChildren<Drone>();
			foreach (Drone val in componentsInChildren)
			{
				if (!((Object)(object)val == (Object)null) && !(val.Enemy.health <= 0f) && !((Object)(object)val == (Object)(object)__instance) && (int)val.Enemy.EID.enemyType == 38)
				{
					if (!val.isEnraged)
					{
						val.Enrage();
					}
					Plugin.instance.logger.LogInfo((object)"Enraging providence");
				}
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(Drone), "Shoot")]
		public static void VirtueBeams(ref Drone __instance, ref EnemyIdentifier ___eid)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Invalid comparison between Unknown and I4
			if (DifficultyHelper.Savage.isEnabled && (int)___eid.enemyType == 38 && __instance.isEnraged)
			{
				GameObject val = Object.Instantiate<GameObject>(Plugin.instance.virtueInsignia);
				VirtueInsignia component = val.GetComponent<VirtueInsignia>();
				component.target = ___eid.target;
				component.parentEnemy = __instance.Enemy;
				component.hadParent = true;
				val.SetActive(true);
			}
		}
	}
	internal class RankDataPatch
	{
		[HarmonyPrefix]
		[HarmonyPatch(/*Could not decode attribute arguments.*/)]
		public static bool RankData_Ctor_Prefix(ref RankData __instance, ref StatsManager sman)
		{
			//IL_0327: Unknown result type (might be due to invalid IL or missing references)
			//IL_032d: Expected O, but got Unknown
			//IL_0207: Unknown result type (might be due to invalid IL or missing references)
			//IL_020d: Expected O, but got Unknown
			__instance.levelNumber = sman.levelNumber;
			RankData rank = GameProgressSaver.GetRank(true, -1);
			if (rank != null)
			{
				__instance.ranks = rank.ranks;
				if (rank.majorAssists != null)
				{
					__instance.majorAssists = rank.majorAssists;
				}
				else
				{
					__instance.majorAssists = new bool[25];
				}
				if (rank.stats != null)
				{
					__instance.stats = rank.stats;
				}
				else
				{
					__instance.stats = (RankScoreData[])(object)new RankScoreData[25];
				}
				if (__instance.majorAssists.Length < 25)
				{
					Array.Resize(ref __instance.majorAssists, 25);
				}
				if (__instance.ranks.Length < 25)
				{
					Array.Resize(ref __instance.ranks, 25);
				}
				if (__instance.stats.Length < 25)
				{
					Array.Resize(ref __instance.stats, 25);
				}
				if (rank.majorAssists.Length < 25)
				{
					Array.Resize(ref rank.majorAssists, 25);
				}
				if (rank.ranks.Length < 25)
				{
					Array.Resize(ref rank.ranks, 25);
				}
				if (rank.stats.Length < 25)
				{
					Array.Resize(ref rank.stats, 25);
				}
				if ((sman.rankScore >= rank.ranks[DifficultyHelper.CurrentDifficulty] && (rank.majorAssists == null || (!sman.majorUsed && rank.majorAssists[DifficultyHelper.CurrentDifficulty]))) || sman.rankScore > rank.ranks[DifficultyHelper.CurrentDifficulty] || rank.levelNumber != __instance.levelNumber)
				{
					__instance.majorAssists[DifficultyHelper.CurrentDifficulty] = sman.majorUsed;
					__instance.ranks[DifficultyHelper.CurrentDifficulty] = sman.rankScore;
					if (__instance.stats[DifficultyHelper.CurrentDifficulty] == null)
					{
						__instance.stats[DifficultyHelper.CurrentDifficulty] = new RankScoreData();
					}
					__instance.stats[DifficultyHelper.CurrentDifficulty].kills = sman.kills;
					__instance.stats[DifficultyHelper.CurrentDifficulty].style = sman.stylePoints;
					__instance.stats[DifficultyHelper.CurrentDifficulty].time = sman.seconds;
				}
				__instance.secretsAmount = sman.secretObjects.Length;
				__instance.secretsFound = new bool[__instance.secretsAmount];
				for (int i = 0; i < __instance.secretsAmount && i < rank.secretsFound.Length; i++)
				{
					if ((Object)(object)sman.secretObjects[i] == (Object)null || rank.secretsFound[i])
					{
						__instance.secretsFound[i] = true;
					}
				}
				__instance.challenge = rank.challenge;
				return false;
			}
			__instance.ranks = new int[25];
			__instance.stats = (RankScoreData[])(object)new RankScoreData[25];
			if (__instance.stats[DifficultyHelper.CurrentDifficulty] == null)
			{
				__instance.stats[DifficultyHelper.CurrentDifficulty] = new RankScoreData();
			}
			__instance.majorAssists = new bool[25];
			for (int j = 0; j < __instance.ranks.Length; j++)
			{
				__instance.ranks[j] = -1;
			}
			__instance.ranks[DifficultyHelper.CurrentDifficulty] = sman.rankScore;
			__instance.majorAssists[DifficultyHelper.CurrentDifficulty] = sman.majorUsed;
			__instance.stats[DifficultyHelper.CurrentDifficulty].kills = sman.kills;
			__instance.stats[DifficultyHelper.CurrentDifficulty].style = sman.stylePoints;
			__instance.stats[DifficultyHelper.CurrentDifficulty].time = sman.seconds;
			__instance.secretsAmount = sman.secretObjects.Length;
			__instance.secretsFound = new bool[__instance.secretsAmount];
			for (int k = 0; k < __instance.secretsAmount; k++)
			{
				if ((Object)(object)sman.secretObjects[k] == (Object)null)
				{
					__instance.secretsFound[k] = true;
				}
			}
			return false;
		}
	}
	public static class SentryPatch
	{
		[HarmonyPostfix]
		[HarmonyPatch(typeof(Turret), "Start")]
		public static void Sentry_Start_Postfix(ref float ___maxAimTime)
		{
			if (DifficultyHelper.Savage.isEnabled)
			{
				___maxAimTime = 3f;
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(Turret), "StartAiming")]
		public static void Sentry_StartAiming_Postfix(ref int ___shotsInARow)
		{
			if (DifficultyHelper.Savage.isEnabled)
			{
				___shotsInARow = -1;
			}
		}
	}
	public static class SisyphusPrimePatch
	{
		private static Dictionary<SisyphusPrime, bool> EverySisyphus = new Dictionary<SisyphusPrime, bool>();

		[HarmonyPostfix]
		[HarmonyPatch(typeof(SisyphusPrime), "Start")]
		public static void SisyphusPrime_Start_Postfix(ref SisyphusPrime __instance)
		{
			if (DifficultyHelper.Savage.isEnabled)
			{
				EverySisyphus.Add(__instance, value: false);
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(SisyphusPrime), "Death")]
		public static void SisyphusPrime_Death_Postfix(ref SisyphusPrime __instance)
		{
			EverySisyphus.Remove(__instance);
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(SisyphusPrime), "PickPrimaryAttack", new Type[] { typeof(int) })]
		public static void SisyphusPrime_PickPrimaryAttack_Prefix(ref SisyphusPrime __instance, ref bool ___enraged)
		{
			if (DifficultyHelper.Savage.isEnabled)
			{
				EverySisyphus.Remove(__instance);
				EverySisyphus.Add(__instance, value: false);
			}
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(SisyphusPrime), "PickSecondaryAttack", new Type[] { typeof(int) })]
		public static void SisyphusPrime_PickSecondaryAttack_Prefix(ref SisyphusPrime __instance, ref bool ___enraged)
		{
			if (DifficultyHelper.Savage.isEnabled)
			{
				EverySisyphus.Remove(__instance);
				EverySisyphus.Add(__instance, value: true);
			}
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(SisyphusPrime), "StompCombo")]
		public static void SisyphusPrime_StompCombo_Prefix(ref SisyphusPrime __instance, ref bool ___enraged)
		{
			if (DifficultyHelper.Savage.isEnabled)
			{
				EverySisyphus.Remove(__instance);
				EverySisyphus.Add(__instance, value: true);
			}
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(SisyphusPrime), "Parryable")]
		public static bool SisyphusPrime_Parryable_Prefix(ref SisyphusPrime __instance, ref bool ___enraged, ref Enemy ___mach)
		{
			if (___enraged && DictionaryExtensions.Get<SisyphusPrime, bool>((IDictionary<SisyphusPrime, bool>)EverySisyphus, __instance, false))
			{
				___mach.parryable = false;
				__instance.Unparryable();
				return false;
			}
			___mach.parryable = true;
			return true;
		}
	}
}
namespace SavageDifficulty.Compat
{
	public static class Angry
	{
		public static class Patches
		{
			[HarmonyPostfix]
			[HarmonyPatch(typeof(AngryDifficultyManager), "Init")]
			public static void AngryDifficultyManager_Init_Postfix(ref List<AngryDifficulty> ___difficulties)
			{
				___difficulties.Add(DifficultyHelper.Savage.IntoAngryDifficulty());
			}

			[HarmonyPrefix]
			[HarmonyPatch(typeof(AngryDifficultyManager), "SetDifficultyFromPrefs")]
			public static bool AngryDifficultyManager_SetDifficultyFromPrefs_Prefix(ref List<AngryDifficulty> ___difficulties)
			{
				if (!DifficultyHelper.Savage.isEnabled)
				{
					return true;
				}
				AngryDifficultyManager.SetDifficulty(DifficultyHelper.Savage.IntoAngryDifficulty());
				return false;
			}
		}

		public static bool AngryLoaded => Chainloader.PluginInfos.ContainsKey("com.eternalUnion.angryLevelLoader");

		public static void Init()
		{
			Plugin.instance.logger.Log((LogLevel)16, (object)$"Has angry: {AngryLoaded}");
			if (AngryLoaded)
			{
				Plugin.instance.harmony.PatchAll(typeof(Patches));
			}
		}
	}
}
[CompilerGenerated]
internal sealed class <>z__ReadOnlyArray<T> : IEnumerable, ICollection, IList, IEnumerable<T>, IReadOnlyCollection<T>, IReadOnlyList<T>, ICollection<T>, IList<T>
{
	int ICollection.Count => _items.Length;

	bool ICollection.IsSynchronized => false;

	object ICollection.SyncRoot => this;

	object IList.this[int index]
	{
		get
		{
			return _items[index];
		}
		set
		{
			throw new NotSupportedException();
		}
	}

	bool IList.IsFixedSize => true;

	bool IList.IsReadOnly => true;

	int IReadOnlyCollection<T>.Count => _items.Length;

	T IReadOnlyList<T>.this[int index] => _items[index];

	int ICollection<T>.Count => _items.Length;

	bool ICollection<T>.IsReadOnly => true;

	T IList<T>.this[int index]
	{
		get
		{
			return _items[index];
		}
		set
		{
			throw new NotSupportedException();
		}
	}

	public <>z__ReadOnlyArray(T[] items)
	{
		_items = items;
	}

	IEnumerator IEnumerable.GetEnumerator()
	{
		return ((IEnumerable)_items).GetEnumerator();
	}

	void ICollection.CopyTo(Array array, int index)
	{
		((ICollection)_items).CopyTo(array, index);
	}

	int IList.Add(object value)
	{
		throw new NotSupportedException();
	}

	void IList.Clear()
	{
		throw new NotSupportedException();
	}

	bool IList.Contains(object value)
	{
		return ((IList)_items).Contains(value);
	}

	int IList.IndexOf(object value)
	{
		return ((IList)_items).IndexOf(value);
	}

	void IList.Insert(int index, object value)
	{
		throw new NotSupportedException();
	}

	void IList.Remove(object value)
	{
		throw new NotSupportedException();
	}

	void IList.RemoveAt(int index)
	{
		throw new NotSupportedException();
	}

	IEnumerator<T> IEnumerable<T>.GetEnumerator()
	{
		return ((IEnumerable<T>)_items).GetEnumerator();
	}

	void ICollection<T>.Add(T item)
	{
		throw new NotSupportedException();
	}

	void ICollection<T>.Clear()
	{
		throw new NotSupportedException();
	}

	bool ICollection<T>.Contains(T item)
	{
		return ((ICollection<T>)_items).Contains(item);
	}

	void ICollection<T>.CopyTo(T[] array, int arrayIndex)
	{
		((ICollection<T>)_items).CopyTo(array, arrayIndex);
	}

	bool ICollection<T>.Remove(T item)
	{
		throw new NotSupportedException();
	}

	int IList<T>.IndexOf(T item)
	{
		return ((IList<T>)_items).IndexOf(item);
	}

	void IList<T>.Insert(int index, T item)
	{
		throw new NotSupportedException();
	}

	void IList<T>.RemoveAt(int index)
	{
		throw new NotSupportedException();
	}
}