group2 0.1.0
CSE 125 Group 2
Loading...
Searching...
No Matches
WeaponConfig.hpp
Go to the documentation of this file.
1
3
4#pragma once
5
6#include "CollisionShape.hpp"
8
9#include <array>
10#include <cstddef>
11
14{
15 float fireCooldown = 0.1f;
16 int magazineSize = 0;
18 float damage = 0.0f;
19 bool hitscan = true;
21 bool explosive = false;
22 bool isBeam = false;
23 bool isCharge = false;
24 float dps = 0.0f;
25 float ammoPerSecond = 0.0f;
26 float chargeDamage = 0.0f;
27};
28
30{
31 int modelId = 0;
32 float initialSpeed = 0.0f;
33 float scale = 1.0f;
35 float maxLifeTime = 5.0f;
36 float explosionRadius = 0.0f;
37};
38
41{
42 static constexpr std::array<WeaponConfig, 4> k_kWeaponConfigs{{
44 .fireCooldown = 0.10f,
45 .magazineSize = 50,
46 .defaultAmmoCapacity = 500,
47 .damage = 15.0f,
48 .hitscan = true,
49 .initialProjectileSpeed = 0.0f,
50 .explosive = false,
51 }, // Rifle
53 .fireCooldown = 1.0f,
54 .magazineSize = 4,
55 .defaultAmmoCapacity = 12,
56 .damage = 200.0f,
57 .hitscan = false,
58 .initialProjectileSpeed = 500.0f,
59 .explosive = true,
60 }, // Rocket
62 .fireCooldown = 0.30f,
63 .magazineSize = 8,
64 .defaultAmmoCapacity = 32,
65 .damage = 60.0f,
66 .hitscan = true,
67 .initialProjectileSpeed = 0.0f,
68 .explosive = false,
69 .isCharge = true,
70 .chargeDamage = 150.0f,
71 }, // RailGun (charge sniper)
73 .fireCooldown = 0.0f,
74 .magazineSize = 200,
75 .defaultAmmoCapacity = 200,
76 .damage = 5.0f,
77 .hitscan = true,
78 .initialProjectileSpeed = 0.0f,
79 .explosive = false,
80 .isBeam = true,
81 .dps = 80.0f,
82 .ammoPerSecond = 20.0f,
83 }, // EnergyGun (Zarya beam)
84 }};
85
86 return k_kWeaponConfigs[static_cast<std::size_t>(type)];
87}
88
91{
92 static constexpr std::array<ProjectileConfig, 4> k_kProjectileConfigs{{
93 ProjectileConfig{}, // Rifle
95 .modelId = 1,
96 .initialSpeed = 0.0f,
97 .scale = 1.0f,
98 .shape = CollisionShape{.halfExtents = {5.0f, 5.0f, 5.0f}},
99 .maxLifeTime = 5.0f,
100 .explosionRadius = 175.0f,
101 }, // Rocket
102 ProjectileConfig{}, // RailGun
103 ProjectileConfig{}, // EnergyGun
104 }};
105
106 return k_kProjectileConfigs[static_cast<std::size_t>(type)];
107}
AABB collision shape component for physics entities.
Projectile component and weapon/surface type enumerations.
const ProjectileConfig & getProjectileConfig(WeaponType type)
Returns the projectile config for a weapon type.
Definition WeaponConfig.hpp:90
const WeaponConfig & getWeaponConfig(WeaponType type)
Returns the gameplay config for a weapon type.
Definition WeaponConfig.hpp:40
WeaponType
Weapon type — determines tracer style, damage, sound, and impact effects.
Definition WeaponState.hpp:10
Axis-aligned bounding box defined by half-extents from the entity's Position.
Definition CollisionShape.hpp:16
glm::vec3 halfExtents
AABB half-dimensions (units).
Definition CollisionShape.hpp:17
Definition WeaponConfig.hpp:30
int modelId
Definition WeaponConfig.hpp:31
float explosionRadius
Definition WeaponConfig.hpp:36
float initialSpeed
Definition WeaponConfig.hpp:32
float maxLifeTime
Definition WeaponConfig.hpp:35
CollisionShape shape
Definition WeaponConfig.hpp:34
float scale
Definition WeaponConfig.hpp:33
Immutable gameplay stats for a weapon type.
Definition WeaponConfig.hpp:14
int defaultAmmoCapacity
Definition WeaponConfig.hpp:17
bool isCharge
True for charge weapons (hold to charge, release to fire).
Definition WeaponConfig.hpp:23
bool hitscan
Definition WeaponConfig.hpp:19
float ammoPerSecond
Ammo drain rate (beam weapons only).
Definition WeaponConfig.hpp:25
float initialProjectileSpeed
Definition WeaponConfig.hpp:20
float chargeDamage
Damage dealt on release (charge weapons only).
Definition WeaponConfig.hpp:26
int magazineSize
Definition WeaponConfig.hpp:16
bool isBeam
True for continuous beam weapons (no per-shot cooldown).
Definition WeaponConfig.hpp:22
float fireCooldown
Definition WeaponConfig.hpp:15
bool explosive
Definition WeaponConfig.hpp:21
float damage
Definition WeaponConfig.hpp:18
float dps
Damage per second (beam weapons only; discrete weapons use damage).
Definition WeaponConfig.hpp:24