Decompiled source of MonarchsStarstormEdits v0.1.0

MonarchStarstormEdits.dll

Decompiled 2 weeks ago
using System;
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 BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using MonarchStarstormEdits.patches;
using Mono.Cecil.Cil;
using MonoMod.Cil;
using RoR2;
using RoR2.ExpansionManagement;
using RoR2BepInExPack.GameAssetPaths.Version_1_35_0;
using SS2;
using SS2.Components;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.Networking;
using UnityHotReloadNS;

[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("MonarchStarstormEdits")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+8867b6cb6ab144ec433c853e05f8a92e8f0f0403")]
[assembly: AssemblyProduct("MonarchStarstormEdits")]
[assembly: AssemblyTitle("MonarchStarstormEdits")]
[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 MonarchStarstormEdits
{
	internal static class Log
	{
		private static ManualLogSource _logSource;

		internal static void Init(ManualLogSource logSource)
		{
			_logSource = logSource;
		}

		internal static void Debug(object data)
		{
			_logSource.LogDebug(data);
		}

		internal static void Error(object data)
		{
			_logSource.LogError(data);
		}

		internal static void Fatal(object data)
		{
			_logSource.LogFatal(data);
		}

		internal static void Info(object data)
		{
			_logSource.LogInfo(data);
		}

		internal static void Message(object data)
		{
			_logSource.LogMessage(data);
		}

		internal static void Warning(object data)
		{
			_logSource.LogWarning(data);
		}
	}
	[BepInPlugin("icebro.MonarchStarstormEdits", "MonarchStarstormEdits", "0.0.1")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class MonarchStarstormEdits : BaseUnityPlugin
	{
		private const string PluginGUID = "icebro.MonarchStarstormEdits";

		private const string PluginAuthor = "icebro";

		private const string PluginName = "MonarchStarstormEdits";

		private const string PluginVersion = "0.0.1";

		private static bool UHRInstalled => Chainloader.PluginInfos.ContainsKey("iDeathHD.UnityHotReload");

		public void Awake()
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Expected O, but got Unknown
			Log.Init(((BaseUnityPlugin)this).Logger);
			Harmony harmony = new Harmony(((BaseUnityPlugin)this).Info.Metadata.GUID);
			IEnumerable<Type> enumerable = from type in Assembly.GetExecutingAssembly().GetTypes()
				where !type.IsAbstract && type.IsSubclassOf(typeof(PatchBase))
				select type;
			foreach (Type item in enumerable)
			{
				PatchBase patchBase = (PatchBase)Activator.CreateInstance(item);
				try
				{
					patchBase.Config(((BaseUnityPlugin)this).Config);
					patchBase.Init(harmony);
				}
				catch (Exception data)
				{
					Log.Error(data);
				}
			}
		}

		private void Update()
		{
			if (Input.GetKeyUp((KeyCode)286))
			{
				if (UHRInstalled)
				{
					UHRSupport.hotReload(typeof(MonarchStarstormEdits).Assembly, Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "MonarchStarstormEdits.dll"));
				}
				else
				{
					Log.Debug("couldnt finds unity hot reload !!");
				}
			}
		}
	}
	internal static class UHRSupport
	{
		internal static void hotReload(Assembly assembly, string path)
		{
			UnityHotReload.LoadNewAssemblyVersion(assembly, path);
		}
	}
}
namespace MonarchStarstormEdits.patches
{
	public class etherealSaplingChanges : PatchBase<etherealSaplingChanges>
	{
		[HarmonyPatch]
		public class Starstorm2EtherealChanges
		{
			[HarmonyPatch(typeof(TraderController), "BeginTrade")]
			[HarmonyPrefix]
			public static void BeginTradePrefix(TraderController __instance, int intPickupIndex)
			{
				Log.Debug(intPickupIndex);
			}

			[HarmonyPatch(typeof(EtherealBehavior), "SpawnShrine")]
			[HarmonyPrefix]
			public static bool SpawnShrinePostFix(EtherealBehavior __instance)
			{
				//IL_004a: Unknown result type (might be due to invalid IL or missing references)
				//IL_004f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0064: Expected O, but got Unknown
				float num = Run.instance.runRNG.RangeFloat(0f, 1f);
				if (num <= spawnChance.Value)
				{
					Log.Debug("spawning shrine !!");
					if (sendChatMessage.Value)
					{
						Chat.SendBroadcastChat((ChatMessageBase)new SimpleChatMessage
						{
							baseToken = chatMessage.Value
						});
					}
					return true;
				}
				Log.Debug("not spawning ethereal shrine !! ");
				return false;
			}

			[HarmonyPatch(typeof(EtherealBehavior), "Start")]
			[HarmonyPrefix]
			public static void StartPostFix(EtherealBehavior __instance)
			{
				EtherealBehavior.alwaysReplaceNewts = false;
			}

			[HarmonyPatch(typeof(EtherealBehavior), "ReplaceRandomNewtStatue")]
			[HarmonyPrefix]
			public static bool ReplaceRandomNewtStatuePostFix(EtherealBehavior __instance)
			{
				//IL_007d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0082: Unknown result type (might be due to invalid IL or missing references)
				//IL_008c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0091: 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)
				PortalStatueBehavior[] source = (from p in Object.FindObjectsOfType<PortalStatueBehavior>(true)
					where (int)p.portalType == 0
					select p).ToArray();
				PortalStatueBehavior[] array = source.Where((PortalStatueBehavior p) => !((Component)p).gameObject.activeInHierarchy).ToArray();
				if (array.Length != 0)
				{
					Transform transform = ((Component)array[Random.Range(0, array.Length)]).transform;
					GameObject val = Object.Instantiate<GameObject>(EtherealBehavior.shrinePrefab, transform.position + Vector3.up * -1.2f, transform.rotation);
					NetworkServer.Spawn(val);
				}
				else
				{
					Log.Debug("idk something bad happened ,..,,.");
				}
				return false;
			}

			[HarmonyPatch(typeof(ShrineEtherealBehavior), "ActivateEtherealTerminal")]
			[HarmonyPrefix]
			public static bool ActivateEtherealTerminalPrefix(ShrineEtherealBehavior __instance, Interactor interactor)
			{
				//IL_0257: Unknown result type (might be due to invalid IL or missing references)
				//IL_025c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0264: Unknown result type (might be due to invalid IL or missing references)
				//IL_0274: Expected O, but got Unknown
				//IL_001f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0024: Unknown result type (might be due to invalid IL or missing references)
				//IL_0034: Expected O, but got Unknown
				//IL_02cd: Unknown result type (might be due to invalid IL or missing references)
				//IL_02d2: Unknown result type (might be due to invalid IL or missing references)
				//IL_038c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0391: Unknown result type (might be due to invalid IL or missing references)
				//IL_03b1: Unknown result type (might be due to invalid IL or missing references)
				//IL_03bb: Unknown result type (might be due to invalid IL or missing references)
				//IL_0608: Unknown result type (might be due to invalid IL or missing references)
				//IL_060d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0634: Unknown result type (might be due to invalid IL or missing references)
				//IL_0198: Unknown result type (might be due to invalid IL or missing references)
				//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
				//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
				//IL_0418: Unknown result type (might be due to invalid IL or missing references)
				//IL_041d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0421: Unknown result type (might be due to invalid IL or missing references)
				//IL_0426: Unknown result type (might be due to invalid IL or missing references)
				//IL_0495: Unknown result type (might be due to invalid IL or missing references)
				//IL_04c6: Unknown result type (might be due to invalid IL or missing references)
				//IL_04f7: Unknown result type (might be due to invalid IL or missing references)
				//IL_0509: Unknown result type (might be due to invalid IL or missing references)
				//IL_053a: Unknown result type (might be due to invalid IL or missing references)
				//IL_053f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0543: Unknown result type (might be due to invalid IL or missing references)
				//IL_0548: Unknown result type (might be due to invalid IL or missing references)
				//IL_0578: Unknown result type (might be due to invalid IL or missing references)
				//IL_057d: Unknown result type (might be due to invalid IL or missing references)
				//IL_058f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0594: Unknown result type (might be due to invalid IL or missing references)
				//IL_059a: Unknown result type (might be due to invalid IL or missing references)
				//IL_05a8: Unknown result type (might be due to invalid IL or missing references)
				//IL_05ad: Unknown result type (might be due to invalid IL or missing references)
				//IL_05b1: Unknown result type (might be due to invalid IL or missing references)
				//IL_05b6: Unknown result type (might be due to invalid IL or missing references)
				//IL_05ca: Unknown result type (might be due to invalid IL or missing references)
				if (__instance.purchaseCount >= 1)
				{
					CharacterBody component = ((Component)interactor).GetComponent<CharacterBody>();
					Chat.SendBroadcastChat((ChatMessageBase)new SubjectFormatChatMessage
					{
						baseToken = "<style=cIsHealing>The gods feel as if mocked...</style>"
					});
					((Component)__instance).gameObject.GetComponent<EtherealShrineActivator>().kill = true;
					if ((Object)(object)__instance.childLocator != (Object)null)
					{
						((Component)__instance.childLocator.FindChild("Loop")).gameObject.SetActive(false);
					}
					__instance.waitingForRefresh = false;
					__instance.purchaseInteraction.SetAvailable(false);
					GameObject gameObject = ((Component)((Component)__instance).transform.Find("ChargeBFG(Clone)")).gameObject;
					ParticleSystem[] array = (ParticleSystem[])(object)new ParticleSystem[5]
					{
						((Component)gameObject.transform.GetChild(1).GetChild(0)).GetComponent<ParticleSystem>(),
						((Component)gameObject.transform.GetChild(1).GetChild(1)).GetComponent<ParticleSystem>(),
						((Component)gameObject.transform.GetChild(1).GetChild(2)).GetComponent<ParticleSystem>(),
						((Component)gameObject.transform.GetChild(1).GetChild(3)).GetComponent<ParticleSystem>(),
						((Component)gameObject.transform.GetChild(1).GetChild(4)).GetComponent<ParticleSystem>()
					};
					ParticleSystem[] array2 = array;
					foreach (ParticleSystem val in array2)
					{
						val.Stop(false, (ParticleSystemStopBehavior)1);
					}
					ShakeEmitter val2 = ((Component)__instance).gameObject.AddComponent<ShakeEmitter>();
					val2.shakeOnStart = true;
					val2.duration = 0.5f;
					val2.radius = 200f;
					val2.startDelay = 0f;
					val2.wave = new Wave
					{
						amplitude = 0.5f,
						frequency = 3f,
						cycleOffset = 0f
					};
					val2.amplitudeTimeDecay = true;
					val2.StartShake();
					((Component)((Component)__instance).transform.GetChild(0).GetChild(0).GetChild(0)).GetComponent<ParticleSystem>().Stop(true, (ParticleSystemStopBehavior)1);
					return false;
				}
				__instance.purchaseInteraction.contextToken = "SS2_ETHEREAL_WARNING2";
				__instance.purchaseInteraction.displayNameToken = "SS2_ETHEREAL_NAME2";
				__instance.purchaseCount++;
				__instance.refreshTimer = 2f;
				Util.PlaySound("Play_UI_shrineActivate", ((Component)__instance).gameObject);
				CharacterBody component2 = ((Component)interactor).GetComponent<CharacterBody>();
				Chat.SendBroadcastChat((ChatMessageBase)new SubjectFormatChatMessage
				{
					subjectAsCharacterBody = component2,
					baseToken = "SS2_SHRINE_ETHEREAL_WARN_MESSAGE"
				});
				if ((Object)(object)__instance.childLocator != (Object)null)
				{
					((Component)__instance.childLocator.FindChild("Loop")).gameObject.SetActive(true);
					((Component)__instance.childLocator.FindChild("Symbol")).gameObject.SetActive(false);
				}
				__instance.waitingForRefresh = true;
				GameObject val3 = Object.Instantiate<GameObject>(Addressables.LoadAssetAsync<GameObject>((object)RoR2_Base_BFG.ChargeBFG_prefab).WaitForCompletion(), ((Component)__instance).transform);
				ParticleSystem[] array3 = (ParticleSystem[])(object)new ParticleSystem[5]
				{
					((Component)val3.transform.GetChild(1).GetChild(0)).GetComponent<ParticleSystem>(),
					((Component)val3.transform.GetChild(1).GetChild(1)).GetComponent<ParticleSystem>(),
					((Component)val3.transform.GetChild(1).GetChild(2)).GetComponent<ParticleSystem>(),
					((Component)val3.transform.GetChild(1).GetChild(3)).GetComponent<ParticleSystem>(),
					((Component)val3.transform.GetChild(1).GetChild(4)).GetComponent<ParticleSystem>()
				};
				((Component)array3[3]).gameObject.SetActive(true);
				for (int j = 0; j < array3.Length; j++)
				{
					MainModule main = array3[j].main;
					((MainModule)(ref main)).duration = ((MainModule)(ref main)).duration * 3.3333333f;
					Transform transform = ((Component)array3[j]).transform;
					transform.localScale *= 3f;
					switch (j)
					{
					case 0:
					{
						((MainModule)(ref main)).simulationSpeed = 1f;
						((MainModule)(ref main)).maxParticles = 400;
						((MainModule)(ref main)).startSizeMultiplier = 1.2f;
						EmissionModule emission = array3[0].emission;
						MinMaxCurve rateOverTime = ((EmissionModule)(ref emission)).rateOverTime;
						Log.Debug(((Keyframe)(ref ((MinMaxCurve)(ref rateOverTime)).curve.keys[1])).value);
						((Keyframe)(ref ((MinMaxCurve)(ref rateOverTime)).curve.keys[0])).value = 0.6f;
						Log.Debug(((Keyframe)(ref ((MinMaxCurve)(ref rateOverTime)).curve.keys[0])).value);
						break;
					}
					case 1:
						((MainModule)(ref main)).startSize = MinMaxCurve.op_Implicit(2f);
						((MainModule)(ref main)).simulationSpeed = 0.3f;
						((MainModule)(ref main)).duration = 2f;
						break;
					case 2:
						((MainModule)(ref main)).startSize = MinMaxCurve.op_Implicit(4f);
						((MainModule)(ref main)).simulationSpeed = 0.3f;
						((MainModule)(ref main)).duration = 2f;
						break;
					case 3:
					{
						((MainModule)(ref main)).startSize = MinMaxCurve.op_Implicit(4f);
						((MainModule)(ref main)).startLifetime = MinMaxCurve.op_Implicit(2f);
						((MainModule)(ref main)).simulationSpeed = 0.3f;
						((MainModule)(ref main)).duration = 2f;
						((MainModule)(ref main)).maxParticles = 1;
						ColorOverLifetimeModule colorOverLifetime = array3[3].colorOverLifetime;
						MinMaxGradient color = ((ColorOverLifetimeModule)(ref colorOverLifetime)).color;
						Gradient gradient = ((MinMaxGradient)(ref color)).gradient;
						GradientColorKey[] colorKeys = gradient.colorKeys;
						colorKeys[0].color = new Color(0f, 1f, 0f, 1f);
						gradient.colorKeys = colorKeys;
						ColorOverLifetimeModule colorOverLifetime2 = array3[3].colorOverLifetime;
						((ColorOverLifetimeModule)(ref colorOverLifetime2)).color = MinMaxGradient.op_Implicit(gradient);
						colorOverLifetime = array3[3].colorOverLifetime;
						color = ((ColorOverLifetimeModule)(ref colorOverLifetime)).color;
						Log.Debug(((MinMaxGradient)(ref color)).gradient.colorKeys[0].color);
						break;
					}
					case 4:
						((MainModule)(ref main)).startSizeMultiplier = 2f;
						break;
					}
				}
				Vector3 localPosition = val3.transform.localPosition;
				localPosition.y += 2.3f;
				localPosition.z -= 0.3f;
				val3.transform.localPosition = localPosition;
				((Component)__instance).gameObject.AddComponent<EtherealShrineActivator>().interactor = interactor;
				return false;
			}
		}

		public class EtherealShrineActivator : MonoBehaviour
		{
			public float timer;

			public Interactor interactor;

			public bool kill;

			private void FixedUpdate()
			{
				//IL_0081: Unknown result type (might be due to invalid IL or missing references)
				//IL_0086: Unknown result type (might be due to invalid IL or missing references)
				//IL_008e: Unknown result type (might be due to invalid IL or missing references)
				//IL_009e: Expected O, but got Unknown
				//IL_0100: Unknown result type (might be due to invalid IL or missing references)
				//IL_012a: Unknown result type (might be due to invalid IL or missing references)
				//IL_012c: Unknown result type (might be due to invalid IL or missing references)
				timer += Time.fixedDeltaTime;
				if (!(timer >= 6.6666665f))
				{
					return;
				}
				if (kill)
				{
					Object.Destroy((Object)(object)this);
					return;
				}
				ShrineEtherealBehavior component = ((Component)this).GetComponent<ShrineEtherealBehavior>();
				component.DisableShrine((TeleporterInteraction)null);
				component.waitingForRefresh = true;
				if (Object.op_Implicit((Object)(object)TeleporterUpgradeController.instance))
				{
					TeleporterUpgradeController.instance.UpgradeEthereal();
				}
				CharacterBody component2 = ((Component)interactor).GetComponent<CharacterBody>();
				Chat.SendBroadcastChat((ChatMessageBase)new SubjectFormatChatMessage
				{
					subjectAsCharacterBody = component2,
					baseToken = "SS2_SHRINE_ETHEREAL_USE_MESSAGE"
				});
				Util.PlaySound("EtherealBell", ((Component)component).gameObject);
				component.purchaseCount++;
				component.refreshTimer = 2f;
				ShakeEmitter val = ((Component)this).gameObject.AddComponent<ShakeEmitter>();
				val.shakeOnStart = true;
				val.duration = 0.25f;
				val.radius = 200f;
				val.startDelay = 0f;
				val.wave = new Wave
				{
					amplitude = 0.5f,
					frequency = 3f,
					cycleOffset = 0f
				};
				val.amplitudeTimeDecay = true;
				val.StartShake();
				((Component)((Component)this).transform.Find("ChargeBFG(Clone)")).gameObject.SetActive(false);
				Object.Destroy((Object)(object)this);
			}
		}

		private static ConfigEntry<bool> etherealChanges;

		private static ConfigEntry<float> spawnChance;

		private static ConfigEntry<bool> sendChatMessage;

		private static ConfigEntry<string> chatMessage;

		public override void Init(Harmony harmony)
		{
			if (etherealChanges.Value)
			{
				harmony.CreateClassProcessor(typeof(Starstorm2EtherealChanges)).Patch();
			}
		}

		public override void Config(ConfigFile config)
		{
			etherealChanges = config.Bind<bool>("ethereal shrine change s,s,.,.", "apply any ethereal sapling changes at al l !!", true, "byeah ,.,");
			spawnChance = config.Bind<float>("ethereal shrine change s,s,.,.", "chance in percent to spawn ethereal shrine !! 1 is 100% ,.,,.", 0.5f, "byeah ,.,");
			sendChatMessage = config.Bind<bool>("ethereal shrine change s,s,.,.", "should if a shrine spawn send a chat message !!", true, "byeah ,.,");
			chatMessage = config.Bind<string>("ethereal shrine change s,s,.,.", "said chat message if chat message enabled ,,.", "<style=\"cIsHealing\">Unknown forces start to coalesce...</style>", "byeah ,.,");
		}
	}
	public class etherealUpgradeChanges : PatchBase<etherealUpgradeChanges>
	{
		[HarmonyPatch]
		public class Starstorm2EtherealUpgradeChanges
		{
			[HarmonyPatch(typeof(EtherealBehavior), "UpdateDifficulty")]
			[HarmonyPrefix]
			public static bool BeginTradePrefix(EtherealBehavior __instance)
			{
				//IL_0007: Unknown result type (might be due to invalid IL or missing references)
				//IL_0059: Unknown result type (might be due to invalid IL or missing references)
				//IL_0060: Invalid comparison between Unknown and I4
				//IL_0090: 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_011b: Unknown result type (might be due to invalid IL or missing references)
				//IL_009b: Unknown result type (might be due to invalid IL or missing references)
				//IL_009e: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c0: Expected I4, but got Unknown
				//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
				//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
				//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e3: 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_00f2: Unknown result type (might be due to invalid IL or missing references)
				//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
				DifficultyDef difficultyDef = DifficultyCatalog.GetDifficultyDef(__instance.run.selectedDifficulty);
				Log.Debug(((object)difficultyDef)?.ToString() + "current dif f,..,.,,. name token = " + difficultyDef.nameToken);
				if (!difficultyDef.nameToken.Contains("ECLIPSE"))
				{
					return true;
				}
				if ((int)__instance.run.selectedDifficulty != 10 && etherealEclipseUpgrade.Value)
				{
					Log.Debug("upgrading eclipse number !! ");
					Run run = __instance.run;
					DifficultyIndex selectedDifficulty = __instance.run.selectedDifficulty;
					if (1 == 0)
					{
					}
					DifficultyIndex selectedDifficulty2 = (DifficultyIndex)((selectedDifficulty - 3) switch
					{
						0 => 4, 
						1 => 5, 
						2 => 6, 
						3 => 7, 
						4 => 8, 
						5 => 9, 
						6 => 10, 
						_ => __instance.run.selectedDifficulty, 
					});
					if (1 == 0)
					{
					}
					run.selectedDifficulty = selectedDifficulty2;
				}
				else
				{
					Log.Debug("e 8 ,.,., stacking instead !! ");
				}
				difficultyDef.scalingValue = EtherealDifficulty.GetDefaultScaling(__instance.run.selectedDifficulty) + etherealEclipseUpgradeStack.Value;
				return false;
			}
		}

		private static ConfigEntry<bool> etherealEclipseChanges;

		private static ConfigEntry<bool> etherealEclipseUpgrade;

		private static ConfigEntry<float> etherealEclipseUpgradeStack;

		public override void Init(Harmony harmony)
		{
			if (etherealEclipseChanges.Value)
			{
				harmony.CreateClassProcessor(typeof(Starstorm2EtherealUpgradeChanges)).Patch();
			}
		}

		public override void Config(ConfigFile config)
		{
			etherealEclipseChanges = config.Bind<bool>("ethereal stacking change s,s,.,.", "apply any ethereal eclipse changes at al l!!!", true, "byeah ,.,");
			etherealEclipseUpgrade = config.Bind<bool>("ethereal stacking change s,s,.,.", "upgrade eclipse difficulty levels (eg e1 -> e2 !!", true, "byeah ,.,");
			etherealEclipseUpgradeStack = config.Bind<float>("ethereal stacking change s,s,.,.", "amount to upgrade scaling difficulty by alongside eclipse upgrade (default is 0.5 like regular ethereal stacking.,,. applied alongside e1 -> e2 if thats also enabled,.,..", 0.5f, "byeah ,.,");
		}
	}
	public class gamblerFix : PatchBase<gamblerFix>
	{
		[HarmonyPatch]
		public class Starstorm2GamblerFix
		{
			[HarmonyPatch(typeof(RewardDropper), "GeneratePickups")]
			[HarmonyPrefix]
			public static bool PickupPostFix(RewardDropper __instance)
			{
				//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)
				//IL_004c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0051: Unknown result type (might be due to invalid IL or missing references)
				//IL_0054: Unknown result type (might be due to invalid IL or missing references)
				//IL_005b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0061: Invalid comparison between Unknown and I4
				//IL_010c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0117: Unknown result type (might be due to invalid IL or missing references)
				//IL_011c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0121: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
				//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
				//IL_0153: 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_0162: Unknown result type (might be due to invalid IL or missing references)
				//IL_016a: Unknown result type (might be due to invalid IL or missing references)
				//IL_016c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0171: 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_01e2: Unknown result type (might be due to invalid IL or missing references)
				//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
				//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
				//IL_021e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0231: Unknown result type (might be due to invalid IL or missing references)
				//IL_0236: Unknown result type (might be due to invalid IL or missing references)
				//IL_023e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0243: Unknown result type (might be due to invalid IL or missing references)
				//IL_027d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0282: Unknown result type (might be due to invalid IL or missing references)
				//IL_028c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0294: Unknown result type (might be due to invalid IL or missing references)
				//IL_0296: Unknown result type (might be due to invalid IL or missing references)
				//IL_029b: Unknown result type (might be due to invalid IL or missing references)
				//IL_02e9: Unknown result type (might be due to invalid IL or missing references)
				//IL_030c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0311: Unknown result type (might be due to invalid IL or missing references)
				//IL_0316: Unknown result type (might be due to invalid IL or missing references)
				//IL_0348: Unknown result type (might be due to invalid IL or missing references)
				//IL_035b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0360: Unknown result type (might be due to invalid IL or missing references)
				//IL_0368: Unknown result type (might be due to invalid IL or missing references)
				//IL_036d: Unknown result type (might be due to invalid IL or missing references)
				//IL_03a7: Unknown result type (might be due to invalid IL or missing references)
				//IL_03ac: Unknown result type (might be due to invalid IL or missing references)
				//IL_03b6: Unknown result type (might be due to invalid IL or missing references)
				//IL_03be: Unknown result type (might be due to invalid IL or missing references)
				//IL_03c0: Unknown result type (might be due to invalid IL or missing references)
				//IL_03c5: Unknown result type (might be due to invalid IL or missing references)
				//IL_0413: Unknown result type (might be due to invalid IL or missing references)
				//IL_0436: Unknown result type (might be due to invalid IL or missing references)
				//IL_043b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0440: Unknown result type (might be due to invalid IL or missing references)
				//IL_0472: Unknown result type (might be due to invalid IL or missing references)
				//IL_0485: Unknown result type (might be due to invalid IL or missing references)
				//IL_048a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0492: Unknown result type (might be due to invalid IL or missing references)
				//IL_0497: Unknown result type (might be due to invalid IL or missing references)
				if (injectorToCoupler.Value && Run.instance.IsExpansionEnabled(Addressables.LoadAssetAsync<ExpansionDef>((object)"RoR2/DLC3/DLC3.asset").WaitForCompletion()))
				{
					PickupIndex[] pickups = __instance.reward.pickups;
					foreach (PickupIndex val in pickups)
					{
						if ((int)PickupCatalog.GetPickupDef(val).equipmentIndex == -1)
						{
							Log.Debug("not equipmnet ,..,");
							continue;
						}
						Log.Debug("adding extra equip item to reward !!");
						Array.Resize(ref __instance.reward.pickups, __instance.reward.pickups.Length + 1);
						__instance.reward.pickups[^1] = PickupCatalog.FindPickupIndex(Items.ExtraEquipment.itemIndex);
					}
				}
				else
				{
					Log.Debug("wow ,.., okay ,.,.");
				}
				__instance.pickupQueue = new Queue<RewardInfo>();
				PickupIndex[] pickups2 = __instance.reward.pickups;
				for (int j = 0; j < pickups2.Length; j++)
				{
					__instance.pickupQueue.Enqueue(new RewardInfo
					{
						pickupIndex = pickups2[j]
					});
				}
				for (int k = 0; k < __instance.reward.white; k++)
				{
					PickupIndex pickupIndex = __instance.rng.NextElementUniform<PickupIndex>(Run.instance.availableTier1DropList);
					__instance.pickupQueue.Enqueue(new RewardInfo
					{
						pickupIndex = pickupIndex
					});
				}
				for (int l = 0; l < __instance.reward.whiteOption; l++)
				{
					List<UniquePickup> list = new List<UniquePickup>();
					RewardDropper.dtTier1.GenerateDistinctPickups(list, 3, __instance.rng, true);
					__instance.pickupQueue.Enqueue(new RewardInfo
					{
						prefabOverride = RewardDropper.optionPrefab,
						options = PickupPickerController.GenerateOptionsFromList<List<UniquePickup>>(list),
						pickupIndex = PickupCatalog.FindPickupIndex((ItemTier)0)
					});
				}
				for (int m = 0; m < __instance.reward.whiteCommand; m++)
				{
					__instance.pickupQueue.Enqueue(new RewardInfo
					{
						pickupIndex = Run.instance.availableTier1DropList[0],
						flag = (PickupArtifactFlag)1
					});
				}
				for (int n = 0; n < __instance.reward.green; n++)
				{
					PickupIndex pickupIndex2 = __instance.rng.NextElementUniform<PickupIndex>(Run.instance.availableTier2DropList);
					__instance.pickupQueue.Enqueue(new RewardInfo
					{
						pickupIndex = pickupIndex2
					});
				}
				for (int num = 0; num < __instance.reward.greenOption; num++)
				{
					List<UniquePickup> list2 = new List<UniquePickup>();
					RewardDropper.dtTier2.GenerateDistinctPickups(list2, 3, __instance.rng, true);
					__instance.pickupQueue.Enqueue(new RewardInfo
					{
						prefabOverride = RewardDropper.optionPrefab,
						options = PickupPickerController.GenerateOptionsFromList<List<UniquePickup>>(list2),
						pickupIndex = PickupCatalog.FindPickupIndex((ItemTier)1)
					});
				}
				for (int num2 = 0; num2 < __instance.reward.greenCommand; num2++)
				{
					__instance.pickupQueue.Enqueue(new RewardInfo
					{
						pickupIndex = Run.instance.availableTier2DropList[0],
						flag = (PickupArtifactFlag)1
					});
				}
				for (int num3 = 0; num3 < __instance.reward.red; num3++)
				{
					PickupIndex pickupIndex3 = __instance.rng.NextElementUniform<PickupIndex>(Run.instance.availableTier3DropList);
					__instance.pickupQueue.Enqueue(new RewardInfo
					{
						pickupIndex = pickupIndex3
					});
				}
				for (int num4 = 0; num4 < __instance.reward.redOption; num4++)
				{
					List<UniquePickup> list3 = new List<UniquePickup>();
					RewardDropper.dtTier3.GenerateDistinctPickups(list3, 3, __instance.rng, true);
					__instance.pickupQueue.Enqueue(new RewardInfo
					{
						prefabOverride = RewardDropper.optionPrefab,
						options = PickupPickerController.GenerateOptionsFromList<List<UniquePickup>>(list3),
						pickupIndex = PickupCatalog.FindPickupIndex((ItemTier)2)
					});
				}
				for (int num5 = 0; num5 < __instance.reward.redCommand; num5++)
				{
					__instance.pickupQueue.Enqueue(new RewardInfo
					{
						pickupIndex = Run.instance.availableTier3DropList[0],
						flag = (PickupArtifactFlag)1
					});
				}
				return false;
			}
		}

		private static ConfigEntry<bool> gamblerFixes;

		private static ConfigEntry<bool> injectorToCoupler;

		public override void Init(Harmony harmony)
		{
			if (gamblerFixes.Value)
			{
				harmony.CreateClassProcessor(typeof(Starstorm2GamblerFix)).Patch();
			}
		}

		public override void Config(ConfigFile config)
		{
			gamblerFixes = config.Bind<bool>("lunar gambler fix s,s,.,.", "try to fix lunar gambler errors when it gives void potentials!!! disable if its fixed already .,.,", true, "byeah ,.,");
			injectorToCoupler = config.Bind<bool>("lunar gambler fix s,s,.,.", "add a functional coupler (if dlc3 enabled( to rewards with equipments (ones that used to have composite injector .,.,", true, "byeah ,.,");
		}
	}
	public class gamblerTweaks : PatchBase<gamblerTweaks>
	{
		[HarmonyPatch]
		public class Starstorm2GamblerTweaks
		{
			[HarmonyPatch(typeof(CurseManager), "OnBodyStartGlobal")]
			[HarmonyILManipulator]
			public static void OnEnterPostFix(ILContext il)
			{
				//IL_0027: Unknown result type (might be due to invalid IL or missing references)
				//IL_002d: Expected O, but got Unknown
				//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
				if (baseCloakDuration.Value == 0f)
				{
					return;
				}
				Log.Debug("tryings il hook curse cloak unevilify ,,.");
				ILCursor val = new ILCursor(il);
				if (val.TryGotoNext(new Func<Instruction, bool>[3]
				{
					(Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 0),
					(Instruction x) => ILPatternMatchingExt.MatchLdsfld(x, "RoR2.RoR2Content/Buffs", "Cloak"),
					(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, (MethodBase)typeof(CharacterBody).GetMethod("AddBuff", new Type[1] { typeof(BuffDef) }))
				}))
				{
					val.RemoveRange(3);
					val.Emit(OpCodes.Ldarg_0);
					val.EmitDelegate<Action<CharacterBody>>((Action<CharacterBody>)delegate(CharacterBody cb)
					{
						cb.AddTimedBuff(Buffs.Cloak, baseCloakDuration.Value * CurseManager.GetCurseIntensity() * (float)CurseManager.GetActiveCurseCount((CurseIndex)7));
					});
					Log.Debug("unevilified cloak !!");
				}
			}
		}

		private static ConfigEntry<bool> gamblerTweak;

		private static ConfigEntry<float> baseCloakDuration;

		public override void Init(Harmony harmony)
		{
			if (gamblerTweak.Value)
			{
				harmony.CreateClassProcessor(typeof(Starstorm2GamblerTweaks)).Patch();
			}
		}

		public override void Config(ConfigFile config)
		{
			gamblerTweak = config.Bind<bool>("lunar gambler tweaks !!!", "try to fix lunar gambler errors when it gives void potentials!!! disable if its fixed already .,.,", true, "byeah ,.,");
			baseCloakDuration = config.Bind<float>("lunar gambler tweaks !!!", "makes cloak curse have a timer instead of always .,., i hate them so much ,.,..,,. 0 to disable !!", 15f, "byeah ,.,");
		}
	}
	public abstract class PatchBase<T> : PatchBase where T : PatchBase<T>
	{
		public static T instance { get; private set; }

		public PatchBase()
		{
			if (instance != null)
			{
				throw new InvalidOperationException("Singleton class \"" + typeof(T).Name + "\" inheriting ItemBase was instantiated twice");
			}
			instance = this as T;
		}
	}
	public abstract class PatchBase
	{
		public abstract void Init(Harmony harmony);

		public abstract void Config(ConfigFile config);

		public virtual void Hooks()
		{
		}
	}
}