Rampage/Game/RampageLinks.cs

Read-only facade that gathers HUD state from three other modules in one place. Exposes town standing/total counts and a standing percent, weapon attack/charge/reach/spin/tip-speed stats, and grabber/pin state from the populace. Every member is a computed property that reads the source module directly, nothing cached.

using System;

/// <summary>
/// What the Game module (the HUD above all) wants to know from the World, Weapon and Humans
/// modules, in one place: how much of the town is still standing, what the weapon is doing and
/// who has hold of the lizard. Everything is read straight from those modules when asked: nothing
/// is cached, looked up by name or allowed to throw.
/// </summary>
public static class RampageLinks
{
	// ---- The town ----
	public static bool TownKnown => RampageWorld.Total > 0;
	public static int Standing => RampageWorld.Standing;
	public static int Total => RampageWorld.Total;
	/// <summary>Percent of the town still standing, or -1 before there is a town.</summary>
	public static int StandingPercent
	{
		get
		{
			int total = RampageWorld.Total;
			if ( total <= 0 ) return -1;
			return (int)MathF.Round( Math.Clamp( RampageWorld.Standing / (float)total, 0f, 1f ) * 100f );
		}
	}

	// ---- The weapon ----
	static DongWeapon Weapon
	{
		get
		{
			var weapon = DongWeapon.Current;
			return weapon.IsValid() ? weapon : null;
		}
	}

	/// <summary>True while the weapon is out.</summary>
	public static bool WeaponKnown => Weapon is not null;
	public static string AttackName => Weapon?.AttackName ?? "";
	/// <summary>Charge of the attack being wound up, 0 to 1, or -1 with no weapon out.</summary>
	public static float Charge01 => Weapon is { } weapon ? Math.Clamp( weapon.Charge01, 0f, 1f ) : -1f;
	public static int WeaponCombo => Weapon?.Combo ?? 0;
	/// <summary>Reach of the weapon in inches, or -1 with no weapon out.</summary>
	public static float Reach => Weapon?.Reach ?? -1f;
	public static bool Swinging => Weapon?.Swinging ?? false;

	// The two weapons, each for itself.
	public static WeaponHint Lit => Weapon?.Lit ?? WeaponHint.None;
	public static string DongState => Weapon?.DongState ?? "";
	public static string BallsState => Weapon?.BallsState ?? "";
	public static string Hooked => Weapon?.HookedName ?? "";
	/// <summary>Tip speed in inches a second, and how near that is to the speed at which it cracks (1 and over: cracking).</summary>
	public static float TipSpeed => Weapon?.TipSpeed ?? 0f;
	public static float TipCrack01 => Weapon is { } weapon ? weapon.TipSpeed / MathF.Max( weapon.CrackSpeed * MathF.Max( RampageGiant.ScaleNow, 1f ), 1f ) : 0f;
	public static bool TipCracking => Weapon?.TipCracking ?? false;
	public static float Spin01 => Weapon?.Spin01 ?? 0f;
	public static float SpinRpm => Weapon?.SpinRpm ?? 0f;
	public static float Draw01 => Weapon?.Draw01 ?? 0f;
	public static float BestTipSpeed => Weapon?.BestTipSpeed ?? 0f;
	public static int Cracks => Weapon?.Cracks ?? 0;
	public static int Megas => Weapon?.Megas ?? 0;
	public static int Misses => Weapon?.Misses ?? 0;
	public static int Flung => Weapon?.Flung ?? 0;

	// ---- The people hanging on ----
	/// <summary>Somebody has hold of the lizard.</summary>
	public static bool Held => RampagePopulace.PlayerHeld;
	/// <summary>Enough of them have hold that it cannot move.</summary>
	public static bool Pinned => RampagePopulace.PlayerPinned;
	public static int Grabbers => RampagePopulace.Grabbers;
	/// <summary>How close the weapon is to throwing everybody off by itself, 0 to 1.</summary>
	public static float ReflexCharge => Math.Clamp( RampagePopulace.ReflexCharge, 0f, 1f );
}