Decompiled source of ArtificerM1Reload v1.0.1

ArtificerM1Reload.dll

Decompiled 6 months ago
using System;
using System.Collections.Generic;
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.Mage.Weapon;
using On.EntityStates.Mage.Weapon;
using RoR2;
using RoR2.Skills;
using UnityEngine;
using UnityEngine.AddressableAssets;
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("ArtificerM1Reload")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("ArtificerM1Reload")]
[assembly: AssemblyTitle("ArtificerM1Reload")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace ArtificerM1Reload
{
	[BepInPlugin("com.Moffein.ArtificerM1Reload", "ArtificerM1Reload", "1.0.1")]
	public class ArtificerM1Reload : BaseUnityPlugin
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static hook_OnEnter <>9__0_0;

			internal void <Awake>b__0_0(orig_OnEnter orig, FireFireBolt self)
			{
				orig.Invoke(self);
				MageStockController component = ((EntityState)self).gameObject.GetComponent<MageStockController>();
				if (Object.op_Implicit((Object)(object)component))
				{
					component.FireSkill(self.duration);
				}
			}
		}

		public void Awake()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Expected O, but got Unknown
			//IL_0030: Expected O, but got Unknown
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Expected O, but got Unknown
			//IL_0069: Expected O, but got Unknown
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Expected O, but got Unknown
			MageStockController.graceDuration = ((BaseUnityPlugin)this).Config.Bind<float>(new ConfigDefinition("Stats", "Grace Duration"), 0.4f, new ConfigDescription("Time after firing before the reload starts. Ignored when out of stocks.", (AcceptableValueBase)null, Array.Empty<object>())).Value;
			MageStockController.baseDuration = ((BaseUnityPlugin)this).Config.Bind<float>(new ConfigDefinition("Stats", "Reload Time"), 1f, new ConfigDescription("Time it takes to reload a shot.", (AcceptableValueBase)null, Array.Empty<object>())).Value;
			GameObject val = LegacyResourcesAPI.Load<GameObject>("Prefabs/CharacterBodies/MageBody");
			SkillDef val2 = Addressables.LoadAssetAsync<SkillDef>((object)"RoR2/Base/Mage/MageBodyFireFirebolt.asset").WaitForCompletion();
			SkillDef val3 = Addressables.LoadAssetAsync<SkillDef>((object)"RoR2/Base/Mage/MageBodyFireLightningBolt.asset").WaitForCompletion();
			MageStockController.StatePairs.Add(typeof(FireFireBolt), MageStockController.fireMuzzleflashEffectPrefab);
			MageStockController.StatePairs.Add(typeof(FireLightningBolt), MageStockController.lightningMuzzleflashEffectPrefab);
			val.AddComponent<MageStockController>();
			val2.rechargeStock = 0;
			val3.rechargeStock = 0;
			object obj = <>c.<>9__0_0;
			if (obj == null)
			{
				hook_OnEnter val4 = delegate(orig_OnEnter orig, FireFireBolt self)
				{
					orig.Invoke(self);
					MageStockController component = ((EntityState)self).gameObject.GetComponent<MageStockController>();
					if (Object.op_Implicit((Object)(object)component))
					{
						component.FireSkill(self.duration);
					}
				};
				<>c.<>9__0_0 = val4;
				obj = (object)val4;
			}
			FireFireBolt.OnEnter += (hook_OnEnter)obj;
		}
	}
	public class MageStockController : MonoBehaviour
	{
		public static float graceDuration = 0.4f;

		public static float baseDuration = 1f;

		private CharacterBody body;

		private SkillLocator skills;

		private float reloadStopwatch;

		private float delayStopwatch;

		private bool rightMuzzle;

		public static GameObject fireMuzzleflashEffectPrefab = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/Mage/MuzzleflashMageFire.prefab").WaitForCompletion();

		public static GameObject lightningMuzzleflashEffectPrefab = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/Mage/MuzzleflashMageLightning.prefab").WaitForCompletion();

		public static GameObject iceMuzzleflashEffectPrefab = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Junk/Mage/MuzzleflashMageIce.prefab").WaitForCompletion();

		public static Dictionary<Type, GameObject> StatePairs = new Dictionary<Type, GameObject>();

		private void Awake()
		{
			body = ((Component)this).GetComponent<CharacterBody>();
			skills = ((Component)this).GetComponent<SkillLocator>();
			reloadStopwatch = 0f;
			delayStopwatch = 0f;
			rightMuzzle = true;
		}

		private void FixedUpdate()
		{
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			if (!((NetworkBehaviour)skills).hasAuthority)
			{
				return;
			}
			if (skills.primary.stock < skills.primary.maxStock)
			{
				Dictionary<Type, GameObject> statePairs = StatePairs;
				SerializableEntityStateType activationState = skills.primary.activationState;
				if (statePairs.ContainsKey(((SerializableEntityStateType)(ref activationState)).stateType))
				{
					if (skills.primary.stock <= 0)
					{
						delayStopwatch = 0f;
					}
					if (delayStopwatch > 0f)
					{
						delayStopwatch -= Time.fixedDeltaTime;
						return;
					}
					reloadStopwatch -= Time.fixedDeltaTime;
					if (reloadStopwatch <= 0f)
					{
						reloadStopwatch += baseDuration / body.attackSpeed;
						skills.primary.AddOneStock();
						Util.PlaySound("Play_railgunner_m2_reload_basic", ((Component)this).gameObject);
						ShowReloadVFX();
						if (skills.primary.stock > skills.primary.maxStock)
						{
							skills.primary.stock = skills.primary.maxStock;
						}
					}
					return;
				}
			}
			reloadStopwatch = baseDuration / body.attackSpeed;
		}

		public void FireSkill(float duration)
		{
			delayStopwatch = graceDuration;
			reloadStopwatch = baseDuration / body.attackSpeed;
		}

		private void ShowReloadVFX()
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			GameObject value = null;
			Dictionary<Type, GameObject> statePairs = StatePairs;
			SerializableEntityStateType activationState = skills.primary.activationState;
			statePairs.TryGetValue(((SerializableEntityStateType)(ref activationState)).stateType, out value);
			if (Object.op_Implicit((Object)(object)value))
			{
				EffectManager.SimpleMuzzleFlash(value, ((Component)this).gameObject, rightMuzzle ? "MuzzleRight" : "MuzzleLeft", true);
			}
			rightMuzzle = !rightMuzzle;
		}
	}
}
namespace R2API.Utils
{
	[AttributeUsage(AttributeTargets.Assembly)]
	public class ManualNetworkRegistrationAttribute : Attribute
	{
	}
}