Decompiled source of FalseSonBossTweaks v1.0.7

FalseSonBossTweaks.dll

Decompiled 8 hours ago
using System;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using EntityStates;
using EntityStates.FalseSonBoss;
using EntityStates.MeridianEvent;
using EntityStates.PrimeMeridian;
using Microsoft.CodeAnalysis;
using On.EntityStates.FalseSonBoss;
using On.EntityStates.MeridianEvent;
using On.EntityStates.PrimeMeridian;
using On.RoR2;
using RoR2;
using RoR2.Skills;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("FalseSonBossTweaks")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+6b369228971b058836bb7dd7761d1d3b0faa8338")]
[assembly: AssemblyProduct("FalseSonBossTweaks")]
[assembly: AssemblyTitle("FalseSonBossTweaks")]
[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 FalseSonBossTweaks
{
	[BepInPlugin("Jeffdev.FalseSonBossTweaks", "FalseSonBossTweaks", "1.0.6")]
	public class FalseSonBossTweaks : BaseUnityPlugin
	{
		public class DelayedState : EntityState
		{
			private readonly float delay;

			private readonly EntityState nextState;

			public DelayedState(float delay, EntityState nextState)
			{
				this.delay = delay;
				this.nextState = nextState;
				((EntityState)this)..ctor();
			}

			public override void Update()
			{
				((EntityState)this).Update();
				if (((EntityState)this).fixedAge >= delay)
				{
					base.outer.SetNextState(nextState);
				}
			}
		}

		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static hook_Start <>9__11_0;

			public static Func<SkillDef, bool> <>9__15_0;

			public static Func<SkillDef, bool> <>9__16_0;

			internal void <Awake>b__11_0(orig_Start orig, MeridianEventLightningTrigger self)
			{
				self.levelstartMonsterCredit = monsterCredits.Value;
				orig.Invoke(self);
			}

			internal bool <Run_onRunStartGlobal>b__15_0(SkillDef skill)
			{
				if (skill.skillName == "Laser")
				{
					return skill.baseRechargeInterval == 35f;
				}
				return false;
			}

			internal bool <Run_onRunDestroyGlobal>b__16_0(SkillDef skill)
			{
				if (skill.skillName == "Laser")
				{
					return skill.baseRechargeInterval == 52.5f;
				}
				return false;
			}
		}

		public const string PluginGUID = "Jeffdev.FalseSonBossTweaks";

		public const string PluginAuthor = "Jeffdev";

		public const string PluginName = "FalseSonBossTweaks";

		public const string PluginVersion = "1.0.6";

		public MeridianEventState bossPhase;

		public static ConfigEntry<int> monsterCredits;

		public static ConfigEntry<float> dashSlamTime;

		public static ConfigEntry<bool> eliteGolems;

		public static ConfigEntry<int> golemAmount;

		public static ConfigEntry<bool> eclipseSevenChanges;

		public static ConfigEntry<bool> slowFalseSonLaser;

		public void Awake()
		{
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Expected O, but got Unknown
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Expected O, but got Unknown
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Expected O, but got Unknown
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Expected O, but got Unknown
			//IL_0142: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: Expected O, but got Unknown
			//IL_0153: Unknown result type (might be due to invalid IL or missing references)
			//IL_015d: Expected O, but got Unknown
			//IL_0164: Unknown result type (might be due to invalid IL or missing references)
			//IL_016e: Expected O, but got Unknown
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Expected O, but got Unknown
			Log.Init(((BaseUnityPlugin)this).Logger);
			monsterCredits = ((BaseUnityPlugin)this).Config.Bind<int>("General", "Meridian Credits", 320, "Change the amount of monster credits Prime Meridian has (450 is vanilla default)");
			dashSlamTime = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Time Between Dash and Slam", 0.4f, "Idle time between the dash and slam attack. (0 will make the boss have no idle time, which is how vanilla works. Keep it between 0-1 second, or else jank will happen.)");
			eliteGolems = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Pre Loop Elite Golems in Fight", false, "Allow golems to be elite in the fight in pre loop (true is vanilla default)");
			golemAmount = ((BaseUnityPlugin)this).Config.Bind<int>("General", "Max Golems in Fight", 4, "Max number of golems allowed to be spawned (5 is vanilla default)");
			eclipseSevenChanges = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Eclipse 7 Laser/Skill Disable Changes", true, "Change the skill cooldowns to be longer for laser and skill disable attacks in Eclipse 7 (false is vanilla default)");
			slowFalseSonLaser = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Slow False Son during Phase 2 Laser", true, "Gives the False Son a slowing debuff during Phase 2 (false is vanilla default)");
			object obj = <>c.<>9__11_0;
			if (obj == null)
			{
				hook_Start val = delegate(orig_Start orig, MeridianEventLightningTrigger self)
				{
					self.levelstartMonsterCredit = monsterCredits.Value;
					orig.Invoke(self);
				};
				<>c.<>9__11_0 = val;
				obj = (object)val;
			}
			MeridianEventLightningTrigger.Start += (hook_Start)obj;
			CorruptedPathsDash.GetNextStateAuthority += new hook_GetNextStateAuthority(CorruptedPathsDash_GetNextStateAuthority);
			LunarGazeHoldLeap.OnEnter += new hook_OnEnter(LunarGazeHoldLeap_OnEnter);
			LunarGazeLaserEnd.OnEnter += new hook_OnEnter(LunarGazeLaserEnd_OnEnter);
			MeridianEventTriggerInteraction.Start += new hook_Start(MeridianEventTriggerInteraction_Start);
			Phase1.OnEnter += new hook_OnEnter(Phase1_OnEnter);
			Phase2.OnEnter += new hook_OnEnter(Phase2_OnEnter);
			Phase3.OnEnter += new hook_OnEnter(Phase3_OnEnter);
			Run.onRunStartGlobal += Run_onRunStartGlobal;
			Run.onRunDestroyGlobal += Run_onRunDestroyGlobal;
		}

		private void MeridianEventTriggerInteraction_Start(orig_Start orig, MeridianEventTriggerInteraction self)
		{
			orig.Invoke(self);
			if (!Object.op_Implicit((Object)(object)self.phase2CombatDirector))
			{
				return;
			}
			CombatDirector component = self.phase2CombatDirector.GetComponent<CombatDirector>();
			if (Object.op_Implicit((Object)(object)component))
			{
				component.maxSquadCount = (uint)golemAmount.Value;
				if ((!Object.op_Implicit((Object)(object)Run.instance) || Run.instance.loopClearCount <= 0) && !eliteGolems.Value)
				{
					component.eliteBias = 9999f;
				}
				else
				{
					component.eliteBias = 0f;
				}
			}
		}

		private EntityState CorruptedPathsDash_GetNextStateAuthority(orig_GetNextStateAuthority orig, CorruptedPathsDash self)
		{
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Expected O, but got Unknown
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			((EntityState)self).skillLocator.primary.DeductStock(2);
			if (dashSlamTime.Value != 0f)
			{
				return (EntityState)(object)new DelayedState(dashSlamTime.Value, (EntityState)new FissureSlamWindup());
			}
			return (EntityState)(object)new DelayedState(0.01f, (EntityState)new FissureSlamWindup());
		}

		private void Run_onRunStartGlobal(Run obj)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Invalid comparison between Unknown and I4
			Log.Debug($"{obj.selectedDifficulty} {(object)(DifficultyIndex)9}");
			if ((int)obj.selectedDifficulty >= 9 && eclipseSevenChanges.Value)
			{
				SkillDef skillDef = SkillCatalog.GetSkillDef(SkillCatalog.FindSkillIndexByName("PrimeDevastator"));
				SkillDef skillDef2 = SkillCatalog.GetSkillDef(SkillCatalog.FindSkillIndexByName("LunarGazePlus"));
				SkillDef val = SkillCatalog.allSkillDefs.FirstOrDefault((Func<SkillDef, bool>)((SkillDef skill) => skill.skillName == "Laser" && skill.baseRechargeInterval == 35f));
				if ((Object)(object)skillDef == (Object)null || (Object)(object)skillDef2 == (Object)null || (Object)(object)val == (Object)null)
				{
					Log.Error($"One or more SkillDefs could not be found! Check skill names. {skillDef} | {skillDef2} | {val}");
					return;
				}
				skillDef.baseRechargeInterval *= 1.5f;
				skillDef2.baseRechargeInterval *= 1.5f;
				val.baseRechargeInterval *= 1.5f;
				Log.Debug($"Devestator Skill Cooldown: {skillDef.baseRechargeInterval}");
				Log.Debug($"Lunar Gaze Plus Skill Cooldown: {skillDef2.baseRechargeInterval}");
				Log.Debug($"Lunar Gaze Skill Cooldown: {val.baseRechargeInterval}");
			}
		}

		private void Run_onRunDestroyGlobal(Run obj)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Invalid comparison between Unknown and I4
			if ((int)obj.selectedDifficulty >= 9 && eclipseSevenChanges.Value)
			{
				SkillDef skillDef = SkillCatalog.GetSkillDef(SkillCatalog.FindSkillIndexByName("PrimeDevastator"));
				SkillDef skillDef2 = SkillCatalog.GetSkillDef(SkillCatalog.FindSkillIndexByName("LunarGazePlus"));
				SkillDef val = SkillCatalog.allSkillDefs.FirstOrDefault((Func<SkillDef, bool>)((SkillDef skill) => skill.skillName == "Laser" && skill.baseRechargeInterval == 52.5f));
				if ((Object)(object)skillDef == (Object)null || (Object)(object)skillDef2 == (Object)null || (Object)(object)val == (Object)null)
				{
					Log.Error($"One or more SkillDefs could not be found! Check skill names. {skillDef} | {skillDef2} | {val}");
					return;
				}
				skillDef.baseRechargeInterval /= 1.5f;
				skillDef2.baseRechargeInterval /= 1.5f;
				val.baseRechargeInterval /= 1.5f;
				Log.Debug($"Devestator Skill Cooldown: {skillDef.baseRechargeInterval}");
				Log.Debug($"Lunar Gaze Plus Skill Cooldown: {skillDef2.baseRechargeInterval}");
				Log.Debug($"Lunar Gaze Skill Cooldown: {val.baseRechargeInterval}");
			}
		}

		private void Phase1_OnEnter(orig_OnEnter orig, Phase1 self)
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			orig.Invoke(self);
			bossPhase = (MeridianEventState)2;
		}

		private void Phase2_OnEnter(orig_OnEnter orig, Phase2 self)
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			orig.Invoke(self);
			bossPhase = (MeridianEventState)3;
		}

		private void Phase3_OnEnter(orig_OnEnter orig, Phase3 self)
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			orig.Invoke(self);
			bossPhase = (MeridianEventState)4;
		}

		private void LunarGazeHoldLeap_OnEnter(orig_OnEnter orig, LunarGazeHoldLeap self)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Invalid comparison between Unknown and I4
			orig.Invoke(self);
			Log.Debug("Added Debuff to False Son!");
			if ((int)bossPhase == 3 && slowFalseSonLaser.Value)
			{
				((EntityState)self).characterBody.AddBuff(Buffs.Slow80);
			}
		}

		private void LunarGazeLaserEnd_OnEnter(orig_OnEnter orig, LunarGazeLaserEnd self)
		{
			orig.Invoke(self);
			foreach (CharacterBody readOnlyInstances in CharacterBody.readOnlyInstancesList)
			{
				if (Object.op_Implicit((Object)(object)readOnlyInstances) && ((Object)readOnlyInstances).name.Contains("FalseSonBoss") && readOnlyInstances.HasBuff(Buffs.Slow80))
				{
					readOnlyInstances.RemoveBuff(Buffs.Slow80);
					Debug.Log((object)"Removed Debuff from False Son!");
				}
			}
		}
	}
	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);
		}
	}
}