Decompiled source of Garand v1.0.7

Garand_Plugin/Garand.dll

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

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyVersion("0.0.0.0")]
public class GarandClipScript : MagazineScript
{
	[Header("Garand Clip Sounds")]
	[EventRef]
	public string sound_event_clip_drop_ping;

	protected override void OnCollisionEnter(Collision collision)
	{
		//IL_0035: Unknown result type (might be due to invalid IL or missing references)
		//IL_0040: Expected O, but got Unknown
		if (((InventoryItem)this).physics_collided)
		{
			return;
		}
		((InventoryItem)this).physics_collided = true;
		if (!string.IsNullOrEmpty(sound_event_clip_drop_ping))
		{
			AudioManager.PlayOneShotAttached(sound_event_clip_drop_ping, ((Component)this).gameObject);
			return;
		}
		AudioManager val = AudioManager.Instance();
		if ((Object)val != (Object)null)
		{
			AudioManager.PlayOneShotAttached(val.sound_event_mag_drop, ((Component)this).gameObject);
		}
	}
}
[BepInPlugin("Garand", "Garand", "1.0.0")]
public class GarandLoader : BaseUnityPlugin
{
	private void Awake()
	{
		//IL_0019: Unknown result type (might be due to invalid IL or missing references)
		//IL_001f: Expected O, but got Unknown
		BepInPlugin val = (BepInPlugin)Attribute.GetCustomAttribute(typeof(GarandLoader), typeof(BepInPlugin));
		((BaseUnityPlugin)this).Logger.LogInfo((object)("Plugin " + val.GUID + " is loaded!"));
	}
}
public class GarandScript : ModGunScript
{
	private readonly float[] slide_push_hammer_curve = new float[4] { 0.03f, 0f, 0.05f, 1f };

	private bool decocking;

	private bool hammer_rest;

	[Header("Garand Sounds")]
	[EventRef]
	public string sound_garand_clip_ping;

	[Header("Garand Bolt Close Behavior")]
	[Range(0f, 1f)]
	public float garand_auto_close_chance = 0.75f;

	private bool garand_ping_played_for_this_eject;

	private bool garand_clip_presence_initialized;

	private bool garand_clip_was_in_gun_last_frame;

	private bool garand_blocking_forbidden_insert;

	private bool garand_auto_chambered_this_clip;

	private bool garand_this_clip_should_auto_close;

	private bool garand_no_clip_hold_open_active;

	private bool garand_no_clip_release_in_progress;

	private bool garand_no_clip_release_armed;

	private bool garand_inserted_clip_started_empty;

	private bool garand_detach_spent_clip_after_ping;

	private RotateMover garand_sear;

	private float garand_sear_cocked;

	private float garand_sear_halfcocked;

	private float garand_sear_uncocked;

	private float garand_sear_almost_cocked;

	private float garand_sear_hammer_back;

	private FieldInfo garand_slide_stop_manual_target_field;

	private FieldInfo garand_slide_stop_locked_field;

	public override void InitializeGun()
	{
		//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
		//IL_0052: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)((GunScript)this).loaded_cartridge_prefab != (Object)null)
		{
			ShellCasingScript component = ((GunScript)this).loaded_cartridge_prefab.GetComponent<ShellCasingScript>();
			if ((Object)(object)component != (Object)null)
			{
				ShellCasingScript val;
				component.ammo_box_prefab = ((ShellCasingScript)ReceiverCoreScript.Instance().generic_prefabs.First((InventoryItem item) => (val = (ShellCasingScript)(object)((item is ShellCasingScript) ? item : null)) != null && (int)val.cartridge_type == 0 && ((Object)val).name != "load_progression")).ammo_box_prefab;
			}
		}
		if ((Object)(object)((GunScript)this).pooled_muzzle_flash.object_prefab == (Object)null)
		{
			GunScript val;
			((GunScript)this).pooled_muzzle_flash = ((GunScript)ReceiverCoreScript.Instance().generic_prefabs.First((InventoryItem item) => (val = (GunScript)(object)((item is GunScript) ? item : null)) != null && (int)val.gun_model == 1)).pooled_muzzle_flash;
		}
	}

