Weapons/Mp5/Mp5Weapon.cs

A weapon class for an MP5 that extends IronSightsWeapon. It overrides DrawCrosshair to draw a four-line crosshair whose gap expands with SpreadBloom and changes color when out of ammo, reloading, or unable to fire.

using Sandbox.Rendering;

public sealed class Mp5Weapon : IronSightsWeapon
{
	public override void DrawCrosshair( HudPainter hud, Vector2 center )
	{
		var gap = 16 + SpreadBloom * 32;
		var len = 12;
		var w = 2f;

		var color = !HasPrimaryAmmo() || IsReloading || NextPrimaryFire > 0 ? CrosshairNoShoot : CrosshairCanShoot;

		hud.SetBlendMode( BlendMode.Lighten );
		hud.DrawLine( center + Vector2.Left * (len + gap), center + Vector2.Left * gap, w, color );
		hud.DrawLine( center - Vector2.Left * (len + gap), center - Vector2.Left * gap, w, color );
		hud.DrawLine( center + Vector2.Up * (len + gap), center + Vector2.Up * gap, w, color );
		hud.DrawLine( center - Vector2.Up * (len + gap), center - Vector2.Up * gap, w, color );
	}
}