Complete weapon-fire event routing system for galaxy rendering, supporting multi-entity-type targeting with BeamEffect instanced rendering integration.
-
Enqueue:
enqueueInstallationWeaponFire(event)(public API)- Validates & normalizes event payload
- Limits queue to 180 pending events max
- Calls internal
_queueInstallationWeaponFire()
-
Apply:
_applyPendingInstallationWeaponFire(elapsed)- Routes by entity type (sourceType field)
- Installation:
→ _applyWeaponFireToInstallations() - Future entity types routed to Phase 2 handlers
-
Installation Handler:
_applyWeaponFireToInstallations(ev, elapsed)- Filters FX entries by:
- weaponKind (optional)
- sourceOwner (optional)
- Triggers shot:
_triggerInstallationWeaponFire()
- Filters FX entries by:
-
Trigger Shot:
_triggerInstallationWeaponFire(fxEntry, elapsed, state, cadenceScale)- Calculates cadence & shot duration
- Creates BeamEffect record with colors/geometry
- Calls
this.beamEffect.addBeam(record) - Spawns burst particles (muzzle, impact, debris, trail)
{
sourceType: 'installation', // Routing key (null = broadcast)
sourceOwner: 'Faction Name', // Filter by faction (null = all)
sourcePosition: 0, // [Reserved] target index
weaponKind: 'laser', // Filter by weapon type (null = all)
targetPos: [x, y, z], // [Unused] future impact particles
energy: 100, // [Unused] future HUD display
}- Event Listeners:
gq:combat:weapon-fire,gq:weapon-firewindows events - BeamEffect Pool: Instanced beam rendering via
this.beamEffect.addBeam() - Installation Registry:
this.systemInstallationWeaponFxEntries[] - Burst Emitters: Muzzle, impact, debris, trail particles
Handler: _applyWeaponFireToShips(ev, elapsed)
- Query ship registry from game engine
- Match by sourceOwner (faction/player)
- Locate hardpoint meshes on vessel 3D model
- Trigger multiple weapon discharge sequences
- Handle hull/shield VFX variations
Handler: _applyWeaponFireToDebris(ev, elapsed)
- Track debris objects and positions
- Animate destruction progression
- Accumulate damage state
- Trigger secondary explosions at threshold
Handler: _applyWeaponFireToWormholes(ev, elapsed)
- Visualize destabilization patterns
- Animate energy discharge sequences
- Handle beacon unlock/rupture effects
- Trigger environmental hazards
renderer.enqueueInstallationWeaponFire({
sourceType: 'installation',
weaponKind: 'laser',
// No sourceOwner → fires on ALL installations
});renderer.enqueueInstallationWeaponFire({
sourceType: 'installation',
sourceOwner: 'Helion Confederation',
weaponKind: 'beam',
});window.dispatchEvent(new CustomEvent('gq:combat:weapon-fire', {
detail: {
sourceType: 'installation',
sourceOwner: 'Iron Fleet',
weaponKind: 'missile',
}
}));- Installation Kind Lookup:
_installationWeaponFxCadence(),_installationWeaponFxShotDuration() - Animation State: 'active', 'dormant', 'damaged', 'destroyed'
- Cadence Scale: Per-event multiplier (1.0 = default, 0.7 = slower)
{
id: 'beam_laser_123456', // Unique ID
from: [x, y, z], // Start position (world coords)
to: [x, y, z], // End position
coreColor: 0x66ccff, // Core beam color (RGB int)
color: 0x66ccff, // Glow color
glowRadius: 0.4, // Bloom size
duration: 0.15, // Shot lifetime (seconds)
}- Max Pending: 180 events (configurable)
- FIFO Processing: All accumulated events per frame
- Timestamp:
performance.now()recorded for debug
- BeamEffect Pooling: Instanced rendering = O(1) per beam
- Event Filtering: Early-out on sourceType/weaponKind mismatch
- Entity Iteration: Linear scan of FX entries (feasible <1000 installations)
- Burst Emitters: Only spawned when cooldown expires
- Queue Limiting: Prevents unlimited accumulation during lag spikes
console.log(renderer.pendingInstallationWeaponFire);renderer.enqueueInstallationWeaponFire({
sourceType: 'installation',
weaponKind: 'laser',
});console.log(renderer.beamEffect?.beams?.size);- Ship hardpoint targeting system
- Debris destruction state machine
- Wormhole destabilization animations
- Target impact prediction (collision-based)
- Weapon charge-up sequences
- Electromagnetic interference VFX
- Chain-reaction damage propagation