	public override void AwakeGun()
	{
		((SimpleMover)((GunScript)this).hammer).amount = 1f;
		garand_sear = AccessTools.FieldRefAccess<GunScript, RotateMover>((GunScript)(object)this, "sear");
		garand_sear_cocked = AccessTools.FieldRefAccess<GunScript, float>((GunScript)(object)this, "sear_cocked");
		garand_sear_halfcocked = AccessTools.FieldRefAccess<GunScript, float>((GunScript)(object)this, "sear_halfcocked");
		garand_sear_uncocked = AccessTools.FieldRefAccess<GunScript, float>((GunScript)(object)this, "sear_uncocked");
		garand_sear_almost_cocked = AccessTools.FieldRefAccess<GunScript, float>((GunScript)(object)this, "sear_almost_cocked");
		garand_sear_hammer_back = AccessTools.FieldRefAccess<GunScript, float>((GunScript)(object)this, "sear_hammer_back");
		garand_slide_stop_manual_target_field = AccessTools.Field(typeof(GunScript), "slide_stop_manual_target");
		garand_slide_stop_locked_field = AccessTools.Field(typeof(GunScript), "slide_stop_locked");
	}

	private void UpdateManualSafetyVisual()
	{
		if (!((Object)(object)((SimpleMover)((GunScript)this).safety).transform == (Object)null))
		{
			((SimpleMover)((GunScript)this).safety).amount = Mathf.MoveTowards(((SimpleMover)((GunScript)this).safety).amount, ((SimpleMover)((GunScript)this).safety).target_amount, Time.deltaTime * 10f);
			((SimpleMover)((GunScript)this).safety).UpdateDisplay();
		}
	}

	private bool IsSlideOpenForMagRemoval()
	{
		if (!((GunScript)this).IsSlideLockedOpen())
		{
			return ((SimpleMover)((GunScript)this).slide).amount >= 0.85f;
		}
		return true;
	}

	private bool IsBoltBackEnoughForClipInsertion()
	{
		if (!((GunScript)this).IsSlideLockedOpen() && !(((SimpleMover)((GunScript)this).slide).amount >= ((GunScript)this).slide_lock_position - 0.02f))
		{
			return ((SimpleMover)((GunScript)this).slide).amount >= 0.85f;
		}
		return true;
	}

	private void BlockMagRemovalUnlessSlideOpen()
	{
		//IL_0036: Unknown result type (might be due to invalid IL or missing references)
		//IL_003b: Unknown result type (might be due to invalid IL or missing references)
		if (!((Object)(object)((GunScript)this).magazine_instance_in_gun == (Object)null) && !IsSlideOpenForMagRemoval())
		{
			((GunScript)this).ReleaseMagEjectButton();
			((SimpleMover)((GunScript)this).magazine).target_amount = 0f;
			((GunScript)this).ready_to_remove_mag = false;
			((GunScript)this).mag_remove_vel = Vector3.zero;
			if (((SimpleMover)((GunScript)this).magazine).amount > 0f)
			{
				((SimpleMover)((GunScript)this).magazine).amount = Mathf.MoveTowards(((SimpleMover)((GunScript)this).magazine).amount, 0f, Time.deltaTime * 12f);
				((SimpleMover)((GunScript)this).magazine).UpdateDisplay();
			}
		}
	}

	private void BlockClipInsertionUnlessBoltBack()
	{
		//IL_0106: Unknown result type (might be due to invalid IL or missing references)
		//IL_010b: Unknown result type (might be due to invalid IL or missing references)
		bool flag = (Object)(object)((GunScript)this).magazine_instance_in_gun != (Object)null;
		if (!garand_clip_presence_initialized)
		{
			garand_clip_presence_initialized = true;
			garand_clip_was_in_gun_last_frame = flag;
			return;
		}
		if (flag && !garand_clip_was_in_gun_last_frame)
		{
			garand_no_clip_hold_open_active = false;
			garand_no_clip_release_in_progress = false;
			garand_no_clip_release_armed = false;
			garand_auto_chambered_this_clip = false;
			garand_this_clip_should_auto_close = Random.value <= garand_auto_close_chance;
			garand_inserted_clip_started_empty = (Object)(object)((GunScript)this).magazine_instance_in_gun != (Object)null && ((GunScript)this).magazine_instance_in_gun.NumRounds() == 0;
			if (!IsBoltBackEnoughForClipInsertion())
			{
				garand_blocking_forbidden_insert = true;
			}
		}
		if (!flag)
		{
			garand_blocking_forbidden_insert = false;
			garand_auto_chambered_this_clip = false;
			garand_this_clip_should_auto_close = false;
			garand_inserted_clip_started_empty = false;
			garand_clip_was_in_gun_last_frame = false;
			return;
		}
		if (garand_blocking_forbidden_insert)
		{
			if (IsBoltBackEnoughForClipInsertion())
			{
				garand_blocking_forbidden_insert = false;
				((SimpleMover)((GunScript)this).magazine).target_amount = 0f;
			}
			else
			{
				((SimpleMover)((GunScript)this).magazine).target_amount = 1f;
				((GunScript)this).ready_to_remove_mag = true;
				((GunScript)this).mag_remove_vel = Vector3.zero;
				if (((SimpleMover)((GunScript)this).magazine).amount < 1f)
				{
					((SimpleMover)((GunScript)this).magazine).amount = Mathf.MoveTowards(((SimpleMover)((GunScript)this).magazine).amount, 1f, Time.deltaTime * 16f);
					((SimpleMover)((GunScript)this).magazine).UpdateDisplay();
				}
			}
		}
		garand_clip_was_in_gun_last_frame = flag;
	}

