|
group2 0.1.0
CSE 125 Group 2
|
Client-only input sampling system — split into two halves so mouse look can run every iterate() (smooth camera at any FPS) while movement keys run once per physics tick group (server-consistent). More...
Namespaces | |
| namespace | aimassist |
| namespace | gamepad |
Classes | |
| struct | GamepadAimAssistConfig |
| Tunable parameters for gamepad aim assist. More... | |
| struct | GamepadAimAssistState |
| Per-frame state required to compute the rotational pull as a delta between frames. More... | |
| struct | JoystickAxis |
| Gamepad axis mapping configuration for look and move axes, used to support stick swapping in user settings. More... | |
| struct | ReconciliationStats |
| struct | PendingWeaponDrop |
| A weapon drop queued during view iteration, spawned afterward. More... | |
| class | RewindHitboxesGuard |
| RAII handle that restores hitbox capsules on scope exit after a rewindHitboxes call swapped them for historical samples. More... | |
| struct | SpawnResolution |
| A resolved spawn: safe center position plus the point's facing yaw. More... | |
| struct | BeamLockResult |
| Result of an auto-lock cone scan for a Tesla-style beam. More... | |
Functions | |
| void | runGamepadAimAssist (Registry ®istry, SDL_Gamepad *gamepad, const GamepadAimAssistConfig &cfg, GamepadAimAssistState &state, float pitchSensitivity, float yawSensitivity, float lookDeadzone, float moveDeadzone, float dt, bool swapSticks=false) |
| Apply gamepad aim assist (slowdown + movement-tracking pull) to the local player's InputSnapshot. | |
| JoystickAxis | getLookJoystickAxes (bool swapSticks) |
| Return the SDL axes used for camera look, honoring the stick-swap setting. | |
| JoystickAxis | getMoveJoystickAxes (bool swapSticks) |
| Return the SDL axes used for movement, honoring the stick-swap setting. | |
| bool | gamepadConnected (SDL_Gamepad *gamepad) |
| True when a gamepad handle is non-null and still connected. | |
| bool | consumePendingGrenadeThrow () |
| Consume and clear the queued grenade throw request. | |
| bool | consumePendingGrenadeCycleNext () |
| Consume and clear the queued "cycle to next grenade" request. | |
| bool | consumePendingGrenadeCyclePrev () |
| Consume and clear the queued "cycle to previous grenade" request. | |
| bool | consumePendingGamepadWeaponSwap () |
| Consume and clear the latched tap-Y gamepad weapon swap request. | |
| int | consumePendingEmote () |
| Consume and clear the latched emote-play request (-1 = none). | |
| void | emoteWheelApplyPointing (float dx, float dy, bool accumulate) |
| Resolve emoteWheelSelection from a pointing input. | |
| void | runEmoteWheelKey (const InputBindings &bindings) |
| Track the Emote binding (keyboard/mouse) to open/close the wheel. | |
| void | runMouseLook (Registry ®istry, float mouseSensitivity, bool gravityFlipped=false) |
| Sample mouse delta and accumulate into yaw / pitch. | |
| void | runMovementKeys (Registry ®istry, const InputBindings &bindings, bool gravityFlipped=false) |
| Sample keyboard state into the movement flags. | |
| void | runDeadInput (Registry ®istry, const InputBindings &bindings) |
| Sample skip-respawn input while the local player is dead. | |
| void | runWeaponKeys (Registry ®istry, const InputBindings &bindings) |
| Sample keyboard state into the weapon flags. | |
| void | runInputSample (Registry ®istry, const InputBindings &bindings, float mouseSensitivity=user_settings::kDefaultMouseSensitivity) |
| Legacy combined sampler — calls both runMouseLook and runMovementKeys. | |
| void | runGamepadLook (Registry ®istry, SDL_Gamepad *gamepad, float pitchSensitivity, float yawSensitivity, float deadzone, float dt, bool gravityFlipped=false, bool swapSticks=false) |
| Sample the right stick into yaw / pitch. | |
| void | runGamepadEmoteWheel (SDL_Gamepad *gamepad, const InputBindings &bindings, bool swapSticks=false) |
| Track the Emote binding (controller) to open/close the wheel and pick a sector from the right stick. | |
| void | runGamepadMovement (Registry ®istry, SDL_Gamepad *gamepad, const InputBindings &bindings, float deadzone, bool gravityFlipped=false, bool swapSticks=false) |
| Sample gamepad buttons / left stick into the movement flags. | |
| void | runGamepadWeapon (Registry ®istry, SDL_Gamepad *gamepad, const InputBindings &bindings) |
| Sample gamepad buttons / right trigger into the weapon flags. | |
| void | runGamepadDeadInput (Registry ®istry, SDL_Gamepad *gamepad, const InputBindings &bindings) |
| Sample controller skip-respawn input while the local player is dead. | |
| void | runInputSend (Registry ®istry, Client &conn) |
| Send the local player's current InputSnapshot over the network. | |
| void | runPrediction (Registry ®istry, float dt, const physics::WorldGeometry &world) |
| Run one tick of client-side prediction for the local player. | |
| ReconciliationStats | runReconciliation (Registry ®istry, const InputRingBuffer &ring, uint32_t ackedTick, uint32_t currentTick, float dt, const physics::WorldGeometry &world) |
| Replay stored inputs from ackedTick + 1 through currentTick on the local player, restoring its predicted state after a snapshot apply rewrote it to the server-authoritative value. | |
| void | tickCooldown (float &cooldown, float dt) |
| void | useAbility (entt::entity player, AbilityType type, Registry ®istry, AbilityRegistry &abilityRegistry) |
| bool | queueAbilityChoice (AbilityState &state) |
| void | grantAbilityLevel (AbilityState &state) |
| void | grantAbilityProgress (AbilityState &state, float amount) |
| void | handleAbilitySelection (InputSnapshot &snap, AbilityState &state) |
| void | runAbility (Registry ®istry, AbilityRegistry &abilityRegistry, float dt) |
| static void | depenetratePlanes (glm::vec3 &pos, glm::vec3 &vel, const glm::vec3 &halfExtents, std::span< const physics::Plane > planes) |
| Push the entity out of any infinite planes it currently overlaps. | |
| static void | depenetrateBox (glm::vec3 &pos, glm::vec3 &vel, const glm::vec3 &halfExtents, const physics::WorldAABB &box) |
| Push the entity out of a static AABB it currently overlaps. | |
| static void | depenetrateBrush (glm::vec3 &pos, glm::vec3 &vel, const glm::vec3 &halfExtents, const physics::WorldBrush &brush) |
| Push the entity out of a convex brush it currently overlaps. | |
| static void | depenetrateCylinder (glm::vec3 &pos, glm::vec3 &vel, const glm::vec3 &halfExtents, const physics::WorldCylinder &cyl) |
| Push the entity out of a vertical cylinder it currently overlaps. | |
| static void | depenetrateSphere (glm::vec3 &pos, glm::vec3 &vel, const glm::vec3 &halfExtents, const physics::WorldSphere &sph) |
| Push the entity out of a world sphere it currently overlaps. | |
| static void | depenetrateTriMesh (glm::vec3 &pos, glm::vec3 &vel, const glm::vec3 &halfExtents, const physics::WorldTriMesh &mesh) |
| Push the entity out of a triangle mesh it currently overlaps. | |
| static bool | overlapsAabb (const physics::WorldAABB &a, const physics::WorldAABB &b) |
| static void | depenetrate (glm::vec3 &pos, glm::vec3 &vel, const glm::vec3 &halfExtents, const physics::WorldGeometry &world) |
| Run all depenetration passes for legacy AABB bodies. | |
| void | runCollision (Registry ®istry, float dt, const physics::WorldGeometry &world) |
| Run one tick of swept-AABB collision for all physics entities. | |
| void | spawnDroppedWeapon (Registry ®istry, glm::vec3 pos, glm::vec3 initialVel, const GunInstance &gun, float pickupDelay) |
| Spawn an in-world dropped-weapon pickup carrying a gun's ammo. | |
| bool | tryPickup (Registry ®istry, Position dropPos, CollisionShape dropShape, const DroppedWeapon &dw, std::vector< PendingWeaponDrop > &pendingDrops) |
| Try to grant the dropped weapon to a player. | |
| void | runDroppedWeapons (Registry ®istry, float dt) |
| Tick dropped weapons: handle pickup (overlap-refill or look+F replace) and despawn timer. | |
| void | runDynamics (Registry ®istry, float dt, const physics::WorldGeometry &world, physics::ContactCache &cache, const physics::SolverConfig &solverCfg, const physics::SleepConfig &sleepCfg) |
| One physics tick for rigid-body dynamic entities. | |
| void | queueExplosion (Registry ®istry, glm::vec3 position, float radius, float maxDamage, entt::entity owner, float falloffExponent=1.0f, float selfDamageMultiplier=1.0f, float maxKnockback=0.0f, float knockbackFalloffExponent=1.0f, entt::entity directKillTarget=entt::null, WeaponType weaponType=WeaponType::Rocket) |
| Create an explosion entity at the given position. | |
| void | runExplosion (Registry ®istry, std::vector< NetParticleEvent > &outParticles, std::vector< NetKillEvent > &killEvents) |
| Process all pending explosions: apply radial damage and emit particle events. | |
| void | spawnFireField (Registry ®istry, glm::vec3 position, float radius, float duration, float dps, entt::entity owner) |
| Spawn a FireField at position that lasts duration seconds and deals dps damage to players inside radius. | |
| void | runFireField (Registry ®istry, float dt, std::vector< NetKillEvent > &killEvents) |
| Tick all FireField entities: decrement remaining, apply DoT damage at fixed sub-intervals (4 Hz), and destroy expired fields. | |
| void | checkForPlayers (Registry ®istry, Position spawnerPos, CollisionShape spawnerShape, HealthPackSpawner &spawner) |
| Check if any player overlaps the spawner and transfer the weapon on pickup. | |
| void | runHealthPackSpawners (Registry ®istry, float dt) |
| Tick spawners: check player overlap for pickup, manage cooldowns. | |
| void | updateHitboxes (Registry ®istry, const HitboxRig &hitboxRig, float rigScale, float rigMeshMinY) |
| Update world-space hitbox capsules for all entities that have JointMatrices. | |
| void | runJumpPads (Registry ®istry, float dt) |
| Tick jump pads: for each pad, any player whose AABB overlaps the pad's trigger volume on the rising edge has the pad's velocity applied as an impulse. | |
| void | runKillzones (Registry ®istry, std::vector< NetKillEvent > &killEvents) |
| Tick killzones: for each killzone trigger, any player whose AABB overlaps it takes lethal damage. | |
| physics::KccFrameResult | runKinematicCharacterController (glm::vec3 &pos, glm::vec3 &vel, const CollisionShape &shape, PlayerVisState &state, float dt, const physics::WorldGeometry &world, entt::entity entity, bool jumpedThisTick, PlayerSimState *simState=nullptr) |
| Resolve one fixed-tick capsule character-controller step. | |
| RewindHitboxesGuard | rewindHitboxes (Registry ®istry, entt::entity shooter, const glm::vec3 *rayOrigin=nullptr, const glm::vec3 *rayDirection=nullptr, float rayMaxDistance=0.0f, float bulletRadius=0.0f) |
| Rewind every other player's hitbox capsules to where they were on shooter's screen at fire time. | |
| std::optional< ClientId > | handleWinCondition (Registry ®istry, int killsToWin) |
| Checks if any player has met win condition and updates their PlayerMatchStats accordingly. | |
| void | resetStats (Registry ®istry) |
| Resets all players' match scores to initial values. | |
| float | currentWishSpeed (const PlayerVisState &vis) |
| Determine the current ground wish speed based on movement mode and stance. | |
| void | reconcileMovementAfterKcc (glm::vec3 &pos, glm::vec3 &vel, const CollisionShape &shape, PlayerVisState &vis, PlayerSimState &sim, const InputSnapshot &input, const physics::WorldGeometry &world, const physics::KccFrameResult &kcc, float dt) |
| Consume collision-owned KCC feedback after position integration. | |
| void | runMovement (Registry ®istry, float dt, const physics::WorldGeometry &world) |
| Apply one tick of player movement physics to all eligible entities. | |
| bool | overlapsAABB (glm::vec3 aPos, glm::vec3 aHalf, glm::vec3 bPos, glm::vec3 bHalf) |
| Test whether two axis-aligned bounding boxes overlap. | |
| glm::vec3 | viewForward (float yaw, float pitch) |
| Forward direction implied by a player's yaw + pitch. | |
| bool | isPlayerLookingAtPickup (glm::vec3 eye, glm::vec3 viewFwd, glm::vec3 pickupPos) |
| True if the eye is within range of pickupPos and viewFwd points within the look cone. | |
| void | applyHeal (float amount, Health &playerHealth) |
| float | standingHalfHeight (const CollisionShape &shape) |
| physics::CapsuleShape | spawnCapsuleFor (const CollisionShape &shape) |
| glm::vec3 | resolveRespawnPosition (Registry ®istry, entt::entity player, glm::vec3 feetPosition) |
| SpawnResolution | chooseRespawnPoint (Registry ®istry, entt::entity respawning) |
| Choose a respawn point with cooldown-aware, enemy-avoiding selection. | |
| SpawnResolution | chooseAndResolveSpawnPosition (Registry ®istry, entt::entity player) |
| Pick a respawn point and resolve it to a safe spawn center. | |
| void | handleRespawn (entt::entity &player, Registry ®istry) |
| Reset a dead player to a fresh spawn state. | |
| void | handleDeath (entt::entity &player, Health &playerHealth, entt::entity &killer, Registry ®istry, std::vector< NetKillEvent > &killEvents, BodyRegion hitRegion) |
| Transition a player to the dead state if health has reached zero. | |
| void | updateAbilityLevel (Registry ®istry, entt::entity player, float dmg) |
| float | absorbDamage (float &pool, float damage) |
| float | absorbDamageScaled (float &pool, float damage, float effectiveness) |
| Absorb damage through a shield pool with reduced effectiveness. | |
| void | applyBulletSlow (entt::entity player, Registry ®istry) |
| Refresh the bullet-hit movement slow on a player. | |
| float | applyDamage (float damage, entt::entity player, entt::entity &killer, Registry ®istry, std::vector< NetKillEvent > &killEvents, BodyRegion hitRegion=BodyRegion::UpperTorso, float shieldMultiplier=1.0f) |
| Apply damage to a player, splitting across armor then health. | |
| void | handleHealing (Health &playerHealth, float dt) |
| Tick passive health regeneration after the heal cooldown expires. | |
| void | runPlayerStatus (Registry ®istry, float dt) |
| Run one tick of player status: respawn timers and passive healing. | |
| void | runSpawnPointCooldowns (Registry ®istry, float dt) |
| Tick spawn point cooldowns. | |
| bool | hasPowerup (const PowerupState &state, PowerupType type) |
| void | addOrRefreshPowerup (PowerupState &state, PowerupType type, float duration) |
| void | removePowerup (PowerupState &state, PowerupType type) |
| void | applyPowerupSpawnerConfig (Registry ®istry, const MatchConfig &matchConfig) |
| Clamp pending powerup cooldowns to the current host-managed timing settings. | |
| void | resetPowerupSpawnersForMatch (Registry ®istry, const MatchConfig &matchConfig) |
| Hide all powerups and restart their initial match-start spawn delay. | |
| void | checkForPlayers (Registry ®istry, Position spawnerPos, CollisionShape spawnerShape, PowerupSpawner &spawner, const MatchConfig &matchConfig, std::vector< NetParticleEvent > &outEvents) |
| Check if any player overlaps the spawner and transfer the powerup on collision. | |
| void | runPowerupSpawners (Registry ®istry, float dt, const MatchConfig &matchConfig, std::vector< NetParticleEvent > &outEvents) |
| Tick Powerup spawners: check player overlap for pickup, manage cooldowns. | |
| void | runPowerups (Registry ®istry, float dt) |
| Run one tick of powerup logic for all players. | |
| entt::entity | spawnRagdoll (Registry ®istry, entt::entity character) |
| Build a 15-body humanoid ragdoll for the dead character. | |
| void | destroyRagdoll (Registry ®istry, entt::entity character) |
| Destroy the ragdoll bodies and joints owned by a character. | |
| void | runRagdolls (Registry ®istry, float dt) |
| Per-tick ragdoll bookkeeping: advance age, optionally tick the cleanup timer for old corpses. | |
| void | update (Registry ®istry, float dt) |
| Placeholder system — replace with real logic. | |
| void | runTriggers (Registry ®istry, bool isPredictedClient=false) |
| Test every trigger-volume entity for overlap with non-trigger entities and emit Enter / Stay / Exit events. | |
| void | checkForPlayers (Registry ®istry, Position spawnerPos, CollisionShape spawnerShape, WeaponSpawner &spawner, std::vector< PendingWeaponDrop > &pendingDrops) |
| Check if any player overlaps the spawner and transfer the weapon on pickup. | |
| void | runWeaponSpawners (Registry ®istry, float dt) |
| Tick weapon spawners: check player overlap for pickup, manage cooldowns. | |
| bool | combatLogEnabled () |
| void | handleSwitch (const InputSnapshot &input, WeaponState &weapon) |
| Apply weapon slot switch from player input. | |
| void | handleCooldown (WeaponState &weapon, float dt) |
| Tick fire cooldowns for all weapon slots. | |
| void | handleGrenadeCooldown (GrenadeState &grenades, float dt) |
| void | handleReload (GunInstance &gun) |
| Reload the gun's magazine from reserve ammo. | |
| bool | handleAmmo (GunInstance &gun) |
| Consume one round from the magazine; auto-reload if empty. | |
| glm::vec3 | muzzleOrigin (glm::vec3 eye, glm::vec3 direction, bool gravityFlipped=false) |
| Offset the muzzle origin from the eye position for tracer visuals. | |
| void | logShot (Registry ®istry, entt::entity shooter, std::uint32_t shotInputTick, const glm::vec3 &origin, const glm::vec3 &direction, const physics::HitboxHit &hit) |
| void | captureShotDebug (Registry ®istry, entt::entity shooter, std::uint32_t shotInputTick, const glm::vec3 &origin, const glm::vec3 &direction, float range, const physics::HitboxHit &hit, std::vector< net::shotdebug::ShotDebugCapture > *out) |
| static void | spawnGrenade (Registry ®istry, entt::entity shooter, WeaponType type, glm::vec3 muzzle, glm::vec3 eyeDir, glm::vec3 eyeRight, glm::vec3 throwerVel) |
| Spawn a grenade projectile from the player's eye position. | |
| int | nextGrenadeWithAmmo (const GrenadeState &grenades, int start, int dir) |
Find the next grenade type index (wrapping in direction dir, +1 or -1) that still has ammo, starting the search one step away from start. | |
| void | handleGrenadeInput (Registry ®istry, entt::entity shooter, InputSnapshot &input, const Position &pos, const CollisionShape &shape, GrenadeState &grenades, bool gravityFlipped) |
| void | handleScope (Registry ®istry, entt::entity shooter, const InputSnapshot &input, WeaponState &weapon, float dt) |
| BeamLockResult | findBeamLockTarget (Registry ®istry, entt::entity shooter, glm::vec3 eye, glm::vec3 viewDir, const WeaponConfig &config) |
| Pick the enemy closest to the crosshair inside the lock-on cone. | |
| void | handleFire (Registry ®istry, entt::entity shooter, const InputSnapshot &input, const Position &pos, const CollisionShape &shape, WeaponState &weapon, bool gravityFlipped, bool grenadeThrowActive, float dt, std::vector< NetParticleEvent > &outParticles, std::vector< NetKillEvent > &killEvents, std::vector< net::shotdebug::ShotDebugCapture > *outShotDebug) |
| Process fire input: hitscan raycasts, beam weapons, charge shots, and projectiles. | |
| void | runWeapon (Registry ®istry, float dt, std::vector< NetParticleEvent > &outParticles, std::vector< NetKillEvent > &killEvents, std::vector< net::shotdebug::ShotDebugCapture > *outShotDebug=nullptr) |
| Run one tick of weapon logic for all armed entities. | |
| void | pushHitboxHistory (Registry ®istry, uint32_t serverTick) |
| Capture this tick's hitbox capsules into each entity's HitboxHistory ring. | |
| Event | runInputReceive (const void *data) |
| Deserialise a raw InputSnapshot packet into a gameplay Event. | |
Variables | |
| bool | prevKillSelfKey = false |
| Tracks previous-frame key state for edge detection. | |
| bool | prevGrenadeCycleKey = false |
| Previous-frame CycleGrenade (H) / ThrowGrenade (G) key state for edge detection (keyboard/mouse). | |
| bool | prevGrenadeThrowKey = false |
| bool | prevGamepadGrenadeCycleKey = false |
| Gamepad equivalents: CycleGrenade (D-pad Left) / ThrowGrenade (B). | |
| bool | prevGamepadGrenadeThrowKey = false |
| bool | pendingGrenadeThrow = false |
| Latched throw request, consumed once per frame by the game loop. | |
| bool | pendingGrenadeCycleNext = false |
| Latched cycle next/prev requests, consumed once per frame by the game loop. | |
| bool | pendingGrenadeCyclePrev = false |
| bool | prevAbilitySelectLeft = false |
| Tracks previous-frame Alt+LMB state for ability choice edge detection. | |
| bool | prevAbilitySelectRight = false |
| Tracks previous-frame Alt+RMB state for ability choice edge detection. | |
| bool | prevGamepadAbilitySelectLeft = false |
| Tracks previous-frame gamepad left ability-select chord for edge detection. | |
| bool | prevGamepadAbilitySelectRight = false |
| Tracks previous-frame gamepad right ability-select chord for edge detection. | |
| bool | prevGamepadPickupKey = false |
| Gamepad Y (Pickup binding) tap-vs-hold state: tap swaps weapon, hold picks up. | |
| Uint64 | gamepadPickupDownMs = 0 |
| SDL_GetTicks at the Y press, for hold-duration timing. | |
| bool | gamepadPickupHoldFired = false |
| Set once the press crossed the hold threshold (suppresses tap-swap). | |
| bool | pendingGamepadWeaponSwap = false |
| Latched tap-Y weapon swap, consumed once per frame by the game loop. | |
| float | gamepadLookAccel = 0.0f |
| COD-style look acceleration progress in [0, 1]; ramps while the look stick is held near full deflection and resets when it eases off. | |
| bool | emoteWheelOpen = false |
| True while the emote wheel is open (Emote binding held on any device). | |
| int | emoteWheelSelection = -1 |
| Currently highlighted emote sector while the wheel is open, or -1 (none). | |
| float | emoteWheelDirX = 0.0f |
| Accumulated pointing direction used to resolve the highlighted sector. | |
| float | emoteWheelDirY = 0.0f |
| int | pendingEmoteRequest = -1 |
| Latched emote to play on wheel release; consumed once by the game loop. | |
| bool | prevEmoteKey = false |
| Previous-frame Emote-binding state for open/close edge detection. | |
| bool | prevGamepadEmoteKey = false |
| constexpr float | dmgThreshold = 1000.0f |
| constexpr int | maxLevel = 2 |
| static constexpr float | k_pushback = 0.03125f |
| constexpr float | k_droppedWeaponLifetime = 30.0f |
| Default lifetime (seconds) for a dropped weapon before it despawns. | |
| constexpr float | k_swapDropPickupDelay = 0.8f |
| Pickup-immunity applied to a weapon dropped during a swap, so the player can't instantly re-grab the gun they just replaced. | |
| constexpr float | healthPackCooldownTime = 15.0f |
| constexpr float | k_pickupRange = 140.0f |
| Maximum distance (units) at which a player can press F to pick up. | |
| const glm::vec3 | k_weaponPickupHalfExtents {32.0f, 32.0f, 32.0f} |
| Shared pickup collision half-extents for weapon spawners and dropped weapons. | |
| constexpr float | k_pickupMaxAngleDeg = 12.0f |
| Half-angle (degrees) of the look cone for press-F pickup. | |
| const float | k_pickupMinDot = std::cos(glm::radians(k_pickupMaxAngleDeg)) |
| Pre-computed cosine of the look cone half-angle. | |
| constexpr float | k_spawnPointCooldown = 5.0f |
| Cooldown duration set on a spawn point after a player spawns there. | |
| constexpr float | k_spawnPushback = 0.03125f |
| const float | armorMax = 100.0f |
| Maximum armor value. | |
| const float | healthMax = 100.0f |
| Maximum health value. | |
| const float | overShieldMax = 200.0f |
| const float | healCooldown = 5.0f |
| Seconds after last damage before passive healing starts. | |
| const float | healingRate = 20.0f |
| Passive healing amount per second. | |
| constexpr float | weaponCooldownTime = 10.0f |
Client-only input sampling system — split into two halves so mouse look can run every iterate() (smooth camera at any FPS) while movement keys run once per physics tick group (server-consistent).
Input receive system functions.
Weapon state update system.
Weapon spawner update system.
ECS systems namespace.
Powerup state update system.
Powerup spawner update system.
Player status update system.
Shared movement system — compiled identically on client and server.
Health pack spawner update system.
Shared collision system — compiled identically on client and server.
Client-only system that serialises and sends input to the server.
Any divergence between client and server builds is a bug (breaks prediction).
Any divergence between client and server builds is a bug (breaks prediction).
Implements the Titanfall-inspired movement state machine: OnFoot → Sliding → WallRunning with sprint, double jump, coyote time, jump lurch, air strafing, and speed cap.
Each free function (or callable) represents one system. A system receives the shared Registry and any per-frame state it needs, then queries and mutates components.
Concrete system implementations live in individual .hpp/.cpp pairs under this directory.
|
inline |
|
inline |
Absorb damage through a shield pool with reduced effectiveness.
effectiveness scales how fast the pool drains: removing one point of the pool consumes 1 / effectiveness points of the incoming damage budget. With effectiveness == 1 this is identical to absorbDamage; with 0.2 the pool is 5× as tanky (a 100-shield needs 500 damage to break). Returns the leftover damage budget after the pool is exhausted (always full-value, to be applied to the next, less-resistant layer).
| void systems::addOrRefreshPowerup | ( | PowerupState & | state, |
| PowerupType | type, | ||
| float | duration ) |
| void systems::applyBulletSlow | ( | entt::entity | player, |
| Registry & | registry ) |
Refresh the bullet-hit movement slow on a player.
Sets the player's PlayerSimState::bulletSlowTimer to tms::k_bulletHitSlowDuration, so the next ground-movement tick clamps the wish speed to k_bulletHitSlowFactor of normal. Hitscan call sites in WeaponSystem invoke this alongside applyDamage so getting shot punishes the target's mobility; explosion / fire / killzone damage paths skip it. No-op if player lacks PlayerSimState (e.g. a hit dummy).
| float systems::applyDamage | ( | float | damage, |
| entt::entity | player, | ||
| entt::entity & | killer, | ||
| Registry & | registry, | ||
| std::vector< NetKillEvent > & | killEvents, | ||
| BodyRegion | hitRegion = BodyRegion::UpperTorso, | ||
| float | shieldMultiplier = 1.0f ) |
Apply damage to a player, splitting across armor then health.
Resets the heal cooldown timer. If health reaches zero, triggers death handling (respawn timer, kill event, stats update).
| damage | Damage amount being applied. |
| player | Player entity who took damage. |
| killer | Entity who dealt the final blow. |
| registry | The ECS registry. |
| killEvents | Accumulates kill events for network broadcast. |
| hitRegion | Body region that was hit (for kill feed / headshot tracking). |
| shieldMultiplier | Effectiveness against shield layers (overShield + armor). 1.0 = full; <1.0 makes shields drain slower (energy-vs-energy weapons). Damage spilling into raw health is always applied at full. |
| void systems::applyHeal | ( | float | amount, |
| Health & | playerHealth ) |
Apply a healing amount, filling health first then armor.
Apply a healing amount, filling health first then armor.
| amount | Healing amount being applied. |
| playerHealth | Entity's health component (modified in place). |
| amount | Healing amount being applied. |
| playerHealth | Entity's health component (modified in place). |
| void systems::applyPowerupSpawnerConfig | ( | Registry & | registry, |
| const MatchConfig & | matchConfig ) |
Clamp pending powerup cooldowns to the current host-managed timing settings.
|
inline |
|
inline |
Check if any player overlaps the spawner and transfer the weapon on pickup.
| registry | The ECS registry. |
| spawnerPos | Position of the spawner entity. |
| spawnerShape | Collision shape of the spawner. |
| spawner | Spawner component |
|
inline |
Check if any player overlaps the spawner and transfer the powerup on collision.
| registry | The ECS registry. |
| spawnerPos | Position of the spawner entity. |
| spawnerShape | Collision shape of the spawner. |
| spawner | Spawner component. |
|
inline |
Check if any player overlaps the spawner and transfer the weapon on pickup.
| registry | The ECS registry. |
| spawnerPos | Position of the spawner entity. |
| spawnerShape | Collision shape of the spawner. |
| spawner | Spawner component (weapon type, availability, cooldown). |
| SpawnResolution systems::chooseAndResolveSpawnPosition | ( | Registry & | registry, |
| entt::entity | player ) |
Pick a respawn point and resolve it to a safe spawn center.
Uses the same cooldown-aware spawn selection and depenetration logic as on-death respawn, so initial join spawns share the live respawn behavior. Spawn points are biased away from living enemies, and the chosen point's authored facing yaw is returned so the caller can orient the player. The player's CollisionShape should already be attached so the capsule recovery sweep matches the player's actual shape.
| registry | The ECS registry. |
| player | The player entity whose spawn position to resolve. |
|
inline |
Choose a respawn point with cooldown-aware, enemy-avoiding selection.
Prefers available (cooldown = 0) spawn points, biased toward those farthest from living enemies (random tiebreak among the safest few so spawns aren't fully deterministic). If all points are on cooldown, picks the one closest to being ready. Sets a cooldown on the chosen point and returns its feet position plus authored facing yaw.
|
inline |
|
inline |
Consume and clear the latched emote-play request (-1 = none).
|
inline |
Consume and clear the latched tap-Y gamepad weapon swap request.
|
inline |
Consume and clear the queued "cycle to next grenade" request.
|
inline |
Consume and clear the queued "cycle to previous grenade" request.
|
inline |
Consume and clear the queued grenade throw request.
| float systems::currentWishSpeed | ( | const PlayerVisState & | vis | ) |
Determine the current ground wish speed based on movement mode and stance.
Returns the speed the player is accelerating toward on the ground this tick: tms::k_adsSpeed (if ADS-ing a precision weapon), else tms::k_crouchSpeed / k_sprintSpeed / k_walkSpeed, or 0 during a slide. For air movement use physics::k_airMaxSpeed directly.
| vis | Replicated player vis state (for moveMode + crouching + sprinting + ads). |
|
static |
Run all depenetration passes for legacy AABB bodies.
| pos | Entity position (modified in place). |
| vel | Entity velocity (modified in place). |
| halfExtents | AABB half-extents of the entity. |
| world | World collision geometry. |
|
static |
Push the entity out of a static AABB it currently overlaps.
| pos | Entity position (modified in place). |
| vel | Entity velocity (modified in place). |
| halfExtents | AABB half-extents of the entity. |
| box | Static axis-aligned bounding box to test against. |
|
static |
Push the entity out of a convex brush it currently overlaps.
Only fires if the entity is inside ALL planes simultaneously.
| pos | Entity position (modified in place). |
| vel | Entity velocity (modified in place). |
| halfExtents | AABB half-extents of the entity. |
| brush | Convex brush to test against. |
|
static |
Push the entity out of a vertical cylinder it currently overlaps.
|
static |
Push the entity out of any infinite planes it currently overlaps.
| pos | Entity position (modified in place). |
| vel | Entity velocity (modified in place). |
| halfExtents | AABB half-extents of the entity. |
| planes | Infinite planes to test against. |
|
static |
Push the entity out of a world sphere it currently overlaps.
|
static |
Push the entity out of a triangle mesh it currently overlaps.
Delegates to physics::depenetrateAABBvsTriMesh, the legacy projectile AABB safety-net path. Player movement uses capsule depenetration in physics::depenetrateCapsuleVsWorld; this remains for small projectile bodies that still use AABB sweeps.
| void systems::destroyRagdoll | ( | Registry & | registry, |
| entt::entity | character ) |
Destroy the ragdoll bodies and joints owned by a character.
Called when the player respawns or disconnects. This removes the transient physics entities immediately instead of letting every death leave orphan registry entries behind.
|
inline |
Resolve emoteWheelSelection from a pointing input.
| dx,dy | Pointing delta in screen convention (dx right, dy down). |
| accumulate | True for mouse deltas (integrated into a virtual stick), false for an absolute stick direction. |
The wheel lays emote 0 at the top and proceeds clockwise. A small deadzone keeps the selection empty until the player points clearly in a direction.
|
inline |
Pick the enemy closest to the crosshair inside the lock-on cone.
Scans every other player's hitbox capsules. A candidate qualifies when its centre of mass is within maxRange, inside the cone of half-angle coneHalfAngleDeg around viewDir, and has clear line-of-sight from eye (no world geometry between the shooter and the target). Among qualifying candidates the one with the smallest angular deviation from the crosshair wins. Must be called while any lag-compensation rewind guard is in scope so the capsules reflect the attacker's screen-time positions.
|
inline |
True when a gamepad handle is non-null and still connected.
|
inline |
Return the SDL axes used for camera look, honoring the stick-swap setting.
|
inline |
Return the SDL axes used for movement, honoring the stick-swap setting.
| void systems::grantAbilityLevel | ( | AbilityState & | state | ) |
| void systems::grantAbilityProgress | ( | AbilityState & | state, |
| float | amount ) |
|
inline |
|
inline |
Consume one round from the magazine; auto-reload if empty.
| gun | Gun instance to consume ammo from (modified in place). |
|
inline |
Tick fire cooldowns for all weapon slots.
| weapon | Weapon state (modified in place). |
| dt | Fixed physics delta time in seconds. |
|
inline |
Transition a player to the dead state if health has reached zero.
Hides the player, removes hitboxes, starts a 5-second respawn timer, updates death/kill stats, and emits a NetKillEvent for the kill feed.
| player | Entity that died. |
| playerHealth | Health component (already at or below zero). |
| killer | Entity that dealt the killing blow. |
| registry | The ECS registry. |
| killEvents | Accumulates kill events for network broadcast. |
| hitRegion | Body region of the killing blow. |
|
inline |
Process fire input: hitscan raycasts, beam weapons, charge shots, and projectiles.
Handles three weapon archetypes:
Emits NetParticleEvent entries for tracer/impact effects and applies damage through applyDamage() which may trigger kill events.
| registry | The ECS registry. |
| shooter | Entity that is firing. |
| input | Current input snapshot. |
| pos | Shooter position. |
| shape | Shooter collision shape (for eye height). |
| weapon | Shooter weapon state (modified in place). |
| gravityFlipped | True when the shooter's gravity is inverted. |
| dt | Fixed physics delta time in seconds. |
| outParticles | Accumulates particle events for network broadcast. |
| killEvents | Accumulates kill events for network broadcast. |
| outShotDebug | PR-20: optional server-side debug capture sink. When non-null, each hitscan-fire path pushes one ShotDebugCapture row while RewindHitboxesGuard is still active, so the captured targets[*]. capsules reflect the historical sample the server actually raycast against. |
|
inline |
|
inline |
|
inline |
Tick passive health regeneration after the heal cooldown expires.
| playerHealth | Health component (modified in place). |
| dt | Fixed physics delta time in seconds. |
|
inline |
Reload the gun's magazine from reserve ammo.
| gun | Gun instance to reload (modified in place). |
|
inline |
Reset a dead player to a fresh spawn state.
Clears the respawn timer and death info, restores visibility, resets position/velocity/health/weapons to defaults, and places the player at the spawn point.
| player | Entity to respawn (modified in place). |
| registry | The ECS registry. |
|
inline |
| void systems::handleSwitch | ( | const InputSnapshot & | input, |
| WeaponState & | weapon ) |
Apply weapon slot switch from player input.
| input | Current input snapshot. |
| weapon | Weapon state (modified in place). |
Checks if any player has met win condition and updates their PlayerMatchStats accordingly.
| bool systems::hasPowerup | ( | const PowerupState & | state, |
| PowerupType | type ) |
|
inline |
True if the eye is within range of pickupPos and viewFwd points within the look cone.
|
inline |
|
inline |
Offset the muzzle origin from the eye position for tracer visuals.
Shifts the origin right and down from eye, slightly forward, so tracers don't originate from the center of the screen.
| eye | Eye position (camera origin). |
| direction | Normalized view direction. |
| gravityFlipped | When true, negate the horizontal offset so the tracer originates from the viewmodel side. The viewmodel stays on screen-right, but the 180° camera roll reverses world-left/right — so world-right (the normal offset) appears on the wrong side of the screen. |
|
inline |
Find the next grenade type index (wrapping in direction dir, +1 or -1) that still has ammo, starting the search one step away from start.
Returns start when no other type has ammo (including when start itself is the only one with ammo, or none do).
|
inline |
Test whether two axis-aligned bounding boxes overlap.
|
static |
| void systems::pushHitboxHistory | ( | Registry & | registry, |
| uint32_t | serverTick ) |
Capture this tick's hitbox capsules into each entity's HitboxHistory ring.
For every entity that has a HitboxInstance, copies its current capsules vector into the next slot of the ring and records the owning server tick. Entities without a HitboxInstance (e.g. dead players whose capsules were dropped by updateHitboxes) are skipped — their existing samples stay in the ring, so a target that died ~200 ms ago can still be hit by a delayed shot once rewind lands.
| registry | The ECS registry. |
| serverTick | Current server tick (monotonic, 128 Hz). Stored alongside the capsules so the rewind guard can pick the closest sample to the attacker's tick. |
|
inline |
| void systems::queueExplosion | ( | Registry & | registry, |
| glm::vec3 | position, | ||
| float | radius, | ||
| float | maxDamage, | ||
| entt::entity | owner, | ||
| float | falloffExponent = 1.0f, | ||
| float | selfDamageMultiplier = 1.0f, | ||
| float | maxKnockback = 0.0f, | ||
| float | knockbackFalloffExponent = 1.0f, | ||
| entt::entity | directKillTarget = entt::null, | ||
| WeaponType | weaponType = WeaponType::Rocket ) |
Create an explosion entity at the given position.
The explosion is processed on the next call to runExplosion().
| registry | The ECS registry. |
| position | World-space center of the explosion. |
| radius | Blast radius (damage falls off to zero at edge). |
| maxDamage | Maximum damage at the epicenter. |
| owner | Entity that caused the explosion (for self-damage / kill credit). |
| falloffExponent | Damage curve exponent (1 = linear, 3 = cubic/sharp). |
| selfDamageMultiplier | Damage scale when victim == owner (e.g. 0.4 for rocket jumps). |
| maxKnockback | Peak knockback velocity (u/s) imparted at the epicenter. |
| knockbackFalloffExponent | Knockback curve exponent (same form as damage falloff). |
| directKillTarget | If valid, this entity takes guaranteed lethal damage regardless of radius/falloff (used by a grenade stuck to a player). |
| void systems::reconcileMovementAfterKcc | ( | glm::vec3 & | pos, |
| glm::vec3 & | vel, | ||
| const CollisionShape & | shape, | ||
| PlayerVisState & | vis, | ||
| PlayerSimState & | sim, | ||
| const InputSnapshot & | input, | ||
| const physics::WorldGeometry & | world, | ||
| const physics::KccFrameResult & | kcc, | ||
| float | dt ) |
Consume collision-owned KCC feedback after position integration.
MovementSystem owns traversal state. CollisionSystem calls this immediately after KCC so wallrun can respond to blockers, ceilings, and solver stalls before the next movement tick accelerates again.
| void systems::removePowerup | ( | PowerupState & | state, |
| PowerupType | type ) |
| void systems::resetPowerupSpawnersForMatch | ( | Registry & | registry, |
| const MatchConfig & | matchConfig ) |
Hide all powerups and restart their initial match-start spawn delay.
| void systems::resetStats | ( | Registry & | registry | ) |
Resets all players' match scores to initial values.
|
inline |
|
inline |
Rewind every other player's hitbox capsules to where they were on shooter's screen at fire time.
Reads LagCompTarget from shooter. If absent or zero, returns a no-op guard immediately (the common case for client-side and for sub-tick-RTT shooters). Otherwise walks every entity with both HitboxInstance and HitboxHistory, finds the most recent history sample whose tick is ≤ targetServerTick, swaps the live capsules for the historical ones, and stashes the originals in the returned guard for restore-on-destruction.
PR-5 (server-perf): two overloads.
shooter itself is not rewound — resolveHitscanHitbox already excludes the shooter from the player-hitbox raycast.
| registry | The server ECS registry. |
| shooter | Entity firing the hitscan. Read for LagCompTarget. |
| void systems::runAbility | ( | Registry & | registry, |
| AbilityRegistry & | abilityRegistry, | ||
| float | dt ) |
| void systems::runCollision | ( | Registry & | registry, |
| float | dt, | ||
| const physics::WorldGeometry & | world ) |
Run one tick of swept-AABB collision for all physics entities.
For every entity with [Position, Velocity, CollisionShape, PlayerVisState]:
| registry | The ECS registry. |
| dt | Fixed physics delta time in seconds. |
| world | World collision geometry (planes, boxes, brushes) for this tick. |
|
inline |
Sample skip-respawn input while the local player is dead.
Runs independently of Controllable — dead players can use the Jump binding to skip the remaining respawn timer and respawn immediately.
| registry | The ECS registry. |
| bindings | The configured keyboard/mouse bindings. |
| void systems::runDroppedWeapons | ( | Registry & | registry, |
| float | dt ) |
Tick dropped weapons: handle pickup (overlap-refill or look+F replace) and despawn timer.
| registry | The ECS registry. |
| dt | Fixed physics delta time in seconds. |
| void systems::runDynamics | ( | Registry & | registry, |
| float | dt, | ||
| const physics::WorldGeometry & | world, | ||
| physics::ContactCache & | cache, | ||
| const physics::SolverConfig & | solverCfg, | ||
| const physics::SleepConfig & | sleepCfg ) |
One physics tick for rigid-body dynamic entities.
| registry | ECS registry. |
| dt | Tick duration (typically 1/128 s). |
| world | Active world collision geometry (static). |
| cache | Persistent contact-manifold cache (carried across ticks for warm-starting the solver). |
| solverCfg | Solver tuning parameters (iteration counts, friction). |
| sleepCfg | Sleep thresholds. |
|
inline |
Track the Emote binding (keyboard/mouse) to open/close the wheel.
Must run every iterate() before runMouseLook so the look sampler can divert mouse motion into the wheel. On release, the highlighted sector is latched as the emote to play.
| void systems::runExplosion | ( | Registry & | registry, |
| std::vector< NetParticleEvent > & | outParticles, | ||
| std::vector< NetKillEvent > & | killEvents ) |
Process all pending explosions: apply radial damage and emit particle events.
For each Explosion component, damages every player within the blast radius (damage = maxDamage * pow(1 - d/r, falloffExponent)), emits a ParticleEffectType::Explosion event, and destroys the explosion entity.
| registry | The ECS registry. |
| outParticles | Accumulates particle events for network broadcast. |
| killEvents | Accumulates kill events for network broadcast. |
| void systems::runFireField | ( | Registry & | registry, |
| float | dt, | ||
| std::vector< NetKillEvent > & | killEvents ) |
Tick all FireField entities: decrement remaining, apply DoT damage at fixed sub-intervals (4 Hz), and destroy expired fields.
Self-damage is scaled by 0.4 (matches rocket/grenade self-damage philosophy).
|
inline |
Apply gamepad aim assist (slowdown + movement-tracking pull) to the local player's InputSnapshot.
Must run AFTER runGamepadLook so we can refund part of the player input it just integrated.
| registry | ECS registry. |
| gamepad | Open gamepad handle (nullptr → no-op). |
| cfg | Tuning parameters. |
| state | Persistent per-frame state (anchor + previous-frame snapshot). |
| pitchSensitivity | Pitch radians per second at full stick deflection. |
| yawSensitivity | Yaw radians per second at full stick deflection. |
| lookDeadzone | Look-stick deadzone as a fraction of full deflection. |
| moveDeadzone | Move-stick deadzone as a fraction of full deflection. |
| dt | Frame delta time (seconds). |
| swapSticks | When true, use the swapped stick layout for activation checks. |
|
inline |
Sample controller skip-respawn input while the local player is dead.
| registry | The ECS registry. |
| gamepad | Open gamepad, or nullptr to no-op. |
| bindings | Controller bindings to sample. |
|
inline |
Track the Emote binding (controller) to open/close the wheel and pick a sector from the right stick.
Mirrors runEmoteWheelKey; runs every iterate() before runGamepadLook. ORs into the shared wheel state so a player can use either device. On release the highlighted sector is latched as the emote to play.
|
inline |
Sample the right stick into yaw / pitch.
Must be called every iterate() call — same cadence as runMouseLook — so camera rotation is smooth at any frame rate. Unlike mouse delta (which is integrated over the time between calls), the stick gives an instantaneous angular velocity, so we multiply by frame delta time.
Adds to existing yaw/pitch (so simultaneous mouse + stick compose).
| registry | The ECS registry. |
| gamepad | Open gamepad, or nullptr to no-op. |
| pitchSensitivity | Pitch radians per second at full stick deflection. |
| yawSensitivity | Yaw radians per second at full stick deflection. |
| deadzone | Stick deadzone as a fraction of full deflection. |
| dt | Frame delta time in seconds. |
| gravityFlipped | When true, both axes are inverted for 180° camera roll. |
| swapSticks | When true, use the left stick for look instead of the right stick. |
< Stick deflection needed to start accelerating.
< Seconds at full deflection to reach the max boost.
< Extra turn-rate multiplier at full ramp (1.0 => up to 2x).
|
inline |
Sample gamepad buttons / left stick into the movement flags.
ORs with whatever the keyboard sampler set so kbm + pad coexist. Should run on the same cadence as runMovementKeys (once per physics tick group when synced, otherwise every iterate).
Mapping: Left stick → forward / back / strafe Configured buttons/triggers drive jump, crouch, and abilities.
| registry | The ECS registry. |
| gamepad | Open gamepad, or nullptr to no-op. |
| bindings | Controller bindings to sample. |
| deadzone | Stick deadzone as a fraction of full deflection. |
| gravityFlipped | When true, left/right stick are swapped to match the 180° camera roll. |
| swapSticks | When true, use the right stick for movement instead of the left stick. |
|
inline |
Sample gamepad buttons / right trigger into the weapon flags.
ORs with whatever the keyboard sampler set so kbm + pad coexist.
Mapping: Configured buttons/triggers drive weapon actions.
| registry | The ECS registry. |
| gamepad | Open gamepad, or nullptr to no-op. |
| bindings | Controller bindings to sample. |
| void systems::runHealthPackSpawners | ( | Registry & | registry, |
| float | dt ) |
Tick spawners: check player overlap for pickup, manage cooldowns.
| registry | The ECS registry. |
| dt | Fixed physics delta time in seconds. |
|
inline |
Deserialise a raw InputSnapshot packet into a gameplay Event.
| data | Pointer to the raw InputSnapshot bytes. |
|
inline |
Legacy combined sampler — calls both runMouseLook and runMovementKeys.
| registry | The ECS registry. |
| mouseSensitivity | Radians per pixel. |
Send the local player's current InputSnapshot over the network.
| registry | The ECS registry. |
| conn | Network connection to the server. |
| void systems::runJumpPads | ( | Registry & | registry, |
| float | dt ) |
Tick jump pads: for each pad, any player whose AABB overlaps the pad's trigger volume on the rising edge has the pad's velocity applied as an impulse.
A small per-player cooldown prevents the same player from being relaunched every tick while they're still inside the trigger (the impulse won't have moved them out yet).
| registry | The ECS registry. |
| dt | Fixed physics delta time in seconds. |
| void systems::runKillzones | ( | Registry & | registry, |
| std::vector< NetKillEvent > & | killEvents ) |
Tick killzones: for each killzone trigger, any player whose AABB overlaps it takes lethal damage.
Kill events are appended to killEvents so they're broadcast alongside other kills in the tick.
Killer is set to the player themselves so the kill feed shows the kill as a self-elimination (the world has no entity to credit).
| registry | The ECS registry. |
| killEvents | Network kill events to broadcast this tick. |
| physics::KccFrameResult systems::runKinematicCharacterController | ( | glm::vec3 & | pos, |
| glm::vec3 & | vel, | ||
| const CollisionShape & | shape, | ||
| PlayerVisState & | state, | ||
| float | dt, | ||
| const physics::WorldGeometry & | world, | ||
| entt::entity | entity, | ||
| bool | jumpedThisTick, | ||
| PlayerSimState * | simState = nullptr ) |
Resolve one fixed-tick capsule character-controller step.
MovementSystem owns intent and velocity shaping. This module owns the collision-side KCC work: capsule depenetration, walk-capsule horizontal sweep, ground snap, vertical sweep, final grounded state, and diagnostics.
|
inline |
Sample mouse delta and accumulate into yaw / pitch.
Must be called every iterate() call regardless of whether a physics tick fires — this keeps camera rotation smooth at the render frame rate. SDL_GetRelativeMouseState returns the accumulated delta since the previous call, so the total rotation over any time window is identical regardless of call frequency.
| registry | The ECS registry. |
| mouseSensitivity | Radians per pixel of mouse movement. |
| gravityFlipped | When true, both mouse axes are inverted so controls feel natural while the camera is rolled 180° for upside-down gravity. |
| void systems::runMovement | ( | Registry & | registry, |
| float | dt, | ||
| const physics::WorldGeometry & | world ) |
Apply one tick of player movement physics to all eligible entities.
| registry | The ECS registry. |
| dt | Fixed physics delta time in seconds. |
| world | World collision geometry (needed for wall detection). |
|
inline |
Sample keyboard state into the movement flags.
Should be called once per physics tick group when input is synced with physics (the default) so movement calculations match the server. Can also be called every iterate() when the sync toggle is off.
| registry | The ECS registry. |
| bindings | Keyboard/mouse bindings to sample. |
| gravityFlipped | When true, A/D are swapped so strafing feels correct while the camera is rolled 180°. |
| void systems::runPlayerStatus | ( | Registry & | registry, |
| float | dt ) |
Run one tick of player status: respawn timers and passive healing.
| registry | The ECS registry. |
| dt | Fixed physics delta time in seconds. |
| void systems::runPowerups | ( | Registry & | registry, |
| float | dt ) |
Run one tick of powerup logic for all players.
| registry | The ECS registry. |
| dt | Fixed physics delta time in seconds. |
| void systems::runPowerupSpawners | ( | Registry & | registry, |
| float | dt, | ||
| const MatchConfig & | matchConfig, | ||
| std::vector< NetParticleEvent > & | outEvents ) |
Tick Powerup spawners: check player overlap for pickup, manage cooldowns.
| registry | The ECS registry. |
| dt | Fixed physics delta time in seconds. |
| matchConfig | Current host-managed match settings. |
| outEvents | Server-authored replicated events emitted by pickups. |
|
inline |
Run one tick of client-side prediction for the local player.
Just calls the shared runMovement and runCollision against the local registry. The View filter (PlayerSimState) ensures only the local player is processed on the client. Server's runMovement still processes every player in the same single call.
| registry | The client ECS registry. |
| dt | Fixed physics delta (must match server's dt for prediction parity — typically 1/128 s). |
| world | Active world geometry. Must match the server's world exactly or prediction diverges. |
| void systems::runRagdolls | ( | Registry & | registry, |
| float | dt ) |
Per-tick ragdoll bookkeeping: advance age, optionally tick the cleanup timer for old corpses.
Called from the same tick that runs the constraint solver.
| registry | ECS registry. |
| dt | Tick duration in seconds. |
|
inline |
Replay stored inputs from ackedTick + 1 through currentTick on the local player, restoring its predicted state after a snapshot apply rewrote it to the server-authoritative value.
| registry | The client ECS registry. Local player's Position etc. should be the server's just-applied value. |
| ring | Input history ring; entries from earlier than ackedTick may have been overwritten and are not used. |
| ackedTick | The client tick the server has acknowledged processing through. The local player's current Position represents state as-of this tick. |
| currentTick | The client's current clientPredictTick. Replay runs runMovement+runCollision once per tick from ackedTick + 1 through currentTick (inclusive). |
| dt | Physics delta (match server: 1/128 s). |
| world | World geometry (must match server). |
| void systems::runSpawnPointCooldowns | ( | Registry & | registry, |
| float | dt ) |
Tick spawn point cooldowns.
Each spawn point's cooldown decrements by dt and becomes available again when it reaches zero.
| registry | The ECS registry. |
| dt | Fixed physics delta time in seconds. |
| void systems::runTriggers | ( | Registry & | registry, |
| bool | isPredictedClient = false ) |
Test every trigger-volume entity for overlap with non-trigger entities and emit Enter / Stay / Exit events.
Drops trigger volumes' overlap state when the trigger entity is destroyed.
| registry | ECS registry. |
| isPredictedClient | True when called from the client-side prediction path. Triggers without fireOnPredictedClient do not emit events in this mode (they would double-fire when the server's authoritative state lands). |
| void systems::runWeapon | ( | Registry & | registry, |
| float | dt, | ||
| std::vector< NetParticleEvent > & | outParticles, | ||
| std::vector< NetKillEvent > & | killEvents, | ||
| std::vector< net::shotdebug::ShotDebugCapture > * | outShotDebug = nullptr ) |
Run one tick of weapon logic for all armed entities.
For each entity with [InputSnapshot, Position, CollisionShape, WeaponState]: handles weapon switching, cooldown ticking, fire/beam/charge processing, hitscan raycasting, projectile spawning, damage application, and ammo refill.
| registry | The ECS registry. |
| dt | Fixed physics delta time in seconds. |
| outParticles | Accumulates particle events for network broadcast. |
| killEvents | Accumulates kill events for network broadcast. |
| outShotDebug | PR-20 (server-side only): if non-null, every hitscan shot pushes a ShotDebugCapture row while the rewind guard is still active so the capsule data reflects the historical sample the server actually raycast against. ServerGame serialises and sends each entry to the shooter via Server::enqueueTo. Client TUs leave this null — clients run WeaponSystem for prediction only and don't generate debug reports. |
|
inline |
Sample keyboard state into the weapon flags.
Should be called once per physics tick group when input is synced with physics (the default) so movement calculations match the server. Can also be called every iterate() when the sync toggle is off.
| registry | The ECS registry. |
| bindings | The input bindings. |
| void systems::runWeaponSpawners | ( | Registry & | registry, |
| float | dt ) |
Tick weapon spawners: check player overlap for pickup, manage cooldowns.
| registry | The ECS registry. |
| dt | Fixed physics delta time in seconds. |
|
inline |
| void systems::spawnDroppedWeapon | ( | Registry & | registry, |
| glm::vec3 | pos, | ||
| glm::vec3 | initialVel, | ||
| const GunInstance & | gun, | ||
| float | pickupDelay ) |
Spawn an in-world dropped-weapon pickup carrying a gun's ammo.
Shared by death drops (PlayerStatusSystem) and weapon-swap drops (WeaponSpawnerSystem / DroppedWeaponSystem). The entity gets a compact AABB plus Velocity/RigidBody so it falls under gravity and settles.
| registry | The ECS registry. |
| pos | World position to spawn the drop at. |
| initialVel | Initial velocity (e.g. a gentle toss for swap drops). |
| gun | The gun being dropped; its ammo state is snapshotted. |
| pickupDelay | Pickup-immunity window (s) before the drop can be grabbed. |
| void systems::spawnFireField | ( | Registry & | registry, |
| glm::vec3 | position, | ||
| float | radius, | ||
| float | duration, | ||
| float | dps, | ||
| entt::entity | owner ) |
Spawn a FireField at position that lasts duration seconds and deals dps damage to players inside radius.
owner gets kill credit.
|
static |
Spawn a grenade projectile from the player's eye position.
Computes a throw direction by rotating the eye direction upward by the configured (small) pitch offset, then adds the thrower's velocity so a grenade thrown on the move inherits the player's momentum (Halo-style): moving forward extends the throw, backpedaling shortens it. Copies all flight-relevant fields from the grenade's GrenadeConfig into the new Projectile entity so CollisionSystem can dispatch on them.
| entt::entity systems::spawnRagdoll | ( | Registry & | registry, |
| entt::entity | character ) |
Build a 15-body humanoid ragdoll for the dead character.
The character's existing position / velocity become the seed state for the new bodies. Idempotent: calling twice on the same character is a no-op (the second call sees the Ragdoll component is already present).
|
inline |
|
inline |
|
inline |
Try to grant the dropped weapon to a player.
| pendingDrops | Collects any swap-out gun to re-drop (spawned after iteration to avoid invalidating the active view). |
|
inline |
Placeholder system — replace with real logic.
| registry | The ECS registry. |
| dt | Fixed physics delta time in seconds. |
|
inline |
| void systems::updateHitboxes | ( | Registry & | registry, |
| const HitboxRig & | hitboxRig, | ||
| float | rigScale, | ||
| float | rigMeshMinY ) |
Update world-space hitbox capsules for all entities that have JointMatrices.
For each entity with [Position, JointMatrices] this builds the world transform (entity position + yaw rotation + rig scale + vertical offset) and transforms every HitboxDef capsule into a WorldCapsule stored in HitboxInstance.
| registry | The ECS registry. |
| hitboxRig | Shared hitbox definitions (bone-to-capsule mapping). |
| rigScale | Scale factor applied to the rig (model space -> game units). |
| rigMeshMinY | Minimum Y vertex of the bind-pose mesh (model space). |
|
inline |
|
inline |
Forward direction implied by a player's yaw + pitch.
Compute the player's 3D view direction from yaw and pitch angles.
| yaw | Horizontal angle (radians). |
| pitch | Vertical angle (radians, positive = down). |
| const float systems::armorMax = 100.0f |
Maximum armor value.
|
constexpr |
|
inline |
Accumulated pointing direction used to resolve the highlighted sector.
|
inline |
|
inline |
True while the emote wheel is open (Emote binding held on any device).
|
inline |
Currently highlighted emote sector while the wheel is open, or -1 (none).
|
inline |
COD-style look acceleration progress in [0, 1]; ramps while the look stick is held near full deflection and resets when it eases off.
|
inline |
SDL_GetTicks at the Y press, for hold-duration timing.
|
inline |
Set once the press crossed the hold threshold (suppresses tap-swap).
| const float systems::healCooldown = 5.0f |
Seconds after last damage before passive healing starts.
| const float systems::healingRate = 20.0f |
Passive healing amount per second.
| const float systems::healthMax = 100.0f |
Maximum health value.
|
constexpr |
|
constexpr |
Default lifetime (seconds) for a dropped weapon before it despawns.
|
constexpr |
Half-angle (degrees) of the look cone for press-F pickup.
|
inline |
Pre-computed cosine of the look cone half-angle.
|
constexpr |
Maximum distance (units) at which a player can press F to pick up.
|
staticconstexpr |
|
inlineconstexpr |
Cooldown duration set on a spawn point after a player spawns there.
|
inlineconstexpr |
|
constexpr |
Pickup-immunity applied to a weapon dropped during a swap, so the player can't instantly re-grab the gun they just replaced.
|
inline |
Shared pickup collision half-extents for weapon spawners and dropped weapons.
|
constexpr |
| const float systems::overShieldMax = 200.0f |
|
inline |
Latched emote to play on wheel release; consumed once by the game loop.
|
inline |
Latched tap-Y weapon swap, consumed once per frame by the game loop.
|
inline |
Latched cycle next/prev requests, consumed once per frame by the game loop.
|
inline |
|
inline |
Latched throw request, consumed once per frame by the game loop.
|
inline |
Tracks previous-frame Alt+LMB state for ability choice edge detection.
|
inline |
Tracks previous-frame Alt+RMB state for ability choice edge detection.
|
inline |
Previous-frame Emote-binding state for open/close edge detection.
|
inline |
Tracks previous-frame gamepad left ability-select chord for edge detection.
|
inline |
Tracks previous-frame gamepad right ability-select chord for edge detection.
|
inline |
|
inline |
Gamepad equivalents: CycleGrenade (D-pad Left) / ThrowGrenade (B).
|
inline |
|
inline |
Gamepad Y (Pickup binding) tap-vs-hold state: tap swaps weapon, hold picks up.
|
inline |
Previous-frame CycleGrenade (H) / ThrowGrenade (G) key state for edge detection (keyboard/mouse).
|
inline |
|
inline |
Tracks previous-frame key state for edge detection.
|
constexpr |