weapon-colors.ts
PURPOSE
Signature color tables and lookup helpers for the additive lighting system. One color per weapon serves as both the projectile body tint and the additive glow color, so the projectile and its light read as a single cohesive object (“Geometry Wars in space” aesthetic). Also defines per-rarity player ship aura colors and per-planet boss aura colors.
OWNS
RGBHexinterface —{ r, g, b, hex }where r/g/b are 0–1 floats for the WebGL sprite batch andhexis a CSS string for any Canvas 2D draw paths.WEAPON_COLOR— record of weapon id toRGBHex. Covers 13 weapon ids grouped into four signature buckets:- Bullet (white/silver,
#f5f5f5):rifle,shotgun,disc,revolver. - Energy (electric blue,
#22aaff):railgun,lightning,sweep,barrier,line. - Fire (bright orange-yellow,
#ff8800):flame. - Bomb (dark red,
#cc2200):cannon,mortar,missile.
- Bullet (white/silver,
WEAPON_COLOR_DEFAULT— white fallback#fffffffor unknown or missing weapon ids.getWeaponColor(weaponId)— lookup; empty string returns the default white (enemy projectiles without a weapon id); unknown ids also fall back to default white.SHIP_RARITY_GLOW_COLOR— record of rarity name toRGBHexfor the steady additive halo under the player ship sticker:common— soft white-cyan#99ccff.uncommon— green#66ff99.rare— blue#66b3ff.epic— purple#cc66ff.legendary— orange#ff9900.
BOSS_PLANET_GLOW_COLOR— record of numeric planet id toRGBHexfor boss auras, derived from biome identity rather than per-boss-def color:3voidstar — violet#cc66ff.12landing site — warm orange#ff8033.21sunrise city — yellow#ffd966.
BOSS_GLOW_DEFAULT— red-orange#ff4d1afallback for unknown planets.getBossGlowColor(planetId)— lookup; null/undefined returns the default; unknown numeric ids also fall back to the default.
READS FROM
Nothing. Pure data module with two lookup functions and no imports.
PUSHES TO
engine/rendering/draw.tsimportsgetWeaponColorand resolves a weapon color for projectile body tint and additive glow during draw.engine/bridge.tsimportsgetWeaponColorandSHIP_RARITY_GLOW_COLORto wire weapon and ship-aura colors through the engine bridge.
DOES NOT
- Does not allocate per-frame; tables are module-level constants.
- Does not own a per-boss-def color field; boss aura color is derived from
planetIdso the aura matches the biome. - Does not throw on unknown ids despite the docstring on
getWeaponColormentioning “throws”; both lookups return their default constant via nullish-coalescing. - Does not drive light intensity, radius, falloff, or any non-color glow parameter — only the RGB tint.
- Does not list or validate against the weapon id catalog; ids are assumed to match
data/weapons/index.ts.
Signals
None. The module exports static data plus two synchronous pure lookups; no events, observers, or callbacks.
Entry points
getWeaponColor(weaponId: string): RGBHex— empty string short-circuits toWEAPON_COLOR_DEFAULT; unknown id also returns the default.getBossGlowColor(planetId: number | null | undefined): RGBHex— null/undefined short-circuits toBOSS_GLOW_DEFAULT; unknown id also returns the default.- Direct record reads of
WEAPON_COLOR,SHIP_RARITY_GLOW_COLOR,BOSS_PLANET_GLOW_COLORare also valid use; consumers currently use the helper for weapons and readSHIP_RARITY_GLOW_COLORdirectly.
Pattern notes
- One
RGBHexshape carries both 0–1 floats (for the WebGL sprite batch) and a hex string (for Canvas 2D paths) so consumers on either renderer path can use the same constants without conversion. - Weapons are grouped into four color buckets rather than per-weapon hues so distinct weapon families read as distinct light sources while related weapons stay visually coherent.
- Boss aura is keyed by planet id rather than boss def so adding a new boss in an existing biome inherits the right color automatically; new biomes require adding a row.
- v5.60.0 ships with only the
iron_throneboss (red biome); the planet-id table is sparse with three named planets and a red-orange default that covers the rest. - Defaults are returned (not thrown) so missing data degrades to white/red-orange rather than crashing the render path.