	private void TryAutoEjectEmptyClip()
	{
		if (!((Object)(object)((GunScript)this).magazine_instance_in_gun == (Object)null) && !garand_inserted_clip_started_empty && ((GunScript)this).magazine_instance_in_gun.NumRounds() <= 0 && !((GunScript)this).IsThereAChamberedRound() && (((GunScript)this).IsSlideLockedOpen() || ((SimpleMover)((GunScript)this).slide).amount >= ((GunScript)this).slide_lock_position - 0.02f || ((SimpleMover)((GunScript)this).slide).amount >= 0.85f))
		{
			ForceGarandFakeFollowerHoldOpen();
			if (!((GunScript)this).ready_to_remove_mag || ((SimpleMover)((GunScript)this).magazine).target_amount < 1f || ((SimpleMover)((GunScript)this).magazine).amount < 0.95f)
			{
				((GunScript)this).PressMagEjectButton();
			}
			if (((SimpleMover)((GunScript)this).magazine).amount >= 0.95f || ((GunScript)this).ready_to_remove_mag)
			{
				garand_detach_spent_clip_after_ping = true;
			}
		}
	}

	private void TryDetachSpentClipAfterPing()
	{
		//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
		//IL_010c: Unknown result type (might be due to invalid IL or missing references)
		if (!garand_detach_spent_clip_after_ping)
		{
			return;
		}
		if ((Object)(object)((GunScript)this).magazine_instance_in_gun == (Object)null)
		{
			garand_detach_spent_clip_after_ping = false;
		}
		else if (garand_inserted_clip_started_empty || ((GunScript)this).magazine_instance_in_gun.NumRounds() > 0 || ((GunScript)this).IsThereAChamberedRound())
		{
			garand_detach_spent_clip_after_ping = false;
		}
		else
		{
			if (((SimpleMover)((GunScript)this).magazine).amount < 0.95f && !((GunScript)this).ready_to_remove_mag)
			{
				return;
			}
			MagazineScript val = ((GunScript)this).RemoveMag();
			garand_detach_spent_clip_after_ping = false;
			if (!((Object)(object)val == (Object)null))
			{
				((InventoryItem)val).Move((InventorySlot)null);
				((Component)val).transform.parent = null;
				Rigidbody component = ((Component)val).GetComponent<Rigidbody>();
				if ((Object)(object)component != (Object)null)
				{
					component.isKinematic = false;
					component.useGravity = true;
					component.WakeUp();
					component.velocity = ((Component)this).transform.TransformDirection(new Vector3(Random.Range(-0.7f, 0.7f), 2.2f, -2f));
					component.angularVelocity = new Vector3(Random.Range(-8f, 8f), Random.Range(-12f, 12f), Random.Range(-8f, 8f));
				}
			}
		}
	}

	private void TryPlayGarandPingOnRealEject()
	{
		if ((Object)(object)((GunScript)this).magazine_instance_in_gun == (Object)null)
		{
			garand_ping_played_for_this_eject = false;
		}
		else if (((SimpleMover)((GunScript)this).magazine).target_amount == 0f || ((SimpleMover)((GunScript)this).magazine).amount <= 0.05f)
		{
			garand_ping_played_for_this_eject = false;
		}
		else if (!garand_ping_played_for_this_eject && ((GunScript)this).ready_to_remove_mag && ((SimpleMover)((GunScript)this).magazine).amount >= 0.95f && IsSlideOpenForMagRemoval())
		{
			if (!string.IsNullOrEmpty(sound_garand_clip_ping))
			{
				AudioManager.PlayOneShotAttached(sound_garand_clip_ping, ((Component)((GunScript)this).magazine_instance_in_gun).gameObject);
			}
			garand_ping_played_for_this_eject = true;
		}
	}

