feat: implement weapon set system (t_p2_weapons)

- WeaponData resource class with configurable weapon properties and
  pre-configured constants for rifle, pistol, shotgun, and SMG
- WeaponDefinitions singleton/static registry with WEAPONS dictionary
- WeaponServer node for server-authoritative weapon logic including
  fire rate cooldowns, ammo tracking, reload state machine, and
  multi-pellet hit-scan raycasting
- Extended WeaponManager with weapon inventory array, weapon switching,
  per-weapon state persistence, fire_animation_triggered signal
This commit is contained in:
2026-07-01 20:16:22 -04:00
parent 3c3251fa7a
commit 2452aba0d7
4 changed files with 654 additions and 5 deletions
+34
View File
@@ -0,0 +1,34 @@
## WeaponDefinitions — Central registry of all weapon definitions.
##
## Provides a WEAPONS dictionary keyed by weapon_id for runtime lookup,
## plus a convenience getter. The data itself lives in WeaponData constants,
## so this file serves as a single import point for the full arsenal.
##
## Usage (as autoload singleton or direct preload):
## var data = WeaponDefinitions.get_weapon("rifle")
## # or:
## var all = WeaponDefinitions.WEAPONS
##
extends RefCounted
class_name WeaponDefinitions
# ---------------------------------------------------------------------------
# Weapon Registry
# ---------------------------------------------------------------------------
## All weapons indexed by weapon_id — the single source of truth for the
## game's starter arsenal. Add new weapons here and in WeaponData.
const WEAPONS: Dictionary = {
"rifle": WeaponData.RIFLE,
"pistol": WeaponData.PISTOL,
"shotgun": WeaponData.SHOTGUN,
"smg": WeaponData.SMG,
}
# ---------------------------------------------------------------------------
# Lookup
# ---------------------------------------------------------------------------
## Return the WeaponData for the given weapon_id, or null if unknown.
static func get_weapon(id: String) -> WeaponData:
return WEAPONS.get(id, null) as WeaponData