ProjectileSpawnSystem Class
System that spawns projectiles for entities with active ShootComponents. More...
Declaration
Public Member Typedefs Index
| using | EngineRoleTag = helios::engine::common::tags::SystemRole |
Public Constructors Index
| ProjectileSpawnSystem (const helios::engine::runtime::spawn::types::SpawnProfileId &spawnProfileId) | |
|
Constructs a ProjectileSpawnSystem with the specified spawn profile. More... | |
Public Member Functions Index
| void | update (helios::engine::runtime::world::UpdateContext &updateContext) noexcept |
|
Processes all shooting entities and spawns projectiles. More... | |
Private Member Attributes Index
| const helios::engine::runtime::spawn::types::SpawnProfileId | spawnProfileId_ |
|
The spawn profile ID used for projectile creation. More... | |
Description
System that spawns projectiles for entities with active ShootComponents.
ProjectileSpawnSystem iterates all entities that have a ShootComponent, Aim2DComponent, and TranslationStateComponent. When a ShootComponent has non-zero intensity and the aim component has a valid frequency, the system calculates how many projectiles to spawn based on accumulated time and cooldown.
## Fire Rate Mechanics
The system implements an intensity-based fire rate: 1. Accumulates `deltaTime * intensity` into the cooldown timer 2. When timer >= cooldownDelta, spawns `floor(timer / cooldownDelta)` projectiles 3. Reduces timer by spawned amount, preserving fractional remainder
This allows continuous fire with variable intensity affecting the effective rate.
## Spawn Context
Each SpawnCommand includes an EmitterContext containing:
- **position:** Current translation from TranslationStateComponent
- **velocity:** sourceVelocity + (aimDirection * projectileSpeed)
Example setup: ```cpp auto projectileSpawnSystem = std::make_unique<ProjectileSpawnSystem>( SpawnProfileId{1} // ID of the projectile spawn profile ); mainPhase.addPass().add(std::move(projectileSpawnSystem)); ```
Entities must have ShootComponent, Aim2DComponent, and TranslationStateComponent to be processed.
- See Also
ShootComponent
- See Also
Aim2DComponent
- See Also
SpawnCommand
- See Also
Definition at line 73 of file ProjectileSpawnSystem.ixx.
Public Member Typedefs
EngineRoleTag
|
Definition at line 86 of file ProjectileSpawnSystem.ixx.
Public Constructors
ProjectileSpawnSystem()
| inline explicit |
Constructs a ProjectileSpawnSystem with the specified spawn profile.
- Parameters
-
spawnProfileId The ID of the spawn profile to use for projectiles.
Definition at line 93 of file ProjectileSpawnSystem.ixx.
Public Member Functions
update()
| inline noexcept |
Processes all shooting entities and spawns projectiles.
For each entity with ShootComponent, Aim2DComponent, and TranslationStateComponent:
1. Skips if aim frequency or intensity are near zero 2. Accumulates `deltaTime * intensity` into the cooldown timer 3. If timer < cooldownDelta, updates timer and continues 4. Calculates projectile count as `floor(timer / cooldownDelta)` 5. Reduces timer by `count * cooldownDelta` 6. Enqueues SpawnCommands with EmitterContext for each projectile
- Parameters
-
updateContext The current frame's update context.
Definition at line 114 of file ProjectileSpawnSystem.ixx.
Reference helios::math::EPSILON_LENGTH.
Private Member Attributes
spawnProfileId_
|
The spawn profile ID used for projectile creation.
References a SpawnProfile in the spawn system that defines how projectiles are placed and initialized.
Definition at line 81 of file ProjectileSpawnSystem.ixx.
The documentation for this class was generated from the following file:
Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.