	private void SetSlideStopManualTarget(int value)
	{
		if (garand_slide_stop_manual_target_field != null)
		{
			garand_slide_stop_manual_target_field.SetValue(this, value);
		}
		if (value != 0 && garand_slide_stop_locked_field != null)
		{
			garand_slide_stop_locked_field.SetValue(this, false);
		}
	}

	private int GetSlideStopManualTarget()
	{
		if (garand_slide_stop_manual_target_field == null)
		{
			return 0;
		}
		return (int)garand_slide_stop_manual_target_field.GetValue(this);
	}

	private void ForceGarandFakeFollowerHoldOpen()
	{
		SetSlideStopManualTarget(1);
		((SimpleMover)((GunScript)this).slide_stop).target_amount = 1f;
		((SimpleMover)((GunScript)this).slide_stop).amount = 1f;
		((SimpleMover)((GunScript)this).slide_stop).UpdateDisplay();
	}

	private void UpdateGarandInternalFollowerHoldOpen()
	{
		if (!((Object)(object)((GunScript)this).magazine_instance_in_gun == (Object)null) || ((GunScript)this).IsThereAChamberedRound())
		{
			garand_no_clip_hold_open_active = false;
			garand_no_clip_release_in_progress = false;
			garand_no_clip_release_armed = false;
			return;
		}
		if (garand_no_clip_release_in_progress)
		{
			SetSlideStopManualTarget(-1);
			((SimpleMover)((GunScript)this).slide_stop).target_amount = 0f;
			((SimpleMover)((GunScript)this).slide_stop).amount = 0f;
			((SimpleMover)((GunScript)this).slide_stop).UpdateDisplay();
			if (garand_slide_stop_locked_field != null)
			{
				garand_slide_stop_locked_field.SetValue(this, false);
			}
			if (((SimpleMover)((GunScript)this).slide).amount <= 0.05f)
			{
				garand_no_clip_release_in_progress = false;
				garand_no_clip_hold_open_active = false;
				garand_no_clip_release_armed = false;
				SetSlideStopManualTarget(0);
				((SimpleMover)((GunScript)this).slide_stop).target_amount = 0f;
			}
			return;
		}
		if (!garand_no_clip_hold_open_active && ((SimpleMover)((GunScript)this).slide).amount >= ((GunScript)this).slide_lock_position - 0.02f)
		{
			garand_no_clip_hold_open_active = true;
			garand_no_clip_release_armed = false;
		}
		if (!garand_no_clip_hold_open_active)
		{
			return;
		}
		ForceGarandFakeFollowerHoldOpen();
		if (!garand_no_clip_release_armed)
		{
			if (((GunScript)this).IsSlideLockedOpen() || ((SimpleMover)((GunScript)this).slide).amount <= ((GunScript)this).slide_lock_position + 0.01f)
			{
				garand_no_clip_release_armed = true;
			}
		}
		else if (((SimpleMover)((GunScript)this).slide).amount >= 0.98f)
		{
			garand_no_clip_release_in_progress = true;
			garand_no_clip_release_armed = false;
			SetSlideStopManualTarget(-1);
			((SimpleMover)((GunScript)this).slide_stop).target_amount = 0f;
			((SimpleMover)((GunScript)this).slide_stop).amount = 0f;
			((SimpleMover)((GunScript)this).slide_stop).UpdateDisplay();
			if (garand_slide_stop_locked_field != null)
			{
				garand_slide_stop_locked_field.SetValue(this, false);
			}
			((SimpleMover)((GunScript)this).slide).target_amount = 0f;
			((SimpleMover)((GunScript)this).slide).vel = -2f * ((PlayerStats)(ref ReceiverCoreScript.Instance().player_stats)).animation_speed;
			if (!string.IsNullOrEmpty(((GunScript)this).sound_slide_released))
			{
				AudioManager.PlayOneShotAttached(((GunScript)this).sound_slide_released, ((Component)this).gameObject);
			}
		}
	}

