969741aa31
- WeaponData: restored class_name, converted static vars to make() factory - WeaponDefinitions: updated to use make() instead of static var refs - Windows export: tactical-shooter.exe + godot-jolt_windows-x64.dll - Build artifact: build/tactical-shooter-windows-x86_64-v0.1.0.zip
69 lines
2.3 KiB
GDScript
69 lines
2.3 KiB
GDScript
## WeaponData — A resource defining a weapon's static properties.
|
|
##
|
|
## Used as the data contract between weapon_definitions.gd, weapon_server.gd,
|
|
## and weapon_manager.gd. Each weapon type is pre-configured and accessible
|
|
## via the class-level constants (RIFLE, PISTOL, SHOTGUN, SMG).
|
|
##
|
|
## Usage:
|
|
## var wd = preload("res://scripts/combat/weapon_data.gd")
|
|
## var data = wd.make("rifle", "Assault Rifle", 30.0, 10.0, 30, ...)
|
|
|
|
extends Resource
|
|
class_name WeaponData
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# Properties
|
|
# ---------------------------------------------------------------------------
|
|
|
|
## Unique identifier string (e.g., "rifle", "pistol").
|
|
@export var weapon_id: String = ""
|
|
## Human-readable weapon name.
|
|
@export var display_name: String = ""
|
|
## Base damage per projectile/pellet.
|
|
@export var damage: float = 0.0
|
|
## Rate of fire in rounds per second (Hz).
|
|
@export var fire_rate: float = 0.0
|
|
## Magazine capacity (max ammo per reload).
|
|
@export var mag_size: int = 0
|
|
## Reload duration in seconds.
|
|
@export var reload_time: float = 0.0
|
|
## If true, hold to fire continuously. If false, single-shot per press.
|
|
@export var is_automatic: bool = false
|
|
## Base weapon spread in degrees (used for accuracy cone).
|
|
@export var spread_degrees: float = 0.0
|
|
## Effective range in Godot units (metres conceptual).
|
|
@export var range: float = 0.0
|
|
## Number of pellets/projectiles per shot (1 for most weapons, 8 for shotgun).
|
|
@export var pellets_per_shot: int = 1
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# Factory
|
|
# ---------------------------------------------------------------------------
|
|
|
|
## Construct a WeaponData instance from raw stat values.
|
|
## Avoids class_name references in return types for headless compatibility.
|
|
static func make(
|
|
_weapon_id: String,
|
|
_display_name: String,
|
|
_damage: float,
|
|
_fire_rate: float,
|
|
_mag_size: int,
|
|
_reload_time: float,
|
|
_is_automatic: bool,
|
|
_spread_degrees: float,
|
|
_range: float,
|
|
_pellets: int = 1
|
|
):
|
|
var w = WeaponData.new()
|
|
w.weapon_id = _weapon_id
|
|
w.display_name = _display_name
|
|
w.damage = _damage
|
|
w.fire_rate = _fire_rate
|
|
w.mag_size = _mag_size
|
|
w.reload_time = _reload_time
|
|
w.is_automatic = _is_automatic
|
|
w.spread_degrees = _spread_degrees
|
|
w.range = _range
|
|
w.pellets_per_shot = _pellets
|
|
return w
|