group2 0.1.0
CSE 125 Group 2
Loading...
Searching...
No Matches
WeaponSystem.cpp File Reference

Weapon state manager system. More...

Include dependency graph for WeaponSystem.cpp:

Classes

struct  systems::BeamLockResult
 Result of an auto-lock cone scan for a Tesla-style beam. More...

Namespaces

namespace  systems
 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).

Macros

#define GROUP2_HAS_SHOTLOG   0

Functions

bool systems::combatLogEnabled ()
void systems::handleSwitch (const InputSnapshot &input, WeaponState &weapon)
 Apply weapon slot switch from player input.
void systems::handleCooldown (WeaponState &weapon, float dt)
 Tick fire cooldowns for all weapon slots.
void systems::handleGrenadeCooldown (GrenadeState &grenades, float dt)
void systems::handleReload (GunInstance &gun)
 Reload the gun's magazine from reserve ammo.
bool systems::handleAmmo (GunInstance &gun)
 Consume one round from the magazine; auto-reload if empty.
glm::vec3 systems::viewForward (float yaw, float pitch)
 Forward direction implied by a player's yaw + pitch.
glm::vec3 systems::muzzleOrigin (glm::vec3 eye, glm::vec3 direction, bool gravityFlipped=false)
 Offset the muzzle origin from the eye position for tracer visuals.
void systems::logShot (Registry &registry, entt::entity shooter, std::uint32_t shotInputTick, const glm::vec3 &origin, const glm::vec3 &direction, const physics::HitboxHit &hit)
void systems::captureShotDebug (Registry &registry, 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 systems::spawnGrenade (Registry &registry, 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 systems::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 systems::handleGrenadeInput (Registry &registry, entt::entity shooter, InputSnapshot &input, const Position &pos, const CollisionShape &shape, GrenadeState &grenades, bool gravityFlipped)
void systems::handleScope (Registry &registry, entt::entity shooter, const InputSnapshot &input, WeaponState &weapon, float dt)
BeamLockResult systems::findBeamLockTarget (Registry &registry, 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 systems::handleFire (Registry &registry, 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 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.
HitscanHit resolveHitscan (Registry &registry, entt::entity shooter, glm::vec3 origin, glm::vec3 direction)
 Full hitscan resolution: world geometry first, then players (closest wins).
HitboxHit resolveHitscanHitbox (Registry &registry, entt::entity shooter, glm::vec3 origin, glm::vec3 direction, float bulletRadius=0.0f)
 Full hitscan with skeleton-driven hitboxes.

Detailed Description

Weapon state manager system.

Macro Definition Documentation

◆ GROUP2_HAS_SHOTLOG

#define GROUP2_HAS_SHOTLOG   0

Function Documentation

◆ resolveHitscan()

HitscanHit physics::resolveHitscan ( Registry & registry,
entt::entity shooter,
glm::vec3 origin,
glm::vec3 direction )
inline

Full hitscan resolution: world geometry first, then players (closest wins).

◆ resolveHitscanHitbox()

HitboxHit physics::resolveHitscanHitbox ( Registry & registry,
entt::entity shooter,
glm::vec3 origin,
glm::vec3 direction,
float bulletRadius = 0.0f )
inline

Full hitscan with skeleton-driven hitboxes.

World geometry first, then player hitbox capsules (closest wins). Falls back to the old AABB path for players without HitboxInstance.

Parameters
bulletRadiusSwept-sphere "cylinder hitreg" radius (world units) applied to PLAYER hitboxes only. World geometry stays a thin ray so bullets still require crosshair line-of-sight past walls. 0 = ray.