	private void ClearGarandForcedSlideStopReleaseAfterBoltCloses()
	{
		if (GetSlideStopManualTarget() == -1 && ((SimpleMover)((GunScript)this).slide).amount <= 0.05f)
		{
			SetSlideStopManualTarget(0);
		}
	}

	private void TryAutoCloseBoltAfterClipInsertion()
	{
		if ((Object)(object)((GunScript)this).magazine_instance_in_gun == (Object)null)
		{
			garand_auto_chambered_this_clip = false;
		}
		else if (!garand_blocking_forbidden_insert && !garand_auto_chambered_this_clip && garand_this_clip_should_auto_close && !garand_inserted_clip_started_empty && ((GunScript)this).magazine_instance_in_gun.NumRounds() > 0 && !(((SimpleMover)((GunScript)this).magazine).amount > 0.05f) && ((SimpleMover)((GunScript)this).magazine).target_amount == 0f && (((GunScript)this).IsSlideLockedOpen() || ((SimpleMover)((GunScript)this).slide).amount >= ((GunScript)this).slide_lock_position - 0.02f))
		{
			garand_auto_chambered_this_clip = true;
			SetSlideStopManualTarget(-1);
			((SimpleMover)((GunScript)this).slide_stop).target_amount = 0f;
			if (garand_slide_stop_locked_field != null)
			{
				garand_slide_stop_locked_field.SetValue(this, false);
			}
			((SimpleMover)((GunScript)this).slide).target_amount = 0f;
			((SimpleMover)((GunScript)this).slide).vel = -2f * ((PlayerStats)(ref ReceiverCoreScript.Instance().player_stats)).animation_speed;
			if (!string.IsNullOrEmpty(((GunScript)this).sound_slide_released))
			{
				AudioManager.PlayOneShotAttached(((GunScript)this).sound_slide_released, ((Component)this).gameObject);
			}
		}
	}

	private void TryManualCloseBoltAfterClipInsertion()
	{
		if (!((Object)(object)((GunScript)this).magazine_instance_in_gun == (Object)null) && !garand_blocking_forbidden_insert && !garand_auto_chambered_this_clip && !garand_inserted_clip_started_empty && ((GunScript)this).magazine_instance_in_gun.NumRounds() > 0 && !(((SimpleMover)((GunScript)this).magazine).amount > 0.05f) && ((SimpleMover)((GunScript)this).magazine).target_amount == 0f && !garand_this_clip_should_auto_close && ((SimpleMover)((GunScript)this).slide).amount >= 0.98f)
		{
			garand_auto_chambered_this_clip = true;
			garand_no_clip_hold_open_active = false;
			garand_no_clip_release_in_progress = true;
			garand_no_clip_release_armed = false;
			SetSlideStopManualTarget(-1);
			((SimpleMover)((GunScript)this).slide_stop).target_amount = 0f;
			((SimpleMover)((GunScript)this).slide_stop).amount = 0f;
			((SimpleMover)((GunScript)this).slide_stop).UpdateDisplay();
			if (garand_slide_stop_locked_field != null)
			{
				garand_slide_stop_locked_field.SetValue(this, false);
			}
			((SimpleMover)((GunScript)this).slide).target_amount = 0f;
			((SimpleMover)((GunScript)this).slide).vel = -2f * ((PlayerStats)(ref ReceiverCoreScript.Instance().player_stats)).animation_speed;
			if (!string.IsNullOrEmpty(((GunScript)this).sound_slide_released))
			{
				AudioManager.PlayOneShotAttached(((GunScript)this).sound_slide_released, ((Component)this).gameObject);
			}
		}
	}

