A small weapon class for a Glock handgun that derives from IronSightsWeapon. It triggers primary attack when the attack1 input is pressed and draws a simple circular crosshair whose color depends on ammo, reload state, and next-fire timer.
using Sandbox.Rendering;
public sealed class GlockWeapon : 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 );
}
}