group2 0.1.0
CSE 125 Group 2
Loading...
Searching...
No Matches
Game.hpp
Go to the documentation of this file.
1
3
4#pragma once
5
6#include "IScreen.hpp"
11#include "app/AppContext.hpp"
13#include "debug/DebugUI.hpp"
15#include "ecs/AssetRegistry.hpp"
26#include "hud/Hud.hpp"
28#include "network/Client.hpp"
33#include "sfx/SfxSystem.hpp"
37#include "util/WorkerPool.hpp"
39
40#include <SDL3/SDL.h>
41
42#include <array>
43#include <cstdint>
44#include <deque>
45#include <entt/entt.hpp>
46#include <glm/glm.hpp>
47#include <memory>
48#include <optional>
49#include <string>
50#include <string_view>
51#include <unordered_map>
52#include <vector>
53
58class Game : public IScreen
59{
60public:
62 bool initDebugUI(const AppContext& ctx);
63
66 bool init(AppContext& ctx);
67
71 SDL_AppResult event(SDL_Event* event) override;
72
106 SDL_AppResult iterate() override;
107
109 bool shouldReturnToLobby() const;
110
113
115 void quit() override;
116
118 void shutdownAfterRenderer() override;
119
122
125
128
131
134
135private:
139 std::uint32_t snapshotTick, const std::uint8_t* bytes, Uint32 size, Uint64 captureNs, std::uint32_t& ackedTick);
141 void handleLocalPlayerReady(entt::entity local);
142
154
156 {
157 bool skip = false;
158 bool missingHistory = false;
159 float positionError = 0.0f;
160 float velocityError = 0.0f;
161 };
162
163 void clearPredictedStateHistory() noexcept;
164 void storePredictedPlayerState(std::uint32_t tick);
165 [[nodiscard]] std::optional<PredictedPlayerState> captureLocalPredictedState() const;
166 [[nodiscard]] const PredictedPlayerState* predictedStateForTick(std::uint32_t tick) const noexcept;
168 [[nodiscard]] ReconciliationDecision
170 const PredictedPlayerState* predictedAtAck,
171 const std::optional<PredictedPlayerState>& currentBeforeSnapshot) const noexcept;
172
174 void openChat();
175
177 void closeChat();
178
180 void submitChat();
181
183 void appendChatMessage(ClientId sender, std::string_view message);
184
186 void appendLocalChatMessage(std::string_view message);
187
190
191 static constexpr int k_physicsHz = 128;
192 static constexpr float k_physicsDt = 1.0f / static_cast<float>(k_physicsHz);
201 static constexpr int k_maxTicksPerFrame = 2;
202 static constexpr int k_fpsHistorySize = 512;
203
204 SDL_Window* window = nullptr;
208 Client* client = nullptr;
210 std::string_view userSettingsPath_;
212 std::optional<entt::entity>
219
220 Uint64 prevTime = 0;
221 float accumulator = 0.0f;
222 int tickCount = 0;
230 uint32_t clientPredictTick = 0;
231
241
247
249 bool mouseCaptured = true;
250
259 SDL_Gamepad* activeGamepad_ = nullptr;
263 SDL_JoystickID activeGamepadId_ = 0;
269
277
283
291 std::unique_ptr<WorkerPool> workerPool_;
292
293 // Runtime-tunable loop settings (exposed via ImGui)
294 float mouseSensitivity = 0.0007f;
295 float horizontalFovDegrees = 90.0f;
300 bool limitFPSToMonitor = true;
301
302 Uint64 softLimitPeriod = 0;
304
308 void applyFrameRateLimit();
309
311 uint64_t frameCount = 0;
312
313 // Cached camera state — updated each iterate(), used by event() key shortcuts.
314 glm::vec3 cachedEye_{0.f, 100.f, 0.f};
315 glm::vec3 cachedCamFwd_{0.f, 0.f, 1.f};
316 bool cachedGravFlipped_{false};
317 float currentCameraRoll_{0.0f};
318
319 // Map collision data — loaded from GLB, owns the vectors that back activeWorld().
321
322 // Central asset registry — maps human-readable names to renderer model indices.
324
325 // Legacy model index aliases (for code that still uses raw indices).
326 // TODO: migrate all call sites to assets_.modelIndex("name") and remove these.
327 int weaponModelIndices_[4] = {-1, -1, -1, -1};
328 int weaponAssetIds_[4] = {-1, -1, -1, -1};
329
331
332 // Dynamic lighting test controls (ImGui-tunable)
333 bool showDynLightUI_ = false;
334 bool showHudDebug_ = false;
335 bool flashlightEnabled_ = false;
336 float flashlightIntensity_ = 8.0f;
337 float flashlightRange_ = 800.0f;
338 float flashlightOffset_ = 30.0f;
340 float sphereFollowDist_ = 150.0f;
341 float sphereIntensity_ = 5.0f;
342 float sphereRange_ = 500.0f;
343 bool beamEnabled_ = false;
344 glm::vec3 beamStartOff_{30.0f, -5.0f, 10.0f};
345 glm::vec3 beamEndOff_{200.0f, -5.0f, 10.0f};
346 float beamRadius_ = 3.0f;
347 glm::vec3 beamColor_{0.6f, 0.1f, 1.0f};
348 float beamLightIntensity_ = 4.0f;
349 float beamLightRange_ = 300.0f;
350 float beamLightSpacing_ = 60.0f;
354
355 // Sound state tracking
356 bool wasChargingRailgun_ = false;
357 bool wasBeamActive_ = false;
359 std::unordered_map<entt::entity, std::array<float, 5>> footstepPhases_;
360 std::unordered_map<entt::entity, float> footstepCooldowns_;
361
362 // Movement / ability transition tracking for SFX.
364 {
365 bool initialized = false;
366 bool grounded = false;
367 bool isDead = false;
368 int moveMode = 0;
369 bool gravityFlipped = false;
370 bool grappleActive = false;
371 float primaryCooldown = 0.0f;
372 float secondaryCooldown = 0.0f;
374 };
375 std::unordered_map<entt::entity, PlayerSfxState> playerSfxState_;
376
377 // Hitmarker
378 float hitmarkerTimer_ = 0.0f;
379 bool hitmarkerIsHeadshot_ = false;
381
382 // Floating damage numbers — queued from replicated particle events, consumed by HUD each frame.
384 {
385 glm::vec3 pos;
386 float damage;
389 };
390 std::vector<PendingDamageNumber> pendingDamageNumbers_;
391
392 // Damage accumulator — tracks continuous damage to a single target.
393 entt::entity accumTarget_ = entt::null;
394 int accumTotal_ = 0;
395 float accumResetTimer_ = 0.f;
396 uint8_t accumLastHitType_ = 0;
397
398 // Vignette state: track previous frame health/armor for delta detection.
399 float prevHealth_ = 100.f;
400 float prevArmor_ = 100.f;
401
402 // ── Voidfall HUD bookkeeping ────────────────────────────────────────
407
414
418 std::vector<HudPickupNotification> pendingPickupNotifications_;
419 std::vector<HudChatMessage> chatMessages_;
420 std::vector<HudVoiceSpeaker> voiceSpeakers_;
421 std::string chatDraft_;
422 std::deque<std::string> pendingLocalChatEchoes_;
423 bool chatOpen_ = false;
424
425 // (No additional bookkeeping needed — name strings are constructed
426 // each frame into the thread_local vector inside Game.cpp.)
427
428 // Viewmodel tuning (live-adjustable via ImGui)
429 float vmScale = 1.0f;
430 float vmForward = 0.0f;
431 float vmRight = 0.0f;
432 float vmDown = 0.0f;
433 float vmYawOffset = 0.0f;
434 float vmPitchOffset = 0.0f;
435 float vmRollOffset = 0.0f;
436 bool showViewmodelUI = false;
437
438 // Weapon sway state (CoD-style barrel lead)
439 float prevSwayYaw_ = 0.0f;
440 float prevSwayPitch_ = 0.0f;
441 float swayOffsetX_ = 0.0f;
442 float swayOffsetY_ = 0.0f;
443 bool swayInitialized_ = false;
444
445 // Sway tuning (ImGui-adjustable)
446 float swayAmplitudeYaw_ = 3.0f;
448 float swayDecayRate_ = 8.0f;
449 float swaySmoothing_ = 0.15f;
450
451 // Visual recoil state (viewmodel-only, does not affect aim)
452 float recoilPitch_ = 0.0f;
453 float recoilPushBack_ = 0.0f;
454 float recoilRoll_ = 0.0f;
455
456 // Local weapon fire cooldown (mirrors server's per-weapon cooldown for VFX)
457 float localFireCooldown_ = 0.0f;
458
460
461 // Third-person weapon tuning (per weapon type, live-adjustable via ImGui)
464 bool showTPWeaponUI_ = false;
465
466 // Weapon spawner model tuning (per weapon type, live-adjustable via ImGui)
470
471 // Animation subsystem — shared rig + clip library + skinning backend.
472 // CharacterAnimators (one per animated entity) hold non-owning refs.
478 float kRigScale_ = 1.0f;
480 -90.0f;
481 float rigMeshMinY_ = 0.0f;
482
483 // FPS ring buffer -- inter-render deltas, newest at (head-1) % size
487 Uint64 prevRenderTime = 0;
488
489 // Network ping timer
490 float pingTimer = 0.0f;
491
492 // Performance stats -- refreshed every 0.5 s
493 Uint64 statsPrevTime = 0;
495 float measuredPhysicsHz = 0.0f;
496 float statsFPSCurrent = 0.0f;
497 float statsFPSMin = 0.0f;
498 float statsFPSMax = 0.0f;
499 float statsFPS1pLow = 0.0f;
500 float statsFPS5pLow = 0.0f;
501
502 // Benchmark mode: when BENCH_SECONDS env var is set to a positive number,
503 // the client runs for that many seconds, prints a one-line FPS summary to
504 // stderr, then quits. Powers `scripts/perf-100bots.sh`.
505 float benchSeconds_ = 0.0f;
506 Uint64 benchStartTime_ = 0;
507 bool benchActive_ = false;
508 static constexpr float k_benchWarmupSeconds = 2.0f;
509 std::vector<float> benchFrameTimesMs_;
510
513 std::vector<ClientPerfFrame> benchFrameStats_;
516 std::uint32_t perfSnapshotApplyCount_ = 0;
517
524 void attachAnimatedCharacter(entt::entity e);
525
526 // Match State
528 float countdownTimer = 0.0f;
531
532 // Kill Feed State
533 std::vector<KillFeedEvent> killFeed;
534
536
537 // Bullet tracer muzzle
538 glm::vec3 cachedMuzzleWorld_{0.0f};
539 bool cachedMuzzleValid_ = false;
540};
Catalog of ozz animation clips shared across all animated entities.
ImGui panel for driving the animation state machine in development.
Borrowed dependencies shared by client screens.
Central registry mapping named assets to renderer model indices.
Shared skinned-character rig: skeleton, bind-pose mesh, skin weights.
Low-overhead client frame profiler that records play sessions to CSV.
TCP client for connecting to the game server.
Live ECS inspector overlay and debug windows powered by Dear ImGui.
Per-frame state recorder for diagnosing camera jitter and position glitches.
AAA-style controller aim assist — applied after runGamepadLook.
Skeleton-driven hitbox types: body regions, capsule definitions, damage profiles, and per-entity runt...
Top-level HUD system — owns widgets, renderer, context, tweens.
Abstract interface for top-level application screens (lobby, in-game).
Per-tick history of stamped input snapshots, keyed by clientPredictTick.
Per-tick player input snapshot for networking and prediction.
Load collision geometry (and optionally visual data) from a map GLB file.
Shared definitions for match status and state synchronization between server and clients.
MatchPhase
Definition MatchStatus.hpp:6
@ LOBBY
Pre-match lobby phase; players are not yet spawned in-world.
Definition MatchStatus.hpp:7
Work-in-progress SDL3 GPU renderer.
Top-level particle system orchestrator owning all effect sub-systems.
Server-only locomotion bookkeeping (timers, blacklists, lurch state).
Visible / replicated half of the player locomotion state.
World-space position component for ECS entities.
Previous-tick position component for render interpolation.
Serialize and deserialize the entt ECS registry for network replication.
Shared ECS registry type alias for the game engine.
entt::registry Registry
Shared ECS registry type alias.
Definition Registry.hpp:11
Client-side sound effects system.
Pluggable skinning interface — phase-1 CPU LBS; GPU backend slots in later.
Linear velocity component for ECS entities.
Per-weapon viewmodel, third-person, and recoil tuning parameters (header-only).
Client-side push-to-talk voice capture, decode, jitter, and spatial playback.
WeaponType
Weapon type — determines tracer style, damage, sound, and impact effects.
Definition WeaponState.hpp:12
@ Rifle
Fast hitscan/projectile (R301-style capsule tracer).
Definition WeaponState.hpp:13
Tiny persistent thread pool for parallel-for over short job ranges.
Collection of animation clips loaded on top of a shared skeleton.
Definition AnimationLibrary.hpp:55
Central asset registry — maps names to renderer model indices.
Definition AssetRegistry.hpp:50
Shared skinned rig — skeleton + bind-pose meshes + joint map.
Definition CharacterRig.hpp:41
Session recorder enabled by GROUP2_CLIENT_PERF=1.
Definition ClientPerfRecorder.hpp:177
TCP stream client — sends input to the server and receives state updates.
Definition Client.hpp:65
CPU Linear Blend Skinning — pure function; no state between calls.
Definition SkinningBackend.hpp:37
Forward-declared to avoid pulling in heavy particle headers.
Definition DebugUI.hpp:44
Records per-frame state to a timestamped directory on disk.
Definition FrameRecorder.hpp:56
Top-level client game object.
Definition Game.hpp:59
bool initDebugUI(const AppContext &ctx)
Create the Game-owned ImGui context before App initialises the renderer backend.
Definition Game.cpp:363
void clearPredictedStateHistory() noexcept
Definition Game.cpp:392
void quit() override
Shut down all subsystems in reverse-init order.
Definition Game.cpp:4699
std::vector< HudVoiceSpeaker > voiceSpeakers_
Definition Game.hpp:420
float vmScale
Weapon model scale (model is in mm).
Definition Game.hpp:429
entt::dispatcher dispatcher
Event bus for weapon/impact/explosion events.
Definition Game.hpp:218
WeaponType currentEquippedType_
Cached each frame.
Definition Game.hpp:351
systems::GamepadAimAssistState aimAssistState_
Persistent inter-frame state for aim assist (anchor on target AABB + previous-frame snapshot used to ...
Definition Game.hpp:282
float swayOffsetY_
Current vertical sway (up axis).
Definition Game.hpp:442
bool wasChargingRailgun_
True last frame if local player was charging RailGun.
Definition Game.hpp:356
std::optional< PredictedPlayerState > captureLocalPredictedState() const
Definition Game.cpp:398
SfxSystem sfxSystem
Client-side sound effects system.
Definition Game.hpp:215
float fpsHistory[k_fpsHistorySize]
Circular buffer of per-frame FPS samples.
Definition Game.hpp:484
float gamepadLookSensitivity
Right-stick look speed in radians per second at full deflection.
Definition Game.hpp:268
std::vector< ClientPerfFrame > benchFrameStats_
Per-frame phase-time breakdown.
Definition Game.hpp:513
float sphereFollowDist_
Distance ahead of player.
Definition Game.hpp:340
std::unordered_map< entt::entity, std::array< float, 5 > > footstepPhases_
Definition Game.hpp:359
bool renderSeparateFromPhysics
Render every iterate() with interpolation (true) vs only after a physics tick (false).
Definition Game.hpp:296
bool chatOpen_
Definition Game.hpp:423
CharacterRig charRig_
Shared skinned rig (skeleton + bind pose + weights).
Definition Game.hpp:473
void refreshRemoteProjectileRenderables()
Assign Renderable components to newly spawned projectile entities.
Definition Game.cpp:4794
int accumTotal_
Running damage total.
Definition Game.hpp:394
Uint64 prevTime
SDL performance counter at the last iterate() call.
Definition Game.hpp:220
InputRingBuffer inputRing_
Phase 5b: ring buffer of recent stamped inputs for replay- based reconciliation.
Definition Game.hpp:246
glm::vec3 cachedCamFwd_
Definition Game.hpp:315
UserSettings * userSettings
Borrowed user settings owned by App.
Definition Game.hpp:209
AnimationTesterState animUI_
Persistent state for the Animation Tester panel.
Definition Game.hpp:476
SDL_Gamepad * activeGamepad_
Currently-bound gamepad, or nullptr if none is plugged in.
Definition Game.hpp:259
void submitChat()
Send the current chat draft to the server and close the chat box.
Definition Game.cpp:1115
float benchSeconds_
Bench duration in seconds (0 = disabled).
Definition Game.hpp:505
void appendLocalChatMessage(std::string_view message)
Queue a locally-authored chat echo while waiting for server replication.
Definition Game.cpp:1156
void restoreLocalPredictedState(const PredictedPlayerState &state)
Definition Game.cpp:447
float hitmarkerTimer_
Remaining display time (fades out over this).
Definition Game.hpp:378
SDL_AppResult event(SDL_Event *event) override
Forward an SDL event to ImGui and handle application-level keys.
Definition Game.cpp:1212
Hud hud_
In-game HUD overlay system.
Definition Game.hpp:217
float swayAmplitudeYaw_
Definition Game.hpp:446
uint32_t clientPredictTick
Monotonic per-tick counter stamped onto outgoing InputSnapshots.
Definition Game.hpp:230
Uint64 softLimitNextFrame
Performance counter target for next frame deadline.
Definition Game.hpp:303
float flashlightRange_
Flashlight attenuation range.
Definition Game.hpp:337
float vmYawOffset
Extra yaw (degrees) applied to the model before camera orient.
Definition Game.hpp:433
std::vector< float > benchFrameTimesMs_
Per-frame ms after warmup; reservation in init().
Definition Game.hpp:509
HitboxRig clientHitboxRig_
Hitbox definitions for client-side debug visualization.
Definition Game.hpp:477
float measuredPhysicsHz
Computed physics rate (Hz).
Definition Game.hpp:495
int rocketProjectileModelIdx_
Definition Game.hpp:330
SfxSystem::SourceHandle beamLoopHandle_
Definition Game.hpp:358
bool beamEnabled_
Show the bloom beam.
Definition Game.hpp:343
std::vector< PendingDamageNumber > pendingDamageNumbers_
Definition Game.hpp:390
void openChat()
Enter chat input mode and release normal gameplay input capture.
Definition Game.cpp:1095
bool consumeReturnToMainMenu()
True if the user requested leaving the match for the main menu, then clear that request.
Definition Game.cpp:4690
Uint64 statsPrevTime
Perf counter at the last stats snapshot.
Definition Game.hpp:493
bool inputSyncedWithPhysics
Sample mouse once per physics tick (true) vs every iterate() call (false).
Definition Game.hpp:298
VoiceChatSystem voiceChat_
Push-to-talk Opus proximity voice chat.
Definition Game.hpp:216
bool returnToLobbyRequested
Latched true when server sends MATCH_STATE with phase == LOBBY.
Definition Game.hpp:529
static constexpr float k_benchWarmupSeconds
Skip the first N seconds (pipeline warmup).
Definition Game.hpp:508
SDL_JoystickID activeGamepadId_
SDL_JoystickID of the active gamepad — needed to identify the device on SDL_EVENT_GAMEPAD_REMOVED so ...
Definition Game.hpp:263
bool flashlightEnabled_
Point light at camera position.
Definition Game.hpp:335
bool benchActive_
True after BENCH_SECONDS read at init.
Definition Game.hpp:507
float swayAmplitudePitch_
Definition Game.hpp:447
glm::vec3 beamStartOff_
Beam start offset (fwd, up, right) from eye.
Definition Game.hpp:344
float statsFPSCurrent
Most-recent render FPS sample.
Definition Game.hpp:496
std::vector< KillFeedEvent > killFeed
Recent kill events for on-screen kill feed (newest first).
Definition Game.hpp:533
Registry registry
The shared ECS registry.
Definition Game.hpp:207
ReconciliationDecision evaluateReconciliationSkip(const PredictedPlayerState &authoritative, const PredictedPlayerState *predictedAtAck, const std::optional< PredictedPlayerState > &currentBeforeSnapshot) const noexcept
Definition Game.cpp:464
glm::vec3 beamEndOff_
Beam end offset (fwd, up, right) from eye.
Definition Game.hpp:345
float sphereIntensity_
Point light intensity of movable sphere.
Definition Game.hpp:341
float vmDown
Downward offset from eye.
Definition Game.hpp:432
bool showViewmodelUI
Show the Viewmodel Tweaker window.
Definition Game.hpp:436
void storePredictedPlayerState(std::uint32_t tick)
Definition Game.cpp:428
const PredictedPlayerState * predictedStateForTick(std::uint32_t tick) const noexcept
Definition Game.cpp:438
float statsFPSMax
Maximum FPS in the ring buffer.
Definition Game.hpp:498
glm::vec3 cachedMuzzleWorld_
Definition Game.hpp:538
std::string_view userSettingsPath_
Borrowed save path for user settings.
Definition Game.hpp:210
std::unique_ptr< WorkerPool > workerPool_
Persistent thread pool for parallel-for over per-frame loops (currently the animation update; future:...
Definition Game.hpp:291
float currentCameraRoll_
Smoothed camera roll angle (radians).
Definition Game.hpp:317
WeaponSpawnerModelParams spawnerWeaponParams_[4]
Runtime-tunable copy; initialised from spawner defaults.
Definition Game.hpp:467
bool showDynLightUI_
Show the Dynamic Lighting panel.
Definition Game.hpp:333
bool cachedGravFlipped_
Local player gravity-flip state, updated each iterate().
Definition Game.hpp:316
static constexpr int k_maxTicksPerFrame
Spiral-of-death guard: max physics ticks per iterate().
Definition Game.hpp:201
float flashlightIntensity_
Flashlight brightness.
Definition Game.hpp:336
float vmRight
Right offset from eye.
Definition Game.hpp:431
ParticleSystem particleSystem
Client-side VFX particle system.
Definition Game.hpp:214
glm::vec3 cachedEye_
Definition Game.hpp:314
float mouseSensitivity
Radians per pixel of mouse movement.
Definition Game.hpp:294
float prevSwayYaw_
Definition Game.hpp:439
bool showTPWeaponUI_
Show the 3P Weapon Tweaker window.
Definition Game.hpp:464
systems::GamepadAimAssistConfig aimAssistCfg_
AAA-style gamepad aim assist tuning.
Definition Game.hpp:276
void appendChatMessage(ClientId sender, std::string_view message)
Queue a replicated chat message for HUD display.
Definition Game.cpp:1128
float matchElapsedSeconds_
Time accumulated while the match is in PLAYING phase (s).
Definition Game.hpp:406
static constexpr int k_physicsHz
Target physics tick rate.
Definition Game.hpp:191
int fpsHistoryHead
Next write index.
Definition Game.hpp:485
float beamRadius_
Beam cylinder radius.
Definition Game.hpp:346
float flashlightOffset_
Forward offset from eye.
Definition Game.hpp:338
float prevArmor_
Definition Game.hpp:400
FrameRecorder recorder
R-key toggled frame-state + screenshot recorder.
Definition Game.hpp:310
bool prevShootingForDebug_
PR-20: tracks last frame's input.shooting so the fire-rising-edge detector inside iterate() only capt...
Definition Game.hpp:240
float swaySmoothing_
Input smoothing (0..1, lower = smoother).
Definition Game.hpp:449
float vmPitchOffset
Extra pitch (degrees).
Definition Game.hpp:434
int weaponAssetIds_[4]
Definition Game.hpp:328
std::unordered_map< entt::entity, PlayerSfxState > playerSfxState_
Definition Game.hpp:375
void clearGameplayInputForChat()
Clear held gameplay actions so typing chat cannot leak into movement or weapons.
Definition Game.cpp:1171
float swayOffsetX_
Current horizontal sway (right axis, Quake units).
Definition Game.hpp:441
AnimationLibrary animLibrary_
Collection of ozz clips on the shared rig.
Definition Game.hpp:474
Uint64 benchStartTime_
Perf counter at first iterate() in bench mode.
Definition Game.hpp:506
float kRigVerticalOffset_
Per-renderable Y translation for animated characters (auto-calculated, tunable).
Definition Game.hpp:479
ClientPerfRecorder perfRecorder_
Definition Game.hpp:514
float perfSnapshotApplyMs_
Definition Game.hpp:515
bool showWeaponSpawnerModelUI_
Show the Weapon Spawner Model Tweaker window.
Definition Game.hpp:469
WeaponType lastEquippedType_
Previous frame's weapon — triggers default reload on change.
Definition Game.hpp:352
int prevAmmoReserve_
Drives "+N <weapon> AMMO" reserve-grow notifications.
Definition Game.hpp:413
static constexpr int k_fpsHistorySize
Samples in the rolling FPS ring buffer.
Definition Game.hpp:202
bool movableSphereEnabled_
Glow sphere following the player.
Definition Game.hpp:339
bool wasBeamActive_
True last frame if local player's beam was active.
Definition Game.hpp:357
std::deque< std::string > pendingLocalChatEchoes_
Definition Game.hpp:422
std::vector< HudPickupNotification > pendingPickupNotifications_
Pickup notifications queued for the next HUD frame.
Definition Game.hpp:418
void shutdownAfterRenderer() override
Destroy the Game-owned ImGui context after App shuts down the renderer backend.
Definition Game.cpp:4729
std::optional< entt::entity > mappedLocalPlayerEntity_
Local-registry entity for this client's player, once assigned.
Definition Game.hpp:213
float vmForward
Forward offset from eye (Quake units).
Definition Game.hpp:430
float kRigScale_
Per-renderable scale for animated characters (auto-calculated, tunable).
Definition Game.hpp:478
bool cachedMuzzleValid_
Definition Game.hpp:539
float vmRollOffset
Extra roll (degrees).
Definition Game.hpp:435
Uint64 softLimitPeriod
Target frame period in perf-counter ticks (0 = disabled).
Definition Game.hpp:302
void refreshRemotePlayerRenderables()
Update Renderable components for remote players (model, scale, orientation from animation rig).
Definition Game.cpp:4739
int statsPhysTicks
Physics ticks accumulated since last snapshot.
Definition Game.hpp:494
float accumResetTimer_
Timer to reset accumulator after inactivity.
Definition Game.hpp:395
int tpTuneWeaponIdx_
Which weapon type is being tuned.
Definition Game.hpp:463
std::uint32_t perfSnapshotApplyCount_
Definition Game.hpp:516
bool mouseCaptured
True when relative mouse mode is active.
Definition Game.hpp:249
MatchPhase currentMatchPhase
Latest match phase update from the server.
Definition Game.hpp:527
bool shouldReturnToLobby() const
True once the server has returned the match phase to the lobby.
Definition Game.cpp:4685
int fpsHistoryCount
Valid sample count (saturates at k_fpsHistorySize).
Definition Game.hpp:486
std::string chatDraft_
Definition Game.hpp:421
void applyFrameRateLimit()
Apply FPS-limit strategy based on limitFPSToMonitor, monitor Hz, and physics Hz.
Definition Game.cpp:1492
bool viewmodelDefaultsApplied_
Definition Game.hpp:353
float horizontalFovDegrees
Player-facing horizontal camera field of view in degrees.
Definition Game.hpp:295
AssetRegistry assets_
Definition Game.hpp:323
physics::MapCollisionData mapCollision_
Definition Game.hpp:320
int prevPrimaryWeaponType_
Last-frame snapshot of the local player's weapon-slot types (-1 = empty).
Definition Game.hpp:411
float recoilPitch_
Current recoil pitch offset (degrees).
Definition Game.hpp:452
NewRenderer * renderer
Borrowed renderer owned by App.
Definition Game.hpp:206
void refreshRemotePowerupRenderables()
Assign or update Renderable components for replicated powerup entities.
Definition Game.cpp:4845
bool swayInitialized_
Guard against initial delta spike.
Definition Game.hpp:443
std::array< PredictedPlayerState, InputRingBuffer::k_capacity > predictedStateHistory_
Definition Game.hpp:248
int prevSecondaryWeaponType_
Definition Game.hpp:412
static constexpr float k_physicsDt
Seconds per tick.
Definition Game.hpp:192
std::optional< registry_serialization::Loader > snapshotLoader_
Incremental loader; created on first snapshot.
Definition Game.hpp:211
float recoilRoll_
Current recoil roll offset (degrees).
Definition Game.hpp:454
float pingTimer
Accumulator for periodic PING sends.
Definition Game.hpp:490
int spawnerTuneWeaponIdx_
Which weapon type is being tuned.
Definition Game.hpp:468
float prevHealth_
Definition Game.hpp:399
bool hitmarkerIsHeadshot_
True when the current hitmarker was a headshot.
Definition Game.hpp:379
void handleLocalPlayerReady(entt::entity local)
Emplace player-control components onto the mapped local entity and record it.
Definition Game.cpp:375
float beamLightSpacing_
Distance between point lights along beam.
Definition Game.hpp:350
float statsFPS1pLow
1st-percentile FPS (1 % low).
Definition Game.hpp:499
glm::vec3 beamColor_
Beam emissive colour (purple).
Definition Game.hpp:347
CpuLbsSkinningBackend skinBackend_
Phase-1 CPU linear-blend-skinning backend.
Definition Game.hpp:475
void refreshDroppedWeaponRenderables()
Assign Renderable components to dropped-weapon entities (mirrors spawner visuals).
Definition Game.cpp:4858
float statsFPS5pLow
5th-percentile FPS (5 % low).
Definition Game.hpp:500
SDL_Window * window
The application window.
Definition Game.hpp:204
float sphereRange_
Point light range of movable sphere.
Definition Game.hpp:342
bool applyIncomingSnapshot(std::uint32_t snapshotTick, const std::uint8_t *bytes, Uint32 size, Uint64 captureNs, std::uint32_t &ackedTick)
Deserialize a snapshot from the server and update the ECS registry.
Definition Game.cpp:499
float prevSwayPitch_
Definition Game.hpp:440
int weaponModelIndices_[4]
Definition Game.hpp:327
float statsFPSMin
Minimum FPS in the ring buffer.
Definition Game.hpp:497
entt::entity accumTarget_
Current target being damaged.
Definition Game.hpp:393
SDL_AppResult iterate() override
Advance one frame: sample input, step physics, render.
Definition Game.cpp:1520
float rigMeshMinY_
Minimum Y of the bind-pose mesh vertices (model space).
Definition Game.hpp:481
void closeChat()
Leave chat input mode and restore normal gameplay input capture.
Definition Game.cpp:1105
bool returnToMainMenuRequested_
Latched true when the pause menu requests leaving the match.
Definition Game.hpp:530
float countdownTimer
Countdown timer for transitions between match phases (e.g. warmup to in-progress).
Definition Game.hpp:528
bool hitmarkerShieldBreak_
True when the current hit depleted target armor.
Definition Game.hpp:380
bool showHudDebug_
Show the HUD Tweaker panel.
Definition Game.hpp:334
float swayDecayRate_
Exponential decay speed.
Definition Game.hpp:448
std::unordered_map< entt::entity, float > footstepCooldowns_
Definition Game.hpp:360
float beamLightIntensity_
Point light intensity per sample.
Definition Game.hpp:348
uint64_t frameCount
Monotonic render-frame counter.
Definition Game.hpp:311
void refreshRemoteRespawnRenderables()
Reset Renderable visibility for players transitioning through respawn.
Definition Game.cpp:4808
uint8_t accumLastHitType_
0=health(white), 1=shield(blue), 2=headshot(gold).
Definition Game.hpp:396
Uint64 prevRenderTime
Perf counter at the last render call.
Definition Game.hpp:487
float accumulator
Unprocessed physics time in seconds.
Definition Game.hpp:221
DebugUI debugUI
Owns the ImGui context and SDL3 input backend.
Definition Game.hpp:205
Client * client
Borrowed UDP network client owned by App.
Definition Game.hpp:208
PauseMenu pauseMenu
In-game pause menu (opened with ESC, blocks input to the game when active).
Definition Game.hpp:535
ThirdPersonWeaponParams tpWeaponParams_[4]
Runtime-tunable copy; initialised from defaults.
Definition Game.hpp:462
float localFireCooldown_
Countdown timer; fire VFX only when <= 0.
Definition Game.hpp:457
float recoilPushBack_
Current recoil backward offset (Quake units).
Definition Game.hpp:453
bool init(AppContext &ctx)
Initialise all subsystems and spawn the local player entity.
Definition Game.cpp:534
float beamLightRange_
Point light range per sample.
Definition Game.hpp:349
std::vector< HudChatMessage > chatMessages_
Definition Game.hpp:419
bool limitFPSToMonitor
VSync on (true) / off (false).
Definition Game.hpp:300
void attachAnimatedCharacter(entt::entity e)
Attach a fresh AnimatedCharacter component to an entity.
Definition Game.cpp:4895
int pendingScrollSwitch_
+1 = next slot, -1 = previous slot, consumed each frame.
Definition Game.hpp:459
int tickCount
Total physics ticks elapsed since start.
Definition Game.hpp:222
Top-level HUD system.
Definition Hud.hpp:24
Interface implemented by each full-screen mode (Lobby, Game).
Definition IScreen.hpp:12
Definition InputRingBuffer.hpp:27
Graphics-team's work-in-progress SDL3 GPU renderer.
Definition NewRenderer.hpp:57
Top-level particle system orchestrator.
Definition ParticleSystem.hpp:35
Lightweight in-game pause overlay.
Definition PauseMenu.hpp:25
Client-side sound effects system.
Definition SfxSystem.hpp:49
std::uint32_t SourceHandle
Definition SfxSystem.hpp:51
static constexpr SourceHandle kInvalidSource
Definition SfxSystem.hpp:52
Definition VoiceChatSystem.hpp:22
Utilities for serializing and deserializing the ECS registry over the network.
Definition RegistrySerialization.cpp:127
Definition AudioRuntime.hpp:365
Persistent UI state for the Animation Tester panel.
Definition AnimationTesterUI.hpp:13
Non-owning view of App-owned services and configuration.
Definition AppContext.hpp:18
Associates an entity with a connected network client.
Definition ClientId.hpp:10
Definition Game.hpp:384
glm::vec3 pos
Definition Game.hpp:385
float damage
Definition Game.hpp:386
bool headshot
Definition Game.hpp:387
bool shielded
Definition Game.hpp:388
Definition Game.hpp:364
float primaryCooldown
Definition Game.hpp:371
bool grappleActive
Definition Game.hpp:370
SfxSystem::SourceHandle slideLoopHandle
Definition Game.hpp:373
float secondaryCooldown
Definition Game.hpp:372
bool initialized
Definition Game.hpp:365
int moveMode
Definition Game.hpp:368
bool isDead
Definition Game.hpp:367
bool gravityFlipped
Definition Game.hpp:369
bool grounded
Definition Game.hpp:366
Definition Game.hpp:144
InputSnapshot input
Definition Game.hpp:151
Velocity velocity
Definition Game.hpp:148
std::uint32_t tick
Definition Game.hpp:145
bool valid
Definition Game.hpp:152
PlayerVisState vis
Definition Game.hpp:149
Position position
Definition Game.hpp:146
PlayerSimState sim
Definition Game.hpp:150
PreviousPosition previousPosition
Definition Game.hpp:147
Definition Game.hpp:156
float velocityError
Definition Game.hpp:160
bool skip
Definition Game.hpp:157
bool missingHistory
Definition Game.hpp:158
float positionError
Definition Game.hpp:159
Hitbox rig (shared per character archetype).
Definition Hitbox.hpp:159
One tick of player input, stamped with the tick it was sampled on.
Definition InputSnapshot.hpp:19
Server-only locomotion bookkeeping.
Definition PlayerSimState.hpp:32
Replicated subset of player locomotion state.
Definition PlayerVisState.hpp:39
World-space position of an entity, in game units.
Definition Position.hpp:10
Copy of Position from the previous physics tick, used for render interpolation.
Definition PreviousPosition.hpp:22
Third-person weapon attachment params for remote players.
Definition ViewmodelConfig.hpp:22
Per-user gameplay settings loaded from SDL's pref-path TOML file.
Definition UserSettings.hpp:9
Linear velocity of an entity, in game units per second.
Definition Velocity.hpp:10
World weapon spawner model params.
Definition ViewmodelConfig.hpp:30
Collision data.
Definition MapLoader.hpp:36
Tunable parameters for gamepad aim assist.
Definition GamepadAimAssistSystem.hpp:71
Per-frame state required to compute the rotational pull as a delta between frames.
Definition GamepadAimAssistSystem.hpp:123