PURPOSE
Registry of weapon archetypes that describes the capability surface of each weapon family — what modifier classes (explode, pierce, bounce, leech, slow, burn) each archetype is eligible for, plus its canonical damageType and entityType. Used as the source of truth for modifier eligibility decisions, distinct from the cosmetic bulletArchetype concept covered in gameplay/concepts/bullet-archetypes (which controls visual shape/trail).
OWNS
WeaponArchetypeMetainterface (id,damageType,entityType, optionalcanExplode/canPierce/canBounce/canLeech/canSlow/canBurn,desc).WeaponArchetypessingleton with:_registry— keyed map of registered archetypes.register(id, meta)— installs a meta blob and stampsmeta.id.get(id)— returns meta ornull.can(archId, capability)— boolean capability lookup.list()— array of registered archetype ids.getModEligibility(weaponId)— returns a capability summary; currently hard-coded to read theprojectilearchetype regardless of theweaponIdargument.
- Built-in archetype registrations:
projectile,beam,sniper,leech,field,melee,nova,vortex,chain,arc_wave,flamethrower,singularity,orbital,buzzsaw,void_tear,whip,bass_cannon,bubble,bug_gun,emp,missile. - Compatibility exports:
ARCHETYPE_MAPalias of_registry, plusprojectileArchetype(),beamArchetype(),shotgunArchetype(),missileArchetype(),burstArchetype(),orbitWeaponArchetype(),teslaArchetype(),flakArchetype(),lanceArchetype()— each returns the matching registry entry or an inline fallback object.
READS FROM
- Its own
_registryonly. No imports, no external data, no globals.
PUSHES TO
- Re-exported via the weapons barrel (
src/starship-survivors/engine/weapons/index.tsre-exportsWeaponArchetypes). - Capability metadata is consumed by callers that ask
WeaponArchetypes.can(archId, capability)or callgetModEligibility(...)to decide whether a given mod class may attach to a weapon.
DOES NOT
- Does not spawn, fire, or render anything.
- Does not define damage numbers, fire rates, cooldowns, projectile speeds, AoE radii, or any per-weapon tuning — only capability flags + damage/entity type labels.
- Does not look up the weapon’s actual archetype id from a weapon definition:
getModEligibility(weaponId)ignores its argument and always readsprojectile. - Does not describe the cosmetic
bulletArchetype(visual/trail shape) — that lives separately undergameplay/concepts/bullet-archetypes. - Does not register a
minearchetype; it was deleted in v1.42 (themineArchetype()export was removed alongside it). - Does not validate
metashape onregisteror guard against id collisions (later registrations silently overwrite earlier ones).
Signals
- None. Pure synchronous lookups; no events emitted or subscribed.
Entry points
WeaponArchetypes.register(id, meta)— invoked at module top level for every built-in archetype.WeaponArchetypes.get(id),WeaponArchetypes.can(archId, capability),WeaponArchetypes.list(),WeaponArchetypes.getModEligibility(weaponId)— public lookup API.- Helper accessor functions (
projectileArchetype(),beamArchetype(),shotgunArchetype(),missileArchetype(),burstArchetype(),orbitWeaponArchetype(),teslaArchetype(),flakArchetype(),lanceArchetype()) — convenience wrappers that resolve a known registry id with an inline fallback meta blob if the registry entry is missing.
Pattern notes
- Module-side-effect registration: every built-in archetype calls
WeaponArchetypes.register(...)at import time, so simply importing the module populates the registry. - Singleton-as-object pattern (not a class), with method references using the explicit
WeaponArchetypes._registryname rather thanthis— safe when methods are destructured or passed as callbacks. - Capability flags are tri-state-ish in source (
true/false/ absent) but normalized to boolean at read time via!!.can()coerces missing keys tofalse. getModEligibilitycurrently bypasses itsweaponIdargument and always reads theprojectilearchetype’s flags — a vestigial signature that does not yet route per-weapon.- Fallback objects inside the compatibility helpers duplicate the meta literally registered above. If a registration’s flags change, the matching fallback should change too; they are not derived from a single source.
- The header comment notes the port origin (
06b-weapon-archetypes.js) and a deletion marker for theminearchetype (v1.42). New archetypes are added by appending aregister(...)call. - The
damageTypefield uses string tags (kinetic,energy,vampiric,fire,gravity,void,sonic,bio,explosive);entityTypeusesbullet,hitscan,aoe,chain, orcone. Both are advisory labels for downstream systems, not enums enforced here.