Decompiled source of ArtifactOfTheDrowned v1.1.2

ArtifactGesture.dll

Decompiled a year ago
using System;
using System.CodeDom.Compiler;
using System.ComponentModel;
using System.Diagnostics;
using System.Globalization;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using ArtifactGesture.Properties;
using BepInEx;
using On.RoR2;
using R2API;
using R2API.Utils;
using RoR2;
using UnityEngine;
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 = "")]
[assembly: AssemblyCompany("ArtifactGesture")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("ArtifactGesture")]
[assembly: AssemblyTitle("ArtifactGesture")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace ArtifactGesture
{
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("com.Borbo.ArtifactGesture", "This Mod Turns Gesture Into An Artifact So That People Can Stop Telling Me Removing Gesture In BalanceOverhaulRBO Was Unnecessary", "1.1.2")]
	[R2APISubmoduleDependency(new string[] { "ContentAddition", "LanguageAPI" })]
	public class Main : BaseUnityPlugin
	{
		public static AssetBundle iconBundle = LoadAssetBundle(Resources.misc);

		private ArtifactDef Gesture = ScriptableObject.CreateInstance<ArtifactDef>();

		public static float artifactCdr = 0.5f;

		public static AssetBundle LoadAssetBundle(byte[] resourceBytes)
		{
			if (resourceBytes == null)
			{
				throw new ArgumentNullException("resourceBytes");
			}
			return AssetBundle.LoadFromMemory(resourceBytes);
		}

		public void Awake()
		{
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Expected O, but got Unknown
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Expected O, but got Unknown
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Expected O, but got Unknown
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			LanguageAPI.Add("ARTIFACT_GESTURE_NAME", "Artifact of the Drowned");
			LanguageAPI.Add("ARTIFACT_GESTURE_DESC", "Dramatically reduce Equipment cooldown... <style=cIsHealth>BUT it automatically activates.</style>");
			Gesture.nameToken = "ARTIFACT_GESTURE_NAME";
			Gesture.descriptionToken = "ARTIFACT_GESTURE_DESC";
			Gesture.smallIconDeselectedSprite = iconBundle.LoadAsset<Sprite>("Assets/gesturedeactivated.png");
			Gesture.smallIconSelectedSprite = iconBundle.LoadAsset<Sprite>("Assets/gesture.png");
			Gesture.unlockableDef = UnlockableCatalog.GetUnlockableDef("SuicideHermitCrabs");
			EquipmentSlot.FixedUpdate += new hook_FixedUpdate(GestureArtifactLogic);
			ItemCatalog.Init += new hook_Init(RemoveGestureItem);
			Inventory.CalculateEquipmentCooldownScale += new hook_CalculateEquipmentCooldownScale(GestureArtifactCdr);
			ContentAddition.AddArtifactDef(Gesture);
			ItemDef val = LegacyResourcesAPI.Load<ItemDef>("ItemDefs/AutoCastEquipment");
			if (Object.op_Implicit((Object)(object)val))
			{
				val.tier = (ItemTier)5;
				val.deprecatedTier = (ItemTier)5;
			}
		}

		private float GestureArtifactCdr(orig_CalculateEquipmentCooldownScale orig, Inventory self)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			float num = orig.Invoke(self);
			if (RunArtifactManager.instance.IsArtifactEnabled(Gesture.artifactIndex))
			{
				num *= 1f - artifactCdr;
			}
			return num;
		}

		private void GestureArtifactLogic(orig_FixedUpdate orig, EquipmentSlot self)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			orig.Invoke(self);
			bool flag = false;
			if (self.equipmentIndex != Equipment.GoldGat.equipmentIndex && !((ButtonState)(ref self.inputBank.activateEquipment)).justPressed && RunArtifactManager.instance.IsArtifactEnabled(Gesture.artifactIndex))
			{
				flag = true;
			}
			bool isEquipmentActivationAllowed = self.characterBody.isEquipmentActivationAllowed;
			if (flag && isEquipmentActivationAllowed && self.hasEffectiveAuthority)
			{
				if (NetworkServer.active)
				{
					self.ExecuteIfReady();
				}
				else
				{
					self.CallCmdExecuteIfReady();
				}
			}
		}

		private void RemoveGestureItem(orig_Init orig)
		{
			orig.Invoke();
			Items.AutoCastEquipment.tier = (ItemTier)5;
		}
	}
}
namespace ArtifactGesture.Properties
{
	[GeneratedCode("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
	[DebuggerNonUserCode]
	[CompilerGenerated]
	internal class Resources
	{
		private static ResourceManager resourceMan;

		private static CultureInfo resourceCulture;

		[EditorBrowsable(EditorBrowsableState.Advanced)]
		internal static ResourceManager ResourceManager
		{
			get
			{
				if (resourceMan == null)
				{
					ResourceManager resourceManager = new ResourceManager("ArtifactGesture.Properties.Resources", typeof(Resources).Assembly);
					resourceMan = resourceManager;
				}
				return resourceMan;
			}
		}

		[EditorBrowsable(EditorBrowsableState.Advanced)]
		internal static CultureInfo Culture
		{
			get
			{
				return resourceCulture;
			}
			set
			{
				resourceCulture = value;
			}
		}

		internal static byte[] misc
		{
			get
			{
				object @object = ResourceManager.GetObject("misc", resourceCulture);
				return (byte[])@object;
			}
		}

		internal Resources()
		{
		}
	}
}