Decompiled source of NolvlupFlash v2.0.1

NolvlupFlash.dll

Decompiled 5 days ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using On.RoR2;
using RoR2;
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("NolvlupFlash")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+392495c226c0b1cc914d66ff65fe4f757252d785")]
[assembly: AssemblyProduct("NolvlupFlash")]
[assembly: AssemblyTitle("NolvlupFlash")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace NolvlupFlash;

[BepInPlugin("com.FortressForce.NolvlupFlash", "No Level Up Flash", "2.0.0")]
public class NolvlupFlashPlugin : BaseUnityPlugin
{
	public enum LevelUpMode
	{
		Both,
		Flash,
		Ding,
		None
	}

	private static ConfigEntry<LevelUpMode> ConfigPlayer;

	private static ConfigEntry<LevelUpMode> ConfigEnemies;

	private static ConfigEntry<LevelUpMode> ConfigDrones;

	private static ConfigEntry<LevelUpMode> ConfigDevotion;

	private ItemIndex devotionItemIndex = (ItemIndex)(-1);

	private ArtifactDef devotionArtifactDef;

	public void Awake()
	{
		//IL_0087: Unknown result type (might be due to invalid IL or missing references)
		//IL_0091: Expected O, but got Unknown
		ConfigPlayer = ((BaseUnityPlugin)this).Config.Bind<LevelUpMode>("Categories", "Player", LevelUpMode.Both, "Behavior when YOU level up.");
		ConfigEnemies = ((BaseUnityPlugin)this).Config.Bind<LevelUpMode>("Categories", "Enemies", LevelUpMode.None, "Behavior when Monsters/Bosses level up.");
		ConfigDrones = ((BaseUnityPlugin)this).Config.Bind<LevelUpMode>("Categories", "Drones", LevelUpMode.None, "Behavior when mechanical allies (Drones, Turrets) level up.");
		ConfigDevotion = ((BaseUnityPlugin)this).Config.Bind<LevelUpMode>("Categories", "Devotion Minions", LevelUpMode.None, "Behavior when Devotion-bound Lemurians level up.");
		CharacterBody.OnLevelUp += new hook_OnLevelUp(CharacterBody_OnLevelUp);
		RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, (Action)delegate
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			devotionItemIndex = ItemCatalog.FindItemIndex("DevotionItem");
			devotionArtifactDef = ArtifactCatalog.FindArtifactDef("Devotion");
		});
		((BaseUnityPlugin)this).Logger.LogInfo((object)"NolvlupFlash 2.0 loaded! Ready to categorize.");
	}

	private void CharacterBody_OnLevelUp(orig_OnLevelUp orig, CharacterBody self)
	{
		//IL_0020: Unknown result type (might be due to invalid IL or missing references)
		//IL_0026: Invalid comparison between Unknown and I4
		//IL_003b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0041: Invalid comparison between Unknown and I4
		//IL_009e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0057: Unknown result type (might be due to invalid IL or missing references)
		//IL_012a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0135: Unknown result type (might be due to invalid IL or missing references)
		LevelUpMode levelUpMode = LevelUpMode.Both;
		if (self.isPlayerControlled)
		{
			levelUpMode = ConfigPlayer.Value;
		}
		else if ((int)self.teamComponent.teamIndex != 1)
		{
			levelUpMode = ConfigEnemies.Value;
		}
		else
		{
			bool flag = false;
			if ((int)devotionItemIndex != -1 && Object.op_Implicit((Object)(object)self.inventory) && self.inventory.GetItemCount(devotionItemIndex) > 0)
			{
				flag = true;
			}
			if (!flag && (Object)(object)devotionArtifactDef != (Object)null && RunArtifactManager.instance.IsArtifactEnabled(devotionArtifactDef) && self.baseNameToken.Contains("LEMURIAN"))
			{
				flag = true;
			}
			bool flag2 = ((Enum)self.bodyFlags).HasFlag((Enum)(object)(BodyFlags)2);
			levelUpMode = (flag ? ConfigDevotion.Value : ((!flag2) ? ConfigDrones.Value : ConfigDrones.Value));
		}
		switch (levelUpMode)
		{
		case LevelUpMode.Both:
			orig.Invoke(self);
			break;
		case LevelUpMode.Ding:
			Util.PlaySound("Play_UI_levelUp", ((Component)self).gameObject);
			break;
		case LevelUpMode.Flash:
		{
			GameObject val = Resources.Load<GameObject>("Prefabs/Effects/LevelUpEffect");
			if (Object.op_Implicit((Object)(object)val))
			{
				Object.Instantiate<GameObject>(val, ((Component)self).transform.position, ((Component)self).transform.rotation).transform.parent = ((Component)self).transform;
			}
			break;
		}
		case LevelUpMode.None:
			break;
		}
	}
}