Decompiled source of PerfectedLoopTri v1.0.3

plugin/PerfectedLoopTri.dll

Decompiled a week ago
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using On.RoR2;
using R2API;
using R2API.Utils;
using RoR2;
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 = "")]
[assembly: AssemblyCompany("PerfectedLoopTri")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("PerfectedLoopTri")]
[assembly: AssemblyTitle("PerfectedLoopTri")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
namespace PerfectedLoopTri;

public enum ConfigAddTo
{
	Disable,
	TierOne,
	TierGilded,
	TierTwo
}
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInPlugin("com.kking117.PerfectedLoop3", "PerfectedLoop3", "1.0.3")]
[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
public class PerfectedLoopTri : BaseUnityPlugin
{
	public const string MODUID = "com.kking117.PerfectedLoop3";

	public const string MODNAME = "PerfectedLoop3";

	public const string MODVERSION = "1.0.3";

	internal static ManualLogSource ModLogger;

	internal static PluginInfo pluginInfo;

	private float Tier_Lunar_Cost = 6f;

	private float Lunar_Perfected_Health = 2f;

	private float Lunar_Perfected_Damage = 2f;

	private bool Tier_Gilded_AllowAny = false;

	private float Tier_Gilded_Cost = 6f;

	private float Tier_Gilded_CostHonor = 3f;

	private int Tier_Gilded_StartStageCount = 3;

	private bool Tier_Gilded_Clear = false;

	private int Tier_One_EndStageCount = 0;

	private ConfigAddTo Gilded_Tier = ConfigAddTo.TierGilded;

	private float Gilded_Health = 6f;

	private float Gilded_Damage = 3f;

	private float GildedHonor_Health = 6f;

	private float GildedHonor_Damage = 3f;

	private ConfigAddTo Mod_Perfected_Tier = ConfigAddTo.TierTwo;

	private float Mod_Perfected_Health = 14.4f;

	private float Mod_Perfected_Damage = 6f;

	private float Mod_PerfectedHonor_Health = 14.4f;

	private float Mod_PerfectedHonor_Damage = 6f;

	private ConfigAddTo Mod_Void_Tier = ConfigAddTo.Disable;

	private float Mod_Void_Health = 1f;

	private float Mod_Void_Damage = 1f;

	private float Mod_VoidHonor_Health = 1f;

	private float Mod_VoidHonor_Damage = 1f;

	private EliteDef Base_VoidDef = Addressables.LoadAssetAsync<EliteDef>((object)"RoR2/DLC1/EliteVoid/edVoid.asset").WaitForCompletion();

	private EliteDef Base_PerfectedDef = Addressables.LoadAssetAsync<EliteDef>((object)"RoR2/Base/EliteLunar/edLunar.asset").WaitForCompletion();

	private EliteDef Base_GildedDef = Addressables.LoadAssetAsync<EliteDef>((object)"RoR2/DLC2/Elites/EliteAurelionite/edAurelionite.asset").WaitForCompletion();

	private EliteDef Base_GildedHonorDef = Addressables.LoadAssetAsync<EliteDef>((object)"RoR2/DLC2/Elites/EliteAurelionite/edAurelioniteHonor.asset").WaitForCompletion();

	public EliteDef Custom_VoidDef = null;

	public EliteDef Custom_VoidHonorDef = null;

	public EliteDef Custom_PerfectedDef = null;

	public EliteDef Custom_PerfectedHonorDef = null;

	public void Awake()
	{
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0069: Expected O, but got Unknown
		ModLogger = ((BaseUnityPlugin)this).Logger;
		pluginInfo = ((BaseUnityPlugin)this).Info;
		ReadConfigs();
		UpdatePerfected();
		UpdateGilded();
		if (Mod_Perfected_Tier != 0)
		{
			CreatePerfected();
		}
		if (Mod_Void_Tier != 0)
		{
			CreateVoid();
		}
		CombatDirector.Init += new hook_Init(OnInit);
	}

	private void OnInit(orig_Init orig)
	{
		orig.Invoke();
		EliteTierDef val = EliteAPI.VanillaEliteTiers[1];
		if (val != null)
		{
			List<EliteDef> list = val.eliteTypes.ToList();
			if (Mod_Perfected_Tier == ConfigAddTo.TierOne)
			{
				list.Add(Custom_PerfectedDef);
			}
			if (Mod_Void_Tier == ConfigAddTo.TierOne)
			{
				list.Add(Custom_VoidDef);
			}
			if (Gilded_Tier == ConfigAddTo.TierOne)
			{
				list.Add(Base_GildedDef);
			}
			if (Tier_One_EndStageCount != 0)
			{
				if (Tier_One_EndStageCount < 0)
				{
					val.isAvailable = (EliteRules rules) => CombatDirector.NotEliteOnlyArtifactActive() && (int)rules == 0;
				}
				else
				{
					val.isAvailable = (EliteRules rules) => CombatDirector.NotEliteOnlyArtifactActive() && (int)rules == 0 && Run.instance.stageClearCount + 1 <= Tier_One_EndStageCount;
				}
			}
			val.eliteTypes = list.ToArray();
		}
		EliteTierDef val2 = EliteAPI.VanillaEliteTiers[2];
		if (val2 != null)
		{
			List<EliteDef> list2 = val2.eliteTypes.ToList();
			if (Mod_Perfected_Tier == ConfigAddTo.TierOne)
			{
				list2.Add(Custom_PerfectedHonorDef);
			}
			if (Mod_Void_Tier == ConfigAddTo.TierOne)
			{
				list2.Add(Custom_VoidHonorDef);
			}
			if (Gilded_Tier == ConfigAddTo.TierOne)
			{
				list2.Add(Base_GildedHonorDef);
			}
			if (Tier_One_EndStageCount != 0)
			{
				if (Tier_One_EndStageCount < 0)
				{
					val2.isAvailable = (EliteRules rules) => CombatDirector.IsEliteOnlyArtifactActive();
				}
				else
				{
					val2.isAvailable = (EliteRules rules) => CombatDirector.IsEliteOnlyArtifactActive() && Run.instance.stageClearCount + 1 <= Tier_One_EndStageCount;
				}
			}
			val2.eliteTypes = list2.ToArray();
		}
		EliteTierDef val3 = EliteAPI.VanillaEliteTiers[3];
		if (val3 != null)
		{
			List<EliteDef> list3 = val3.eliteTypes.ToList();
			if (Tier_Gilded_Clear)
			{
				List<EliteDef> list4 = new List<EliteDef>
				{
					Elites.FireHonor,
					Elites.LightningHonor,
					Elites.IceHonor,
					Elites.EarthHonor,
					Elites.AurelioniteHonor
				};
				foreach (EliteDef item in list4)
				{
					list3.Remove(item);
				}
			}
			if (Mod_Perfected_Tier == ConfigAddTo.TierGilded)
			{
				list3.Add(Custom_PerfectedHonorDef);
			}
			if (Mod_Void_Tier == ConfigAddTo.TierGilded)
			{
				list3.Add(Custom_VoidHonorDef);
			}
			if (Gilded_Tier == ConfigAddTo.TierGilded)
			{
				list3.Add(Base_GildedHonorDef);
			}
			val3.eliteTypes = list3.ToArray();
			if (Tier_Gilded_AllowAny)
			{
				val3.isAvailable = (EliteRules rules) => CombatDirector.IsEliteOnlyArtifactActive() && Run.instance.stageClearCount + 1 >= Tier_Gilded_StartStageCount;
			}
			else
			{
				val3.isAvailable = (EliteRules rules) => CombatDirector.IsEliteOnlyArtifactActive() && (int)rules == 0 && Run.instance.stageClearCount + 1 >= Tier_Gilded_StartStageCount;
			}
			val3.costMultiplier = Tier_Gilded_CostHonor;
		}
		EliteTierDef val4 = EliteAPI.VanillaEliteTiers[4];
		if (val4 != null)
		{
			List<EliteDef> list5 = val4.eliteTypes.ToList();
			if (Tier_Gilded_Clear)
			{
				List<EliteDef> list6 = new List<EliteDef>
				{
					Elites.Fire,
					Elites.Lightning,
					Elites.Ice,
					Elites.Earth,
					Elites.Aurelionite
				};
				foreach (EliteDef item2 in list6)
				{
					list5.Remove(item2);
				}
			}
			if (Mod_Perfected_Tier == ConfigAddTo.TierGilded)
			{
				list5.Add(Custom_PerfectedDef);
			}
			if (Mod_Void_Tier == ConfigAddTo.TierGilded)
			{
				list5.Add(Custom_VoidDef);
			}
			if (Gilded_Tier == ConfigAddTo.TierGilded)
			{
				list5.Add(Base_GildedDef);
			}
			val4.eliteTypes = list5.ToArray();
			val4.isAvailable = (EliteRules rules) => CombatDirector.NotEliteOnlyArtifactActive() && (int)rules == 0 && Run.instance.stageClearCount + 1 >= Tier_Gilded_StartStageCount;
			val4.costMultiplier = Tier_Gilded_Cost;
		}
		EliteTierDef val5 = EliteAPI.VanillaEliteTiers[5];
		if (val5 != null)
		{
			List<EliteDef> list7 = val5.eliteTypes.ToList();
			if (Mod_Perfected_Tier == ConfigAddTo.TierTwo)
			{
				list7.Add(Custom_PerfectedDef);
			}
			if (Mod_Void_Tier == ConfigAddTo.TierTwo)
			{
				list7.Add(Custom_VoidDef);
			}
			if (Gilded_Tier == ConfigAddTo.TierTwo)
			{
				list7.Add(Base_GildedDef);
			}
			val5.eliteTypes = list7.ToArray();
		}
		EliteTierDef val6 = EliteAPI.VanillaEliteTiers[6];
		if (val6 != null)
		{
			val6.costMultiplier = Tier_Lunar_Cost;
		}
	}

	private void UpdateGilded()
	{
		Base_GildedDef.healthBoostCoefficient = Gilded_Health;
		Base_GildedDef.damageBoostCoefficient = Gilded_Damage;
		Base_GildedHonorDef.healthBoostCoefficient = GildedHonor_Health;
		Base_GildedHonorDef.damageBoostCoefficient = GildedHonor_Damage;
	}

	private void UpdatePerfected()
	{
		Base_PerfectedDef.healthBoostCoefficient = Lunar_Perfected_Health;
		Base_PerfectedDef.damageBoostCoefficient = Lunar_Perfected_Damage;
	}

	private void CreateVoid()
	{
		//IL_006b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0070: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a6: Expected O, but got Unknown
		//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ca: Expected O, but got Unknown
		//IL_014f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0154: Unknown result type (might be due to invalid IL or missing references)
		//IL_0184: Unknown result type (might be due to invalid IL or missing references)
		//IL_018a: Expected O, but got Unknown
		//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
		//IL_01af: Expected O, but got Unknown
		Custom_VoidDef = ScriptableObject.CreateInstance<EliteDef>();
		((Object)Custom_VoidDef).name = "edVoidTri";
		Custom_VoidDef.modifierToken = Base_VoidDef.modifierToken;
		Custom_VoidDef.shaderEliteRampIndex = Base_VoidDef.shaderEliteRampIndex;
		Custom_VoidDef.eliteEquipmentDef = Base_VoidDef.eliteEquipmentDef;
		Custom_VoidDef.color = Base_VoidDef.color;
		Custom_VoidDef.healthBoostCoefficient = Mod_Void_Health;
		Custom_VoidDef.damageBoostCoefficient = Mod_Void_Damage;
		EliteTierDef[] array = (EliteTierDef[])(object)new EliteTierDef[1]
		{
			new EliteTierDef()
		};
		array[0].eliteTypes = (EliteDef[])(object)new EliteDef[1] { Custom_VoidDef };
		CustomElite val = new CustomElite(Custom_VoidDef, (IEnumerable<EliteTierDef>)array);
		EliteAPI.Add(val);
		if (Mod_Void_Tier != ConfigAddTo.TierTwo)
		{
			Custom_VoidHonorDef = ScriptableObject.CreateInstance<EliteDef>();
			((Object)Custom_VoidHonorDef).name = "edVoidHonorTri";
			Custom_VoidHonorDef.modifierToken = Base_VoidDef.modifierToken;
			Custom_VoidHonorDef.shaderEliteRampIndex = Base_VoidDef.shaderEliteRampIndex;
			Custom_VoidHonorDef.eliteEquipmentDef = Base_VoidDef.eliteEquipmentDef;
			Custom_VoidHonorDef.color = Base_VoidDef.color;
			Custom_VoidHonorDef.healthBoostCoefficient = Mod_VoidHonor_Health;
			Custom_VoidHonorDef.damageBoostCoefficient = Mod_VoidHonor_Damage;
			EliteTierDef[] array2 = (EliteTierDef[])(object)new EliteTierDef[1]
			{
				new EliteTierDef()
			};
			array2[0].eliteTypes = (EliteDef[])(object)new EliteDef[1] { Custom_VoidHonorDef };
			CustomElite val2 = new CustomElite(Custom_VoidHonorDef, (IEnumerable<EliteTierDef>)array2);
			EliteAPI.Add(val2);
		}
	}

	private void CreatePerfected()
	{
		//IL_006b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0070: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a6: Expected O, but got Unknown
		//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ca: Expected O, but got Unknown
		//IL_014f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0154: Unknown result type (might be due to invalid IL or missing references)
		//IL_0184: Unknown result type (might be due to invalid IL or missing references)
		//IL_018a: Expected O, but got Unknown
		//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
		//IL_01af: Expected O, but got Unknown
		Custom_PerfectedDef = ScriptableObject.CreateInstance<EliteDef>();
		((Object)Custom_PerfectedDef).name = "edLunarTri";
		Custom_PerfectedDef.modifierToken = Base_PerfectedDef.modifierToken;
		Custom_PerfectedDef.shaderEliteRampIndex = Base_PerfectedDef.shaderEliteRampIndex;
		Custom_PerfectedDef.eliteEquipmentDef = Base_PerfectedDef.eliteEquipmentDef;
		Custom_PerfectedDef.color = Base_PerfectedDef.color;
		Custom_PerfectedDef.healthBoostCoefficient = Mod_Perfected_Health;
		Custom_PerfectedDef.damageBoostCoefficient = Mod_Perfected_Damage;
		EliteTierDef[] array = (EliteTierDef[])(object)new EliteTierDef[1]
		{
			new EliteTierDef()
		};
		array[0].eliteTypes = (EliteDef[])(object)new EliteDef[1] { Custom_PerfectedDef };
		CustomElite val = new CustomElite(Custom_PerfectedDef, (IEnumerable<EliteTierDef>)array);
		EliteAPI.Add(val);
		if (Mod_Perfected_Tier != ConfigAddTo.TierTwo)
		{
			Custom_PerfectedHonorDef = ScriptableObject.CreateInstance<EliteDef>();
			((Object)Custom_PerfectedHonorDef).name = "edLunarHonorTri";
			Custom_PerfectedHonorDef.modifierToken = Base_PerfectedDef.modifierToken;
			Custom_PerfectedHonorDef.shaderEliteRampIndex = Base_PerfectedDef.shaderEliteRampIndex;
			Custom_PerfectedHonorDef.eliteEquipmentDef = Base_PerfectedDef.eliteEquipmentDef;
			Custom_PerfectedHonorDef.color = Base_PerfectedDef.color;
			Custom_PerfectedHonorDef.healthBoostCoefficient = Mod_PerfectedHonor_Health;
			Custom_PerfectedHonorDef.damageBoostCoefficient = Mod_PerfectedHonor_Damage;
			EliteTierDef[] array2 = (EliteTierDef[])(object)new EliteTierDef[1]
			{
				new EliteTierDef()
			};
			array2[0].eliteTypes = (EliteDef[])(object)new EliteDef[1] { Custom_PerfectedHonorDef };
			CustomElite val2 = new CustomElite(Custom_PerfectedHonorDef, (IEnumerable<EliteTierDef>)array2);
			EliteAPI.Add(val2);
		}
	}

	private void ReadConfigs()
	{
		Tier_Lunar_Cost = ((BaseUnityPlugin)this).Config.Bind<float>("Elite Tier - Lunar", "Cost", 6f, "Director cost for spawning. (6 = Vanilla)").Value;
		Lunar_Perfected_Health = ((BaseUnityPlugin)this).Config.Bind<float>("Elite - Vanilla Perfected", "Health", 2f, "Health multiplier. (2 = Vanilla) (Get x1.25 Shield from the Aspect)").Value;
		Lunar_Perfected_Damage = ((BaseUnityPlugin)this).Config.Bind<float>("Elite - Vanilla Perfected", "Damage", 2f, "Damage multiplier. (2 = Vanilla)").Value;
		Tier_One_EndStageCount = ((BaseUnityPlugin)this).Config.Bind<int>("Elite Tier - One", "Stage End Count", 0, "The minimun stage count that this elite tier stops being used on. (0 = Don't Change, -1 = Never Stop)").Value;
		Tier_Gilded_AllowAny = ((BaseUnityPlugin)this).Config.Bind<bool>("Elite Tier - Gilded", "Allow Any", true, "Allows most enemies to have affixes from this Elite Tier with Honor enabled. (True would be closer to T1 Elite behavior, False would be closer to T2 Elite.)").Value;
		Tier_Gilded_Cost = ((BaseUnityPlugin)this).Config.Bind<float>("Elite Tier - Gilded", "Cost", 6f, "Director cost for spawning. (6 = Vanilla)").Value;
		Tier_Gilded_CostHonor = ((BaseUnityPlugin)this).Config.Bind<float>("Elite Tier - Gilded", "Honor Cost", 3f, "Director cost for spawning. (3 = Vanilla)").Value;
		Tier_Gilded_StartStageCount = ((BaseUnityPlugin)this).Config.Bind<int>("Elite Tier - Gilded", "Stage Count", 3, "The minimun stage count that this elite tier becomes active on. (3 = Vanilla)").Value;
		Tier_Gilded_Clear = ((BaseUnityPlugin)this).Config.Bind<bool>("Elite Tier - Gilded", "Clear Tier", false, "Removes Blazing, Glacial, Overloading, Mending and Gilded from this Elite Tier and its Honor version.").Value;
		Gilded_Tier = ((BaseUnityPlugin)this).Config.Bind<ConfigAddTo>("Elite - Gilded", "Elite Tier", ConfigAddTo.TierGilded, "Add to which elite pool?").Value;
		Gilded_Health = ((BaseUnityPlugin)this).Config.Bind<float>("Elite - Gilded", "Health", 5f, "Health multiplier. (5 = Vanilla)").Value;
		Gilded_Damage = ((BaseUnityPlugin)this).Config.Bind<float>("Elite - Gilded", "Damage", 2.5f, "Damage multiplier. (2.5 = Vanilla)").Value;
		GildedHonor_Health = ((BaseUnityPlugin)this).Config.Bind<float>("Elite - Gilded", "Honor Health", 3.5f, "Health multiplier. (3.5 = Vanilla)").Value;
		GildedHonor_Damage = ((BaseUnityPlugin)this).Config.Bind<float>("Elite - Gilded", "Honor Damage", 2f, "Damage multiplier. (2 = Vanilla)").Value;
		Mod_Perfected_Tier = ((BaseUnityPlugin)this).Config.Bind<ConfigAddTo>("Elite - Modded Perfected", "Elite Tier", ConfigAddTo.TierTwo, "Add to which elite pool?").Value;
		Mod_Perfected_Health = ((BaseUnityPlugin)this).Config.Bind<float>("Elite - Modded Perfected", "Health", 14.4f, "Health multiplier. (2 = Vanilla) (Gets x1.25 Shield from the Aspect)").Value;
		Mod_Perfected_Damage = ((BaseUnityPlugin)this).Config.Bind<float>("Elite - Modded Perfected", "Damage", 6f, "Damage multiplier. (2 = Vanilla)").Value;
		Mod_PerfectedHonor_Health = ((BaseUnityPlugin)this).Config.Bind<float>("Elite - Modded Perfected", "Honor Health", 14.4f, "Health multiplier. (2 = Vanilla) (Gets x1.25 Shield from the Aspect)").Value;
		Mod_PerfectedHonor_Damage = ((BaseUnityPlugin)this).Config.Bind<float>("Elite - Modded Perfected", "Honor Damage", 6f, "Damage multiplier. (2 = Vanilla)").Value;
		Mod_Void_Tier = ((BaseUnityPlugin)this).Config.Bind<ConfigAddTo>("Elite - Voidtouched", "Elite Tier", ConfigAddTo.Disable, "Add to which elite pool?").Value;
		Mod_Void_Health = ((BaseUnityPlugin)this).Config.Bind<float>("Elite - Voidtouched", "Health", 1f, "Health multiplier. (Gets x1.5 Health from the Aspect)").Value;
		Mod_Void_Damage = ((BaseUnityPlugin)this).Config.Bind<float>("Elite - Voidtouched", "Damage", 1f, "Damage multiplier. (Gets x0.7 Damage from the Aspect)").Value;
		Mod_VoidHonor_Health = ((BaseUnityPlugin)this).Config.Bind<float>("Elite - Voidtouched", "Honor Health", 1f, "Health multiplier. (Gets x1.5 Health from the Aspect)").Value;
		Mod_VoidHonor_Damage = ((BaseUnityPlugin)this).Config.Bind<float>("Elite - Voidtouched", "Honor Damage", 1f, "Damage multiplier. (Gets x0.7 Damage from the Aspect)").Value;
	}
}