Decompiled source of Powerfully Slow Moon v1.3.0

PowerfullySlow.dll

Decompiled 8 months 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.LunarTeleporter;
using EntityStates.Missions.BrotherEncounter;
using InLobbyConfig;
using InLobbyConfig.Fields;
using MonoMod.RuntimeDetour;
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.0", FrameworkDisplayName = ".NET Standard 2.0")]
[assembly: AssemblyCompany("PowerfullySlow")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+dc3c63f8043ea2277dec5f28ddcc3914ebce0876")]
[assembly: AssemblyProduct("PowerfullySlow")]
[assembly: AssemblyTitle("PowerfullySlow")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace PowerfullySlow;

[BepInPlugin("xyz.yekoc.PowerfullySlow", "Powerfully Slow Moon", "1.3.0")]
[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 hook_OnEnter <>9__8_3;

		internal void <Awake>b__8_3(orig_OnEnter orig, EncounterFinished self)
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Expected O, but got Unknown
			orig.Invoke(self);
			if (froggy)
			{
				Transform val = ((BrotherEncounterBaseState)self).childLocator.FindChild("CenterOrbEffect");
				GameObject val2 = Object.Instantiate<GameObject>(frogPrefab, val.position, Quaternion.identity);
				PickupIndex pickupIndex = PickupCatalog.FindPickupIndex((ItemTier)3);
				Highlight[] componentsInChildren = val2.GetComponentsInChildren<Highlight>();
				foreach (Highlight val3 in componentsInChildren)
				{
					val3.pickupIndex = pickupIndex;
					val3.highlightColor = (HighlightColor)2;
					val3.isOn = true;
				}
				val2.AddComponent<Light>().color = ((PickupIndex)(ref pickupIndex)).GetPickupColor();
				if (NetworkServer.active)
				{
					NetworkServer.Spawn(val2);
				}
				EffectManager.SpawnEffect(AssetReferences.fragileDamageBonusBreakEffectPrefab, new EffectData
				{
					origin = val.position
				}, 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_0097: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a1: Expected O, but got Unknown
		//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b3: Expected O, but got Unknown
		//IL_0108: 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_00d3: 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();
		}
		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_3;
		if (obj == null)
		{
			hook_OnEnter val = delegate(orig_OnEnter orig, EncounterFinished self)
			{
				//IL_002d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0032: Unknown result type (might be due to invalid IL or missing references)
				//IL_003e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0043: Unknown result type (might be due to invalid IL or missing references)
				//IL_005c: Unknown result type (might be due to invalid IL or missing references)
				//IL_005d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0065: Unknown result type (might be due to invalid IL or missing references)
				//IL_0089: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c5: Expected O, but got Unknown
				orig.Invoke(self);
				if (froggy)
				{
					Transform val2 = ((BrotherEncounterBaseState)self).childLocator.FindChild("CenterOrbEffect");
					GameObject val3 = Object.Instantiate<GameObject>(frogPrefab, val2.position, Quaternion.identity);
					PickupIndex pickupIndex = PickupCatalog.FindPickupIndex((ItemTier)3);
					Highlight[] componentsInChildren = val3.GetComponentsInChildren<Highlight>();
					foreach (Highlight val4 in componentsInChildren)
					{
						val4.pickupIndex = pickupIndex;
						val4.highlightColor = (HighlightColor)2;
						val4.isOn = true;
					}
					val3.AddComponent<Light>().color = ((PickupIndex)(ref pickupIndex)).GetPickupColor();
					if (NetworkServer.active)
					{
						NetworkServer.Spawn(val3);
					}
					EffectManager.SpawnEffect(AssetReferences.fragileDamageBonusBreakEffectPrefab, new EffectData
					{
						origin = val2.position
					}, false);
				}
			};
			<>c.<>9__8_3 = val;
			obj = (object)val;
		}
		EncounterFinished.OnEnter += (hook_OnEnter)obj;
		new Hook((MethodBase)typeof(BrotherEncounterBaseState).GetProperty("shouldEnableArenaWalls", (BindingFlags)(-1)).GetMethod, typeof(PowerfullySlowPlugin).GetMethod("UnImprison", (BindingFlags)(-1)));
		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;
			froggy = false;
		}
	}

	internal static bool UnImprison(Func<BrotherEncounterBaseState, bool> orig, BrotherEncounterBaseState self)
	{
		return !(((object)self).GetType() == typeof(EncounterFinished)) && orig(self);
	}

	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);
	}
}