aboutsummaryrefslogtreecommitdiffstats
path: root/code/weapon/Pistol.cs
blob: 6358b1055a956d7cc7f319996cec0f3e7386eed2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
using Sandbox;

namespace MurderGame;

public partial class Pistol : Weapon
{
	public Pistol()
	{
		MaxAmmo = 1;
	}

	public override string ModelPath => "weapons/rust_pistol/rust_pistol.vmdl";
	public override string ViewModelPath => "weapons/rust_pistol/v_rust_pistol.vmdl";

	[ClientRpc]
	protected virtual void ShootEffects()
	{
		Game.AssertClient();

		Particles.Create( "particles/pistol_muzzleflash.vpcf", EffectEntity, "muzzle" );

		Pawn?.SetAnimParameter( "b_attack", true );
		ViewModelEntity?.SetAnimParameter( "fire", true );
	}

	public override void PrimaryAttack()
	{
		if ( Ammo > 0 )
		{
			--Ammo;
			ShootEffects();
			Pawn?.PlaySound( "rust_pistol.shoot" );
			ShootBullet( 100, 100, 1 );
		}
	}

	public override void Reload()
	{
		ReloadEffects();
		Pawn?.SetAnimParameter( "b_reload", true );
	}

	[ClientRpc]
	protected virtual void ReloadEffects()
	{
		ViewModelEntity?.SetAnimParameter( "reload", true );
	}

	protected override void Animate()
	{
		Pawn?.SetAnimParameter( "holdtype", (int)CitizenAnimationHelper.HoldTypes.Pistol );
	}
}