group2 0.1.0
CSE 125 Group 2
Loading...
Searching...
No Matches
WeaponState.hpp
Go to the documentation of this file.
1
3
4#pragma once
5
6#include <array>
7#include <cstddef>
8#include <cstdint>
9
23
24inline constexpr std::size_t kRenderableWeaponTypeCount = static_cast<std::size_t>(WeaponType::Shotgun) + 1;
25
31enum class WeaponSlot : uint8_t
32{
36};
37
40{
42 int totalAmmo = 0;
44 float fireCooldown = 0.f;
45 float chargeTime = 0.f;
46 bool isReloading = false;
47 float reloadTime = 0.f;
48 float recoilHeat = 0.f;
49 float recoilIdleTime = 0.f;
51};
52
60{
61 std::array<GunInstance, static_cast<std::size_t>(WeaponSlot::Count)> slots{};
63};
64
67{
68 return w.slots[static_cast<std::size_t>(s)];
69}
70inline const GunInstance& getSlot(const WeaponState& w, WeaponSlot s)
71{
72 return w.slots[static_cast<std::size_t>(s)];
73}
74
77{
78 return getSlot(w, w.current);
79}
80inline const GunInstance& getEquippedGun(const WeaponState& w)
81{
82 return getSlot(w, w.current);
83}
84
86{
87 for (auto& slot : w.slots) {
88 if (slot.type == type) {
89 return &slot;
90 }
91 }
92 return nullptr;
93}
GunInstance & getSlot(WeaponState &w, WeaponSlot s)
Access a specific slot on a WeaponState by enum.
Definition WeaponState.hpp:66
constexpr std::size_t kRenderableWeaponTypeCount
Definition WeaponState.hpp:24
GunInstance & getEquippedGun(WeaponState &w)
The slot the player is currently holding.
Definition WeaponState.hpp:76
GunInstance * findSlotWithType(WeaponState &w, WeaponType type)
Definition WeaponState.hpp:85
WeaponSlot
Identifier for one of the player's weapon slots.
Definition WeaponState.hpp:32
@ SECONDARY
Definition WeaponState.hpp:34
@ PRIMARY
Definition WeaponState.hpp:33
@ Count
Sentinel — must be last. Equals the number of valid slots.
Definition WeaponState.hpp:35
WeaponType
Weapon type — determines tracer style, damage, sound, and impact effects.
Definition WeaponState.hpp:12
@ EnergyGun
Fast hitscan energy burst.
Definition WeaponState.hpp:16
@ Rocket
Slow arcing projectile (ribbon trail).
Definition WeaponState.hpp:14
@ RailGun
Hitscan energy weapon (beam + lightning arcs).
Definition WeaponState.hpp:15
@ Shotgun
Peacekeeper-style pump: 9-pellet star spread, hitscan.
Definition WeaponState.hpp:17
@ None
No weapon in this slot.
Definition WeaponState.hpp:21
@ Rifle
Fast hitscan/projectile (R301-style capsule tracer).
Definition WeaponState.hpp:13
@ Sticky
Sticks to first surface or player; guaranteed kill when stuck to a player.
Definition WeaponState.hpp:20
@ HEGrenade
Bouncy grenade with 3s fuse, lethal explosion + big knockback.
Definition WeaponState.hpp:18
@ Molotov
Impact-detonate, leaves a fire field (damage over time).
Definition WeaponState.hpp:19
Struct that defines this weapon's type, cooldown, and ammo.
Definition WeaponState.hpp:40
bool isReloading
True while reload is in progress.
Definition WeaponState.hpp:46
bool firedSinceTriggerPress
Semi-auto gate: blocks re-fire until trigger released.
Definition WeaponState.hpp:50
WeaponType type
Definition WeaponState.hpp:41
float recoilIdleTime
Time off trigger before decay starts.
Definition WeaponState.hpp:49
float recoilHeat
Recoil heat (decays when not firing).
Definition WeaponState.hpp:48
float fireCooldown
Definition WeaponState.hpp:44
float reloadTime
Time remaining to complete a reload.
Definition WeaponState.hpp:47
float chargeTime
Accumulated charge time (charge weapons only).
Definition WeaponState.hpp:45
int currentMagAmmo
Definition WeaponState.hpp:43
int totalAmmo
Definition WeaponState.hpp:42
Component attached to armed entities (players).
Definition WeaponState.hpp:60
WeaponSlot current
Currently equipped slot.
Definition WeaponState.hpp:62
std::array< GunInstance, static_cast< std::size_t >(WeaponSlot::Count)> slots
Definition WeaponState.hpp:61