Decompiled source of ShurikenFixFix v1.0.0

ShurikenFixFix.dll

Decompiled 3 days ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security.Permissions;
using BepInEx;
using EntityStates;
using EntityStates.Captain.Weapon;
using EntityStates.Chef;
using EntityStates.Engi.EngiWeapon;
using EntityStates.EngiTurret.EngiTurretWeapon;
using EntityStates.Toolbot;
using EntityStates.VoidSurvivor.Weapon;
using HG.Reflection;
using Microsoft.CodeAnalysis;
using R2API.Networking;
using R2API.Networking.Interfaces;
using RoR2;
using RoR2.Items;
using UnityEngine;
using UnityEngine.Networking;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: OptIn]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("ShurikenFixFix")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("ShurikenFixFix")]
[assembly: AssemblyTitle("ShurikenFixFix")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[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 ShurikenFixFix
{
	public class RepeatShurikenBehavior : BaseItemBodyBehavior
	{
		private const float ThrowsPerSecond = 6f;

		private GenericSkill primary;

		private EntityState lastState;

		private int lastStock;

		private float channelTime;

		private bool HasCharge => ((BaseItemBodyBehavior)this).body.HasBuff(Buffs.PrimarySkillShurikenBuff);

		[ItemDefAssociation(useOnServer = true, useOnClient = true)]
		private static ItemDef GetItemDef()
		{
			return Items.PrimarySkillShuriken;
		}

		private static bool IsChanneling(EntityState state)
		{
			if (state is FireNailgun || state is FireBuzzsaw || state is ChargeGrenades || state is EngiLaserCutter || state is FireBeam || state is ChargeCaptainShotgun || state is FireCorruptHandBeam)
			{
				return true;
			}
			return false;
		}

		private void Start()
		{
			primary = ((BaseItemBodyBehavior)this).body.skillLocator.primary;
			((Behaviour)this).enabled = Object.op_Implicit((Object)(object)primary);
		}

		private void OnEnable()
		{
			((BaseItemBodyBehavior)this).body.onSkillActivatedAuthority += OnSkillActivated;
		}

		private void OnDisable()
		{
			((BaseItemBodyBehavior)this).body.onSkillActivatedAuthority -= OnSkillActivated;
		}

		private void OnSkillActivated(GenericSkill skill)
		{
			if ((Object)(object)skill == (Object)(object)primary)
			{
				lastState = null;
			}
		}

		private void FixedUpdate()
		{
			if (((BaseItemBodyBehavior)this).body.hasEffectiveAuthority)
			{
				EntityState state = primary.stateMachine.state;
				if (IsChanneling(state))
				{
					UpdateChannel();
				}
				else
				{
					channelTime = 0f;
				}
				if (state is Dice && state == lastState && primary.stock < lastStock && HasCharge)
				{
					RequestThrow();
				}
				lastState = state;
				lastStock = primary.stock;
			}
		}

		private void UpdateChannel()
		{
			channelTime += Time.fixedDeltaTime;
			if (!(channelTime * 6f * ((BaseItemBodyBehavior)this).body.attackSpeed < 1f) && HasCharge)
			{
				channelTime = 0f;
				RequestThrow();
			}
		}

		private void RequestThrow()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			NetMessageExtensions.Send((INetMessage)(object)new ThrowShuriken(((NetworkBehaviour)((BaseItemBodyBehavior)this).body).netId), (NetworkDestination)2);
		}
	}
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("FluxSquido.ShurikenFixFix", "ShurikenFixFix", "1.0.0")]
	public class ShurikenFixFixPlugin : BaseUnityPlugin
	{
		private void Awake()
		{
			NetworkingAPI.RegisterMessageType<ThrowShuriken>();
		}
	}
	public class ThrowShuriken : INetMessage, ISerializableObject
	{
		private NetworkInstanceId bodyId;

		public ThrowShuriken()
		{
		}

		public ThrowShuriken(NetworkInstanceId bodyId)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			this.bodyId = bodyId;
		}

		public void Serialize(NetworkWriter writer)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			writer.Write(bodyId);
		}

		public void Deserialize(NetworkReader reader)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			bodyId = reader.ReadNetworkId();
		}

		public void OnReceived()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = Util.FindNetworkObject(bodyId);
			PrimarySkillShurikenBehavior val2 = default(PrimarySkillShurikenBehavior);
			if (Object.op_Implicit((Object)(object)val) && val.TryGetComponent<PrimarySkillShurikenBehavior>(ref val2))
			{
				CharacterBody body = ((BaseItemBodyBehavior)val2).body;
				if (body.HasBuff(Buffs.PrimarySkillShurikenBuff))
				{
					body.RemoveBuff(Buffs.PrimarySkillShurikenBuff);
					val2.FireShuriken();
				}
			}
		}
	}
}