2452aba0d7
- 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
35 lines
1.3 KiB
GDScript
35 lines
1.3 KiB
GDScript
## 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
|