Decompiled source of Powerfully Slow Moon v1.3.4

PowerfullySlowMoon.dll

Decompiled a week ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
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 EntityStates;
using EntityStates.LunarTeleporter;
using EntityStates.Missions.BrotherEncounter;
using InLobbyConfig;
using InLobbyConfig.Fields;
using Microsoft.CodeAnalysis;
using On.EntityStates.LunarTeleporter;
using On.EntityStates.Missions.BrotherEncounter;
using On.RoR2.Achievements;
using RoR2;
using RoR2.Achievements;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.Networking;

[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("PowerfullySlowMoon")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("PowerfullySlowMoon")]
[assembly: AssemblyTitle("PowerfullySlowMoon")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
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;
		}
	}
}
namespace PowerfullySlow
{
	[BepInPlugin("xyz.yekoc.PowerfullySlow", "Powerfully Slow Moon", "1.3.4")]
	[BepInIncompatibility("com.xoxfaby.UnlockAll")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class PowerfullySlowPlugin : BaseUnityPlugin
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static Action<Stage> <>9__8_0;

			public static hook_OnExit <>9__8_4;

			public static hook_OnEnter <>9__8_5;

			internal void <Awake>b__8_0(Stage stage)
			{
				//IL_0023: Unknown result type (might be due to invalid IL or missing references)
				//IL_0038: Unknown result type (might be due to invalid IL or missing references)
				//IL_0042: Unknown result type (might be due to invalid IL or missing references)
				GameObject val = GameObject.Find("ShrineRestack");
				if (Object.op_Implicit((Object)(object)val))
				{
					val.transform.position = new Vector3(val.transform.position.x, 211.8f, val.transform.position.z);
				}
			}

			internal void <Awake>b__8_4(orig_OnExit orig, PreEncounter self)
			{
				SceneDef sceneDefForCurrentScene = SceneCatalog.GetSceneDefForCurrentScene();
				if (Object.op_Implicit((Object)(object)sceneDefForCurrentScene) && sceneDefForCurrentScene.baseSceneName == "moon")
				{
					((Component)self.childLocator.FindChild("PreEncounter")).gameObject.SetActive(false);
				}
				else
				{
					orig.Invoke(self);
				}
			}

			internal void <Awake>b__8_5(orig_OnEnter orig, EncounterFinished self)
			{
				//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
				//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
				//IL_0104: Unknown result type (might be due to invalid IL or missing references)
				//IL_0111: Unknown result type (might be due to invalid IL or missing references)
				//IL_0116: Unknown result type (might be due to invalid IL or missing references)
				//IL_0131: Unknown result type (might be due to invalid IL or missing references)
				//IL_013c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0161: Unknown result type (might be due to invalid IL or missing references)
				//IL_0186: Unknown result type (might be due to invalid IL or missing references)
				//IL_018b: Unknown result type (might be due to invalid IL or missing references)
				//IL_018e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0193: Unknown result type (might be due to invalid IL or missing references)
				//IL_0195: Unknown result type (might be due to invalid IL or missing references)
				//IL_01a6: Expected O, but got Unknown
				try
				{
					orig.Invoke(self);
				}
				catch (Exception)
				{
				}
				SceneDef sceneDefForCurrentScene = SceneCatalog.GetSceneDefForCurrentScene();
				if (!Object.op_Implicit((Object)(object)sceneDefForCurrentScene) || !(sceneDefForCurrentScene.baseSceneName == "moon"))
				{
					return;
				}
				((BrotherEncounterBaseState)self).childLocator = ((EntityState)self).GetComponent<ChildLocator>();
				if (Object.op_Implicit((Object)(object)((BrotherEncounterBaseState)self).childLocator))
				{
					Transform val = ((BrotherEncounterBaseState)self).childLocator.FindChild("ArenaWalls");
					Transform val2 = ((BrotherEncounterBaseState)self).childLocator.FindChild("ArenaNodes");
					if (Object.op_Implicit((Object)(object)val))
					{
						((Component)val).gameObject.SetActive(false);
					}
					if (Object.op_Implicit((Object)(object)val2))
					{
						((Component)val2).gameObject.SetActive(false);
					}
				}
				if (froggy)
				{
					Transform val3 = ((BrotherEncounterBaseState)self).childLocator.FindChild("CenterOrbEffect");
					Vector3 val4 = default(Vector3);
					((Vector3)(ref val4))..ctor(0f, 0f, 5f);
					GameObject val5 = Object.Instantiate<GameObject>(frogPrefab, val3.position + val4, Quaternion.identity);
					PickupIndex pickupIndex = PickupCatalog.FindPickupIndex((ItemTier)3);
					Highlight[] componentsInChildren = val5.GetComponentsInChildren<Highlight>();
					foreach (Highlight val6 in componentsInChildren)
					{
						val6.pickupIndex = pickupIndex;
						val6.highlightColor = (HighlightColor)2;
						val6.isOn = true;
					}
					val5.AddComponent<Light>().color = ((PickupIndex)(ref pickupIndex)).GetPickupColor();
					if (NetworkServer.active)
					{
						NetworkServer.Spawn(val5);
					}
					EffectManager.SpawnEffect(AssetReferences.fragileDamageBonusBreakEffectPrefab, new EffectData
					{
						origin = val3.position + val4
					}, false);
				}
			}
		}

