|
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... | |
| class | RewindHitboxesGuard |
| RAII handle that restores hitbox capsules on scope exit after a rewindHitboxes call swapped them for historical samples. More... | |
Functions | |
| void | runGamepadAimAssist (Registry ®istry, SDL_Gamepad *gamepad, const GamepadAimAssistConfig &cfg, GamepadAimAssistState &state, float lookSens, float dt) |
| Apply gamepad aim assist (slowdown + movement-tracking pull) to the local player's InputSnapshot. | |
| void | runMouseLook (Registry ®istry, float mouseSensitivity, bool gravityFlipped=false) |
| Sample mouse delta and accumulate into yaw / pitch. | |
| void | runMovementKeys (Registry ®istry, bool gravityFlipped=false) |
| Sample keyboard state into the movement flags. | |
| void | runDeadInput (Registry ®istry) |
| Sample skip-respawn input while the local player is dead. | |
| void | runWeaponKeys (Registry ®istry) |
| Sample keyboard state into the weapon flags. | |
| void | runInputSample (Registry ®istry, float mouseSensitivity=0.001f) |
| Legacy combined sampler — calls both runMouseLook and runMovementKeys. | |
| void | runGamepadLook (Registry ®istry, SDL_Gamepad *gamepad, float lookSensitivity, float dt, bool gravityFlipped=false) |
| Sample the right stick into yaw / pitch. | |
| void | runGamepadMovement (Registry ®istry, SDL_Gamepad *gamepad, bool gravityFlipped=false) |
| Sample gamepad buttons / left stick into the movement flags. | |
| void | runGamepadWeapon (Registry ®istry, SDL_Gamepad *gamepad) |
| Sample gamepad buttons / right trigger into the weapon flags. | |
| 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. | |
| void | 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. | |
| 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 void | depenetrate (glm::vec3 &pos, glm::vec3 &vel, const glm::vec3 &halfExtents, const physics::WorldGeometry &world) |
| Run all depenetration passes (planes, boxes, brushes, cylinders, spheres). | |
| static bool | tryStepUp (glm::vec3 &pos, glm::vec3 &vel, const glm::vec3 &halfExtents, float remainingTime, const physics::WorldGeometry &world) |
| Attempt to step over a low obstacle when a wall is hit. | |
| static void | snapToGround (glm::vec3 &pos, glm::vec3 &vel, const glm::vec3 &halfExtents, const physics::WorldGeometry &world) |
| Keep the entity glued to descending slopes and step-downs. | |
| void | runCollision (Registry ®istry, float dt, const physics::WorldGeometry &world) |
| Run one tick of swept-AABB collision for all physics entities. | |
| void | queueExplosion (Registry ®istry, glm::vec3 position, float radius, float maxDamage, entt::entity owner) |
| 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 | updateHitboxes (Registry ®istry, const HitboxRig &hitboxRig, float rigScale, float rigMeshMinY) |
| Update world-space hitbox capsules for all entities that have JointMatrices. | |
| RewindHitboxesGuard | rewindHitboxes (Registry ®istry, entt::entity shooter, const glm::vec3 *rayOrigin=nullptr, const glm::vec3 *rayDirection=nullptr, float rayMaxDistance=0.0f) |
| Rewind every other player's hitbox capsules to where they were on shooter's screen at fire time. | |
| bool | 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 | runMovement (Registry ®istry, float dt, const physics::WorldGeometry &world) |
| Apply one tick of player movement physics to all eligible entities. | |
| void | applyHeal (float amount, Health &playerHealth) |
| glm::vec3 | chooseRespawnPoint (Registry ®istry) |
| Choose a respawn point with cooldown-aware selection. | |
| 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 | applyDamage (float damage, entt::entity player, entt::entity &killer, Registry ®istry, std::vector< NetKillEvent > &killEvents, BodyRegion hitRegion=BodyRegion::UpperTorso) |
| 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. | |
| void | update (Registry ®istry, float dt) |
| Placeholder system — replace with real logic. | |
| 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) |
| Compute the player's 3D view direction from yaw and pitch angles. | |
| void | checkForPlayers (Registry ®istry, Position spawnerPos, CollisionShape spawnerShape, WeaponSpawner &spawner) |
| 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. | |
| GunInstance & | getEquippedGun (WeaponState &weapon) |
| Return the GunInstance for the currently selected weapon slot. | |
| 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 | 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) |
| void | handleFire (Registry ®istry, entt::entity shooter, const InputSnapshot &input, const Position &pos, const CollisionShape &shape, WeaponState &weapon, bool gravityFlipped, 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 | prevFlipGravityKey = false |
| Tracks previous-frame G key state for gravity flip edge detection. | |
| static constexpr float | k_pushback = 0.03125f |
| static constexpr float | k_groundProbeDistance = physics::k_stepHeight |
| constexpr float | k_spawnPointCooldown = 5.0f |
| Cooldown duration set on a spawn point after a player spawns there. | |
| const float | armorMax = 100.0f |
| Maximum armor value. | |
| const float | healthMax = 100.0f |
| Maximum health value. | |
| 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.
Player status update system.
Shared movement system — compiled identically on client and server.
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 full Titanfall-inspired movement state machine: OnFoot → Sliding → WallRunning → Climbing → LedgeGrabbing 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.
| void systems::applyDamage | ( | float | damage, |
| entt::entity | player, | ||
| entt::entity & | killer, | ||
| Registry & | registry, | ||
| std::vector< NetKillEvent > & | killEvents, | ||
| BodyRegion | hitRegion = BodyRegion::UpperTorso ) |
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). |
| 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). |
|
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 (weapon type, availability, cooldown). |
|
inline |
Choose a respawn point with cooldown-aware selection.
Prefers available (cooldown = 0) spawn points, picking randomly among them. If all spawn points are on cooldown, picks the one with the lowest remaining cooldown. Sets a 3-second cooldown on the chosen point.
| 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_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). |
|
static |
Run all depenetration passes (planes, boxes, brushes, cylinders, spheres).
| 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, which uses per-triangle SAT MTV — accurate enough that curved surfaces (cylinders, spheres) feel curved instead of cubical. Trade-off: at sharp triangle edges where adjacent normals fight, per-triangle pushes can briefly disagree. In practice the pushback bias keeps the entity off the surface and the swept collision (which still does precise per-triangle hits) is the primary path for normal motion; this depenetration is only a safety net.
|
inline |
Return the GunInstance for the currently selected weapon slot.
| weapon | Weapon state to query. |
|
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 |
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. |
| 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). |
| bool systems::handleWinCondition | ( | Registry & | registry, |
| int | killsToWin ) |
Checks if any player has met win condition and updates their PlayerMatchStats accordingly.
|
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 |
Test whether two axis-aligned bounding boxes overlap.
| aPos | Center of box A. |
| aHalf | Half-extents of box A. |
| bPos | Center of box B. |
| bHalf | Half-extents of box B. |
| 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. |
| void systems::queueExplosion | ( | Registry & | registry, |
| glm::vec3 | position, | ||
| float | radius, | ||
| float | maxDamage, | ||
| entt::entity | owner ) |
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 linearly to zero at edge). |
| maxDamage | Maximum damage at the epicenter. |
| owner | Entity that caused the explosion (for self-damage / kill credit). |
| void systems::resetStats | ( | Registry & | registry | ) |
Resets all players' match scores to initial values.
|
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::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 press Space to skip the remaining respawn timer and respawn immediately.
| registry | The ECS registry. |
| 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 (linear falloff), 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. |
|
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). |
| lookSens | Same value passed to runGamepadLook (rad/s @ full deflection). |
| dt | Frame delta time (seconds). |
|
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. |
| lookSensitivity | Radians per second at full stick deflection. |
| dt | Frame delta time in seconds. |
| gravityFlipped | When true, both axes are inverted for 180° camera roll. |
|
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 A (south) → jump B (east) → crouch L3 (LS click) → sprint LT → grapple (analog, threshold @ 0.5)
| registry | The ECS registry. |
| gamepad | Open gamepad, or nullptr to no-op. |
| gravityFlipped | When true, left/right stick are swapped to match the 180° camera roll. |
|
inline |
Sample gamepad buttons / right trigger into the weapon flags.
ORs with whatever the keyboard sampler set so kbm + pad coexist.
Mapping: RT → shoot (analog, threshold @ 0.5) X (west) → reload Y (north) → pickup LB → switchToPrimary D-pad up → switchToPrimary (alt) RB → switchToSecondary D-pad down → switchToSecondary (alt)
| registry | The ECS registry. |
| gamepad | Open gamepad, or nullptr to no-op. |
|
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 (default 0.001). |
Send the local player's current InputSnapshot over the network.
| registry | The ECS registry. |
| conn | Network connection to the server. |
|
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/climb/ledge 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. |
| 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. |
|
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. |
|
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::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. |
| 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. |
|
static |
Keep the entity glued to descending slopes and step-downs.
| pos | Entity position (modified in place). |
| vel | Entity velocity (modified in place). |
| halfExtents | AABB half-extents of the entity. |
| world | World collision geometry. |
|
static |
Attempt to step over a low obstacle when a wall is hit.
| pos | Entity position (modified in place on success). |
| vel | Entity velocity (modified in place on success). |
| halfExtents | AABB half-extents of the entity. |
| remainingTime | Time remaining in the current bump iteration. |
| world | World collision geometry. |
|
inline |
Placeholder system — replace with real logic.
| registry | The ECS registry. |
| dt | Fixed physics delta time in seconds. |
| 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 |
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.
| 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.
|
staticconstexpr |
|
staticconstexpr |
|
inlineconstexpr |
Cooldown duration set on a spawn point after a player spawns there.
|
inline |
Tracks previous-frame G key state for gravity flip edge detection.
|
inline |
Tracks previous-frame key state for edge detection.
|
constexpr |