perks/PerkIgnorePhysicsReloading.cs

A unique perk class named PerkIgnorePhysicsReloading that increments a Player.IgnorePhysicsAmount when the player starts reloading and decrements it when reload finishes or the perk is removed, allowing the player to move through enemies while reloading.

Networking
using System;
using Sandbox;

[Perk( Rarity.Unique, locked: true, alwaysOfferDebug: false )]
public class PerkIgnorePhysicsReloading : Perk
{
	private bool _ignorePhysicsActive;

	public override float ImportanceMultiplier => 0.75f;

	static PerkIgnorePhysicsReloading()
	{
		Register<PerkIgnorePhysicsReloading>(
			name: "Sneaky Loader",
			imagePath: "textures/icons/vector/ignore_physics_reloading.png",
			description: level => $"Move through enemies\nwhile reloading"
		);
	}

	public override void Start()
	{
		base.Start();
	}

	public override void Refresh()
	{
		base.Refresh();

		// todo: should have another benefit?
	}

	public override void OnStartReload()
	{
		base.OnStartReload();

		if( !_ignorePhysicsActive )
		{
			Player.IgnorePhysicsAmount++;
			_ignorePhysicsActive = true;
		}

		// todo: vfx
	}

	public override void OnFinishReload()
	{
		base.OnFinishReload();

		if( _ignorePhysicsActive )
		{
			Player.IgnorePhysicsAmount--;
			_ignorePhysicsActive = false;
		}
	}

	public override void Remove( bool restart = false )
	{
		base.Remove( restart );

		if ( _ignorePhysicsActive )
			Player.IgnorePhysicsAmount--;
	}
}