		public static ConfigEntry<bool> frogger;

		internal bool hookSet = false;

		internal static bool froggy = false;

		internal static GameObject frogPrefab = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/moon/FrogInteractable.prefab").WaitForCompletion();

		public static ConfigEntry<int> repeatChance { get; set; }

		private void Awake()
		{
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Expected O, but got Unknown
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Expected O, but got Unknown
			//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_00f8: Expected O, but got Unknown
			//IL_0112: 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_011d: Expected O, but got Unknown
			repeatChance = ((BaseUnityPlugin)this).Config.Bind<int>("Configuration", "Repeat Chance", 0, "Percent Chance of runs past first completion repeating old moon. Type:Int,Default:0,Max:100");
			frogger = ((BaseUnityPlugin)this).Config.Bind<bool>("Configuration", "Frog, My Dudes", true, "Whether a glass frog is spawned in the boss area after fights on repeat runs of old moon. Does nothing on new moon or on the first, non-repeat, old moon run. Type:Bool,Default:True");
			repeatChance.Value = Math.Min(Math.Max(repeatChance.Value, 0), 100);
			if (Chainloader.PluginInfos.ContainsKey("com.KingEnderBrine.InLobbyConfig"))
			{
				HandleLobbyConfigCompat();
			}
			Stage.onStageStartGlobal += delegate
			{
				//IL_0023: Unknown result type (might be due to invalid IL or missing references)
				//IL_0038: Unknown result type (might be due to invalid IL or missing references)
				//IL_0042: Unknown result type (might be due to invalid IL or missing references)
				GameObject val9 = GameObject.Find("ShrineRestack");
				if (Object.op_Implicit((Object)(object)val9))
				{
					val9.transform.position = new Vector3(val9.transform.position.x, 211.8f, val9.transform.position.z);
				}
			};
			Run.onRunStartGlobal += delegate
			{
				//IL_000c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0045: Unknown result type (might be due to invalid IL or missing references)
				//IL_004f: Expected O, but got Unknown
				SceneCatalog.GetSceneDefFromSceneName("moon").sceneType = (SceneType)1;
				if (!hookSet && NetworkServer.active && Util.CheckRoll((float)repeatChance.Value, 0f, (CharacterMaster)null))
				{
					Active.OnEnter += new hook_OnEnter(EmpowerMoon);
					froggy = frogger.Value;
					Run.onRunDestroyGlobal += Cleanup;
				}
			};
			BaseEndingAchievement.OnInstall += (hook_OnInstall)delegate(orig_OnInstall orig, BaseEndingAchievement self)
			{
				//IL_002a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0034: Expected O, but got Unknown
				orig.Invoke(self);
				if (((object)self).GetType() == typeof(CompleteMainEndingAchievement))
				{
					Active.OnEnter += new hook_OnEnter(EmpowerMoon);
					hookSet = true;
				}
			};
			BaseEndingAchievement.OnUninstall += (hook_OnUninstall)delegate(orig_OnUninstall orig, BaseEndingAchievement self)
			{
				//IL_002a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0034: Expected O, but got Unknown
				orig.Invoke(self);
				if (((object)self).GetType() == typeof(CompleteMainEndingAchievement))
				{
					Active.OnEnter -= new hook_OnEnter(EmpowerMoon);
					hookSet = false;
				}
			};
			object obj = <>c.<>9__8_4;
			if (obj == null)
			{
				hook_OnExit val = delegate(orig_OnExit orig, PreEncounter self)
				{
					SceneDef sceneDefForCurrentScene2 = SceneCatalog.GetSceneDefForCurrentScene();
					if (Object.op_Implicit((Object)(object)sceneDefForCurrentScene2) && sceneDefForCurrentScene2.baseSceneName == "moon")
					{
						((Component)self.childLocator.FindChild("PreEncounter")).gameObject.SetActive(false);
					}
					else
					{
						orig.Invoke(self);
					}
				};
				<>c.<>9__8_4 = val;
				obj = (object)val;
			}
			PreEncounter.OnExit += (hook_OnExit)obj;
			object obj2 = <>c.<>9__8_5;
			if (obj2 == null)
			{
				hook_OnEnter val2 = delegate(orig_OnEnter orig, EncounterFinished self)
				{
					//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
					//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
					//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
					//IL_0104: Unknown result type (might be due to invalid IL or missing references)
					//IL_0111: Unknown result type (might be due to invalid IL or missing references)
					//IL_0116: Unknown result type (might be due to invalid IL or missing references)
					//IL_0131: Unknown result type (might be due to invalid IL or missing references)
					//IL_013c: Unknown result type (might be due to invalid IL or missing references)
					//IL_0161: Unknown result type (might be due to invalid IL or missing references)
					//IL_0186: Unknown result type (might be due to invalid IL or missing references)
					//IL_018b: Unknown result type (might be due to invalid IL or missing references)
					//IL_018e: Unknown result type (might be due to invalid IL or missing references)
					//IL_0193: Unknown result type (might be due to invalid IL or missing references)
					//IL_0195: Unknown result type (might be due to invalid IL or missing references)
					//IL_01a6: Expected O, but got Unknown
					try
					{
						orig.Invoke(self);
					}
					catch (Exception)
					{
					}
					SceneDef sceneDefForCurrentScene = SceneCatalog.GetSceneDefForCurrentScene();
					if (Object.op_Implicit((Object)(object)sceneDefForCurrentScene) && sceneDefForCurrentScene.baseSceneName == "moon")
					{
						((BrotherEncounterBaseState)self).childLocator = ((EntityState)self).GetComponent<ChildLocator>();
						if (Object.op_Implicit((Object)(object)((BrotherEncounterBaseState)self).childLocator))
						{
							Transform val3 = ((BrotherEncounterBaseState)self).childLocator.FindChild("ArenaWalls");
							Transform val4 = ((BrotherEncounterBaseState)self).childLocator.FindChild("ArenaNodes");
							if (Object.op_Implicit((Object)(object)val3))
							{
								((Component)val3).gameObject.SetActive(false);
							}
							if (Object.op_Implicit((Object)(object)val4))
							{
								((Component)val4).gameObject.SetActive(false);
							}
						}
						if (froggy)
						{
							Transform val5 = ((BrotherEncounterBaseState)self).childLocator.FindChild("CenterOrbEffect");
							Vector3 val6 = default(Vector3);
							((Vector3)(ref val6))..ctor(0f, 0f, 5f);
							GameObject val7 = Object.Instantiate<GameObject>(frogPrefab, val5.position + val6, Quaternion.identity);
							PickupIndex pickupIndex = PickupCatalog.FindPickupIndex((ItemTier)3);
							Highlight[] componentsInChildren = val7.GetComponentsInChildren<Highlight>();
							foreach (Highlight val8 in componentsInChildren)
							{
								val8.pickupIndex = pickupIndex;
								val8.highlightColor = (HighlightColor)2;
								val8.isOn = true;
							}
							val7.AddComponent<Light>().color = ((PickupIndex)(ref pickupIndex)).GetPickupColor();
							if (NetworkServer.active)
							{
								NetworkServer.Spawn(val7);
							}
							EffectManager.SpawnEffect(AssetReferences.fragileDamageBonusBreakEffectPrefab, new EffectData
							{
								origin = val5.position + val6
							}, false);
						}
					}
				};
				<>c.<>9__8_5 = val2;
				obj2 = (object)val2;
			}
			EncounterFinished.OnEnter += (hook_OnEnter)obj2;
			void Cleanup(Run run2)
			{
				//IL_0008: Unknown result type (might be due to invalid IL or missing references)
				//IL_0012: Expected O, but got Unknown
				Active.OnEnter -= new hook_OnEnter(EmpowerMoon);
				Run.onRunDestroyGlobal -= Cleanup;
			}
		}

		internal void EmpowerMoon(orig_OnEnter orig, Active self)
		{
			orig.Invoke(self);
			if (NetworkServer.active)
			{
				((LunarTeleporterBaseState)self).teleporterInteraction.sceneExitController.destinationScene = SceneCatalog.GetSceneDefFromSceneName("moon");
			}
		}

		internal void HandleLobbyConfigCompat()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			ModConfigEntry val = new ModConfigEntry();
			val.DisplayName = "Powerfully Slow";
			val.SectionFields.Add("Old Moon", new List<IConfigField>
			{
				ConfigFieldUtilities.CreateFromBepInExConfigEntry<int>(repeatChance),
				ConfigFieldUtilities.CreateFromBepInExConfigEntry<bool>(frogger)
			});
			ModConfigCatalog.Add(val);
		}
	}
}