FN57Patch/Five-SeveN.dll

Decompiled 3 weeks ago
using System;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using BepInEx;
using Receiver2;
using Receiver2ModdingKit;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyVersion("0.0.0.0")]
namespace FN57_plugin
{
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("Ciarencew.FN57", "FN57 Plugin", "3.0.0")]
	internal class MainPlugin : BaseUnityPlugin
	{
		private void Awake()
		{
			((BaseUnityPlugin)this).Logger.LogInfo((object)"FN57 Main Plugin loaded!");
		}
	}
}
namespace FiveSeveN
{
	public class FiveSeveN : ModGunScript
	{
		private readonly float[] slide_push_hammer_curve = new float[4] { 0f, 0f, 0.02f, 1f };

		public override void InitializeGun()
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			((GunScript)this).pooled_muzzle_flash = ((GunScript)ReceiverCoreScript.Instance().generic_prefabs.First((InventoryItem it) => it is GunScript && (int)((GunScript)it).gun_model == 2)).pooled_muzzle_flash;
		}

		public override void AwakeGun()
		{
			((SimpleMover)((GunScript)this).hammer).amount = 1f;
		}

		public override void UpdateGun()
		{
			if (((GunScript)this).IsSafetyOn())
			{
				((GunScript)this).trigger.amount = Mathf.Min(((GunScript)this).trigger.amount, 0.1f);
				((GunScript)this).trigger.UpdateDisplay();
			}
			((SimpleMover)((GunScript)this).hammer).asleep = false;
			_ = LocalAimHandler.player_instance;
			_ = ((SimpleMover)((GunScript)this).hammer).amount;
			if (((SimpleMover)((GunScript)this).slide).amount > 0.2f)
			{
				((SimpleMover)((GunScript)this).hammer).amount = Mathf.Max(((SimpleMover)((GunScript)this).hammer).amount, ModGunScript.InterpCurve(ref slide_push_hammer_curve, ((SimpleMover)((GunScript)this).slide).amount));
			}
			if (((SimpleMover)((GunScript)this).slide).amount == 0f && ((GunScript)this).trigger.amount == 0f)
			{
				((ModGunScript)this)._disconnector_needs_reset = false;
			}
			if (((GunScript)this).trigger.amount == 1f && ((SimpleMover)((GunScript)this).hammer).amount == ((ModGunScript)this)._hammer_cocked_val && !((ModGunScript)this)._disconnector_needs_reset && !((GunScript)this).IsSafetyOn() && Object.op_Implicit((Object)(object)((GunScript)this).magazine_instance_in_gun))
			{
				if (((SimpleMover)((GunScript)this).slide).amount == 0f)
				{
					((SimpleMover)((GunScript)this).hammer).target_amount = 0f;
					((SimpleMover)((GunScript)this).hammer).vel = -0.1f * ((PlayerStats)(ref ReceiverCoreScript.Instance().player_stats)).animation_speed;
				}
				((ModGunScript)this)._disconnector_needs_reset = true;
			}
			float vel = ((SimpleMover)((GunScript)this).hammer).vel;
			if (((SimpleMover)((GunScript)this).hammer).amount > ((ModGunScript)this)._hammer_cocked_val)
			{
				((ModGunScript)this)._hammer_state = 2;
				((SimpleMover)((GunScript)this).hammer).target_amount = ((ModGunScript)this)._hammer_cocked_val;
				((SimpleMover)((GunScript)this).hammer).vel = -0.1f * ((PlayerStats)(ref ReceiverCoreScript.Instance().player_stats)).animation_speed;
			}
			((SimpleMover)((GunScript)this).hammer).TimeStep(Time.deltaTime);
			if (((SimpleMover)((GunScript)this).hammer).amount == 0f && ((ModGunScript)this)._hammer_state == 2 && vel < 0f)
			{
				((ModGunScript)this).TryFireBullet(1f, (Action<ShellCasingScript>)((GunScript)this).FireBullet);
				((ModGunScript)this)._hammer_state = 0;
			}
			((GunScript)this).trigger.UpdateDisplay();
			((SimpleMover)((GunScript)this).safety).UpdateDisplay();
			((GunScript)this).ApplyTransform("trigger_bar", ((GunScript)this).trigger.amount, ((Component)this).transform.Find("trigger_bar"));
			((GunScript)this).ApplyTransform("barrel", ((SimpleMover)((GunScript)this).slide).amount, ((Component)this).transform.Find("barrel"));
			((GunScript)this).ApplyTransform("Cam", ((SimpleMover)((GunScript)this).slide).amount, ((Component)this).transform.Find("Cam"));
			((GunScript)this).ApplyTransform("loaded_chamber_indicator", 1f, ((Component)this).transform.Find("slide/loaded_chamber_indicator"));
			((ModGunScript)this).UpdateAnimatedComponents();
		}
	}
}