	public override void UpdateGun()
	{
		UpdateManualSafetyVisual();
		if ((Object)(object)LocalAimHandler.player_instance != (Object)null && !LocalAimHandler.player_instance.PullingTrigger)
		{
			((GunScript)this).trigger.target_amount = 0f;
			((GunScript)this).trigger.amount = Mathf.MoveTowards(((GunScript)this).trigger.amount, 0f, Time.deltaTime * 8f);
		}
		if (((ModGunScript)this).player_input.GetButton(14) && ((ModGunScript)this).player_input.GetButtonDown(2) && ((SimpleMover)((GunScript)this).slide).amount == 0f)
		{
			decocking = true;
		}
		((SimpleMover)((GunScript)this).hammer).asleep = false;
		if (decocking)
		{
			if (!((ModGunScript)this).player_input.GetButton(14))
			{
				((SimpleMover)((GunScript)this).hammer).amount = Mathf.MoveTowards(((SimpleMover)((GunScript)this).hammer).amount, 0f, Time.deltaTime * 5f);
			}
			if (((SimpleMover)((GunScript)this).hammer).amount <= 0.001f || !((ModGunScript)this).player_input.GetButton(2))
			{
				((ModGunScript)this)._hammer_state = 0;
				decocking = false;
				if (((SimpleMover)((GunScript)this).hammer).amount <= 0.001f)
				{
					((SimpleMover)((GunScript)this).hammer).amount = 0f;
					((SimpleMover)((GunScript)this).hammer).UpdateDisplay();
					AudioManager.PlayOneShotAttached(((GunScript)this).sound_decock, ((Component)((SimpleMover)((GunScript)this).hammer).transform).gameObject, 0.3f);
				}
			}
		}
		if (!decocking)
		{
			if (((ModGunScript)this)._hammer_state == 0 && ((SimpleMover)((GunScript)this).hammer).amount >= ((ModGunScript)this)._hammer_halfcocked)
			{
				((ModGunScript)this)._hammer_state = 1;
				if (!((SimpleMover)((GunScript)this).hammer).asleep)
				{
					((SimpleMover)((GunScript)this).hammer).target_amount = ((ModGunScript)this)._hammer_halfcocked;
				}
				if ((Object)(object)LocalAimHandler.player_instance == (Object)null || !LocalAimHandler.player_instance.PullingTrigger)
				{
					AudioManager.PlayOneShotAttached("event:/guns/1911/1911_half_cock", ((Component)((SimpleMover)((GunScript)this).hammer).transform).gameObject);
				}
			}
			if (((ModGunScript)this)._hammer_state == 1 && ((SimpleMover)((GunScript)this).hammer).amount >= ((ModGunScript)this)._hammer_cocked_val)
			{
				((ModGunScript)this)._hammer_state = 2;
				if (!((SimpleMover)((GunScript)this).hammer).asleep)
				{
					((SimpleMover)((GunScript)this).hammer).target_amount = ((ModGunScript)this)._hammer_cocked_val;
				}
				if ((Object)(object)LocalAimHandler.player_instance == (Object)null || !LocalAimHandler.player_instance.PullingTrigger)
				{
					AudioManager.PlayOneShotAttached("event:/guns/1911/1911_full_cock", ((Component)((SimpleMover)((GunScript)this).hammer).transform).gameObject);
				}
			}
			if (((GunScript)this).trigger.amount == 0f && !((ModGunScript)this).player_input.GetButton(14))
			{
				if (((ModGunScript)this)._hammer_state == 1)
				{
					((SimpleMover)((GunScript)this).hammer).target_amount = ((ModGunScript)this)._hammer_halfcocked;
					if (!hammer_rest)
					{
						AudioManager.PlayOneShotAttached("event:/guns/1911/1911_hammer_rest", ((Component)((SimpleMover)((GunScript)this).hammer).transform).gameObject);
					}
				}
				if (((ModGunScript)this)._hammer_state == 2)
				{
					((SimpleMover)((GunScript)this).hammer).target_amount = ((ModGunScript)this)._hammer_cocked_val;
					if (!hammer_rest)
					{
						AudioManager.PlayOneShotAttached("event:/guns/1911/1911_hammer_rest", ((Component)((SimpleMover)((GunScript)this).hammer).transform).gameObject);
					}
				}
				hammer_rest = true;
			}
			else
			{
				hammer_rest = false;
			}
		}
		((SimpleMover)((GunScript)this).hammer).TimeStep(Time.deltaTime * 5f);
		((SimpleMover)((GunScript)this).hammer).UpdateDisplay();
		if (((GunScript)this).IsSafetyOn())
		{
			((ModGunScript)this)._hammer_state = 2;
			((SimpleMover)((GunScript)this).hammer).amount = Mathf.Clamp(((SimpleMover)((GunScript)this).hammer).amount, ((ModGunScript)this)._hammer_cocked_val, 1f);
			((SimpleMover)((GunScript)this).hammer).target_amount = ((ModGunScript)this)._hammer_cocked_val;
			((SimpleMover)((GunScript)this).hammer).UpdateDisplay();
			((GunScript)this).trigger.amount = Mathf.Min(((GunScript)this).trigger.amount, 0.1f);
			((GunScript)this).trigger.target_amount = Mathf.Min(((GunScript)this).trigger.target_amount, 0.1f);
			((GunScript)this).trigger.UpdateDisplay();
		}
		if (((SimpleMover)((GunScript)this).slide).amount > 0f)
		{
			((ModGunScript)this)._disconnector_needs_reset = true;
		}
		if (((ModGunScript)this)._disconnector_needs_reset && ((SimpleMover)((GunScript)this).slide).amount == 0f && ((GunScript)this).trigger.amount <= 0.05f)
		{
			((ModGunScript)this)._disconnector_needs_reset = false;
			AudioManager.PlayOneShotAttached(((GunScript)this).sound_trigger_reset, ((Component)((GunScript)this).trigger.transform).gameObject);
		}
		if (((SimpleMover)((GunScript)this).slide).amount > 0.2f && ((ModGunScript)this)._hammer_state != 2)
		{
			((SimpleMover)((GunScript)this).hammer).amount = Mathf.Max(((SimpleMover)((GunScript)this).hammer).amount, ModGunScript.InterpCurve(ref slide_push_hammer_curve, ((SimpleMover)((GunScript)this).slide).amount));
			((SimpleMover)((GunScript)this).hammer).UpdateDisplay();
		}
		bool flag = ((ModGunScript)this).player_input != null && ((ModGunScript)this).player_input.GetButton(14);
		if (((GunScript)this).trigger.amount >= 0.92f && ((SimpleMover)((GunScript)this).hammer).amount >= ((ModGunScript)this)._hammer_cocked_val - 0.01f && ((ModGunScript)this)._hammer_state == 2 && !((ModGunScript)this)._disconnector_needs_reset && !((GunScript)this).IsSafetyOn() && !flag && ((SimpleMover)((GunScript)this).slide).amount <= 0.001f)
		{
			((SimpleMover)((GunScript)this).hammer).target_amount = 0f;
			((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 <= 0.001f && ((ModGunScript)this)._hammer_state == 2 && !decocking)
		{
			((SimpleMover)((GunScript)this).hammer).amount = 0f;
			((SimpleMover)((GunScript)this).hammer).UpdateDisplay();
			((ModGunScript)this).TryFireBullet(1f);
			((ModGunScript)this)._hammer_state = 0;
		}
		if (garand_sear != null)
		{
			if (((SimpleMover)((GunScript)this).hammer).amount < ((ModGunScript)this)._hammer_halfcocked)
			{
				((SimpleMover)garand_sear).amount = garand_sear_uncocked;
			}
			else if (((SimpleMover)((GunScript)this).hammer).amount < ((ModGunScript)this)._hammer_cocked_val)
			{
				((SimpleMover)garand_sear).amount = Mathf.Lerp(garand_sear_halfcocked, garand_sear_almost_cocked, (((SimpleMover)((GunScript)this).hammer).amount - ((ModGunScript)this)._hammer_halfcocked) / (((ModGunScript)this)._hammer_cocked_val - ((ModGunScript)this)._hammer_halfcocked));
			}
			else
			{
				((SimpleMover)garand_sear).amount = Mathf.Lerp(garand_sear_cocked, garand_sear_hammer_back, (((SimpleMover)((GunScript)this).hammer).amount - ((ModGunScript)this)._hammer_cocked_val) / (1f - ((ModGunScript)this)._hammer_cocked_val));
			}
			((SimpleMover)garand_sear).UpdateDisplay();
		}
		((GunScript)this).trigger.UpdateDisplay();
		BlockMagRemovalUnlessSlideOpen();
		BlockClipInsertionUnlessBoltBack();
		TryAutoCloseBoltAfterClipInsertion();
		TryManualCloseBoltAfterClipInsertion();
		ClearGarandForcedSlideStopReleaseAfterBoltCloses();
		TryAutoEjectEmptyClip();
		TryPlayGarandPingOnRealEject();
		TryDetachSpentClipAfterPing();
		((ModGunScript)this).UpdateAnimatedComponents();
		UpdateGarandInternalFollowerHoldOpen();
	}

	public override void LateUpdateGun()
	{
		UpdateGarandInternalFollowerHoldOpen();
	}
}