Decompiled source of RuinedPaladin v1.2.1

RuinedPaladin.dll

Decompiled 2 months ago
using System;
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.Configuration;
using EntityStates;
using EntityStates.FalseSon;
using Microsoft.CodeAnalysis;
using On.EntityStates.FalseSon;
using PaladinMod;
using R2API;
using RoR2;
using RoR2.Skills;
using UnityEngine;
using UnityEngine.AddressableAssets;

[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("RuinedPaladin")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("RuinedPaladin")]
[assembly: AssemblyTitle("RuinedPaladin")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[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 RuinedPaladin
{
	[BepInPlugin("acanthi.RuinedPaladin", "RuinedPaladin", "1.1.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class RuinedPaladin : BaseUnityPlugin
	{
		public const string PluginGUID = "acanthi.RuinedPaladin";

		public const string PluginAuthor = "acanthi";

		public const string PluginName = "RuinedPaladin";

		public const string PluginVersion = "1.1.0";

		private ConfigEntry<bool> shouldReduceCooldown;

		public void Start()
		{
			AddSkills();
			AddSoundbank();
		}

		public void Awake()
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Expected O, but got Unknown
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Expected O, but got Unknown
			AddTokens();
			LunarSpikes.OnEnter += new hook_OnEnter(OnEntityStatesFalseSonLunarSpikesOnEnter);
			LunarStake.OnEnter += new hook_OnEnter(OnEntityStatesFalseSonLunarStakeOnEnter);
			shouldReduceCooldown = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "ShouldReduceCooldown", true, "Reduces base cooldown for Spikes (4 -> 3), Stakes (12 -> 8) for more fluid-feeling gameplay.");
		}

		private void OnEntityStatesFalseSonLunarStakeOnEnter(orig_OnEnter orig, LunarStake self)
		{
			orig.Invoke(self);
			if (((EntityState)self).characterBody.baseNameToken == "PALADIN_NAME")
			{
				((EntityState)self).PlayAnimation("LeftArm, Override", "LunarShard", "LunarSpike.playbackRate", ((LunarSpikes)self).duration * 5f, 0f);
			}
		}

		private void OnEntityStatesFalseSonLunarSpikesOnEnter(orig_OnEnter orig, LunarSpikes self)
		{
			orig.Invoke(self);
			if (((EntityState)self).characterBody.baseNameToken == "PALADIN_NAME")
			{
				((EntityState)self).PlayAnimation("LeftArm, Override", "LunarShard", "LunarSpike.playbackRate", self.duration * 5f, 0f);
				Util.PlayAttackSpeedSound("Play_falseson_skill2_lunarSpikes_shoot", ((EntityState)self).gameObject, self.attackSoundPitch);
			}
		}

		public void AddSoundbank()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				GameObject val = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/DLC2/FalseSon/FalseSonBody.prefab").WaitForCompletion();
				AkBank component = val.GetComponent<AkBank>();
				CopyAkBank(component, PaladinPlugin.characterPrefab);
			}
			catch
			{
				Debug.Log((object)"RuinedPaladin - Something Stupid Went On Here!");
			}
		}

		public void CopyAkBank(AkBank original, GameObject destination)
		{
			Type type = ((object)original).GetType();
			Component obj = destination.AddComponent(type);
			FieldInfo[] fields = type.GetFields();
			FieldInfo[] array = fields;
			foreach (FieldInfo fieldInfo in array)
			{
				fieldInfo.SetValue(obj, fieldInfo.GetValue(original));
			}
		}

		public void AddSkills()
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: 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_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Expected O, but got Unknown
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: 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_015d: Expected O, but got Unknown
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				SkillLocator component = PaladinPlugin.characterPrefab.GetComponent<SkillLocator>();
				SkillFamily skillFamily = component.secondary.skillFamily;
				SkillDef val = Object.Instantiate<SkillDef>(Addressables.LoadAssetAsync<SkillDef>((object)"RoR2/DLC2/FalseSon/FalseSonBodyLunarSpikes.asset").WaitForCompletion());
				val.baseMaxStock = 6;
				if (shouldReduceCooldown.Value)
				{
					val.baseRechargeInterval = 3f;
				}
				val.skillNameToken = "RUINEDPALADIN_LUNAR_SPIKES_NAME";
				val.skillDescriptionToken = "RUINEDPALADIN_LUNAR_SPIKES_DESC";
				Array.Resize(ref skillFamily.variants, skillFamily.variants.Length + 1);
				Variant[] variants = skillFamily.variants;
				int num = skillFamily.variants.Length - 1;
				Variant val2 = new Variant
				{
					skillDef = val
				};
				((Variant)(ref val2)).viewableNode = new Node(val.skillNameToken, false, (Node)null);
				variants[num] = val2;
				SkillDef val3 = Object.Instantiate<SkillDef>(Addressables.LoadAssetAsync<SkillDef>((object)"RoR2/DLC2/FalseSon/FalseSonLunarStake.asset").WaitForCompletion());
				val3.baseMaxStock = 3;
				if (shouldReduceCooldown.Value)
				{
					val3.baseRechargeInterval = 8f;
				}
				val3.skillNameToken = "RUINEDPALADIN_LUNAR_STAKES_NAME";
				val3.skillDescriptionToken = "RUINEDPALADIN_LUNAR_STAKES_DESC";
				Array.Resize(ref skillFamily.variants, skillFamily.variants.Length + 1);
				Variant[] variants2 = skillFamily.variants;
				int num2 = skillFamily.variants.Length - 1;
				val2 = new Variant
				{
					skillDef = val3
				};
				((Variant)(ref val2)).viewableNode = new Node(val.skillNameToken, false, (Node)null);
				variants2[num2] = val2;
			}
			catch (Exception ex)
			{
				Debug.LogException(ex);
			}
		}

		private void AddTokens()
		{
			LanguageAPI.Add("RUINEDPALADIN_LUNAR_SPIKES_NAME", "Ruined Spikes");
			LanguageAPI.Add("RUINEDPALADIN_LUNAR_SPIKES_DESC", "<style=cIsUtility>Lunar Ruin</style>. <style=cIsUtility>Agile</style>. Throw a Lunar Spike for <style=cIsDamage>150% damage</style>. Hold up to <style=cIsDamage>6 shards</style>.");
			LanguageAPI.Add("RUINEDPALADIN_LUNAR_STAKES_NAME", "Ruined Stakes");
			LanguageAPI.Add("RUINEDPALADIN_LUNAR_STAKES_DESC", "<style=cIsUtility>Lunar Ruin</style>. Fire a <style=cIsDamage>piercing</style>, <style=cIsDamage>lightning</style> infused Lunar Stake for <style=cIsDamage>300% damage</style>. Hold up to <style=cIsDamage>3 shards</style>.");
		}
	}
}