A Colt 1911 weapon component derived from IronSightsWeapon. It handles primary attack input, and draws a simple crosshair that changes color when out of ammo, reloading, or unable to fire.
using Sandbox.Rendering;
public sealed class Colt1911Weapon : IronSightsWeapon
{
protected override bool WantsPrimaryAttack()
{
return Input.Pressed( "attack1" );
}
public override void DrawCrosshair( HudPainter hud, Vector2 center )
{
var color = !HasPrimaryAmmo() || IsReloading || NextPrimaryFire > 0 ? CrosshairNoShoot : CrosshairCanShoot;
hud.SetBlendMode( BlendMode.Normal );
hud.DrawCircle( center, 5, Color.Black );
hud.DrawCircle( center, 3, color );
}
}