46ff83325f
- team_data.gd: Team enum (SPECTATOR/CT/Terrorist), constants for names, colors, starting money, and spawn groups; TeamData resource class - team_manager.gd: Player-to-team assignment, auto-balancing, score tracking; round-independent (persists across rounds) - spawn_manager.gd: Scans scene for Marker3D nodes in spawn_points_ct and spawn_points_t groups; selects valid spawns (farthest from enemies with proximity check, fallback to first available) - buy_zone.gd: Area3D-based trigger zone with team filtering, player enter/exit tracking and signals - test_range.tscn: Added 2 CT spawn markers and 2 T spawn markers with appropriate groups
124 lines
3.6 KiB
GDScript
124 lines
3.6 KiB
GDScript
## TeamData — Team definitions and resource for a tactical FPS.
|
|
##
|
|
## Defines the Team enum, named constants for team metadata,
|
|
## and a TeamData resource for per-team configuration.
|
|
##
|
|
## Usage:
|
|
## var team: Team = Team.COUNTER_TERRORIST
|
|
## var name: String = TeamData.get_team_name(team)
|
|
## var color: Color = TeamData.get_team_color(team)
|
|
##
|
|
## Persists across rounds (round-independent).
|
|
##
|
|
## Enum values follow Godot-friendly ordering:
|
|
## 0 = SPECTATOR (no team)
|
|
## 1 = COUNTER_TERRORIST
|
|
## 2 = TERRORIST
|
|
|
|
extends Resource
|
|
class_name TeamData
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# Team enum
|
|
# ---------------------------------------------------------------------------
|
|
enum Team {
|
|
SPECTATOR = 0,
|
|
COUNTER_TERRORIST = 1,
|
|
TERRORIST = 2,
|
|
}
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# Named constants
|
|
# ---------------------------------------------------------------------------
|
|
const TEAM_NAMES: Dictionary = {
|
|
Team.SPECTATOR: "Spectator",
|
|
Team.COUNTER_TERRORIST: "Counter-Terrorist",
|
|
Team.TERRORIST: "Terrorist",
|
|
}
|
|
|
|
const TEAM_COLORS: Dictionary = {
|
|
Team.SPECTATOR: Color(0.6, 0.6, 0.6, 1.0),
|
|
Team.COUNTER_TERRORIST: Color(0.2, 0.5, 0.9, 1.0), # Blue
|
|
Team.TERRORIST: Color(0.9, 0.3, 0.2, 1.0), # Red
|
|
}
|
|
|
|
## Default starting money per player on each team.
|
|
const STARTING_MONEY: Dictionary = {
|
|
Team.COUNTER_TERRORIST: 800,
|
|
Team.TERRORIST: 800,
|
|
Team.SPECTATOR: 0,
|
|
}
|
|
|
|
## Default spawn group suffixes used by SpawnManager when looking for markers.
|
|
const TEAM_SPAWN_GROUPS: Dictionary = {
|
|
Team.COUNTER_TERRORIST: "spawn_points_ct",
|
|
Team.TERRORIST: "spawn_points_t",
|
|
}
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# Resource properties
|
|
# ---------------------------------------------------------------------------
|
|
|
|
## The team this resource describes.
|
|
@export var team_id: Team = Team.SPECTATOR
|
|
|
|
## Human-readable display name for this team.
|
|
@export var display_name: String = ""
|
|
|
|
## Team colour (used for UI, minimap, etc.).
|
|
@export var color: Color = Color.WHITE
|
|
|
|
## Default spawn group name to scan when placing this team on a map.
|
|
@export var default_spawn_group: String = ""
|
|
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# Static helpers
|
|
# ---------------------------------------------------------------------------
|
|
|
|
## Return the human-readable name for a Team enum value.
|
|
static func get_team_name(team: Team) -> String:
|
|
return TEAM_NAMES.get(team, "Unknown")
|
|
|
|
|
|
## Return the colour for a Team enum value.
|
|
static func get_team_color(team: Team) -> Color:
|
|
return TEAM_COLORS.get(team, Color.WHITE)
|
|
|
|
|
|
## Return the starting money for a Team enum value.
|
|
static func get_starting_money(team: Team) -> int:
|
|
return STARTING_MONEY.get(team, 0)
|
|
|
|
|
|
## Return the spawn group name for a Team enum value.
|
|
static func get_spawn_group(team: Team) -> String:
|
|
return TEAM_SPAWN_GROUPS.get(team, "")
|
|
|
|
|
|
## Return true if the team is a playable team (not spectator).
|
|
static func is_playable_team(team: Team) -> bool:
|
|
return team == Team.COUNTER_TERRORIST or team == Team.TERRORIST
|
|
|
|
|
|
## Convert a string to a Team enum value. Returns SPECTATOR if unknown.
|
|
static func from_string(name: String) -> Team:
|
|
match name.to_lower():
|
|
"counter_terrorist", "counter-terrorist", "ct", "counterterrorist":
|
|
return Team.COUNTER_TERRORIST
|
|
"terrorist", "t":
|
|
return Team.TERRORIST
|
|
_:
|
|
return Team.SPECTATOR
|
|
|
|
|
|
## Convert a Team enum value to its short string identifier.
|
|
static func to_short_string(team: Team) -> String:
|
|
match team:
|
|
Team.COUNTER_TERRORIST:
|
|
return "CT"
|
|
Team.TERRORIST:
|
|
return "T"
|
|
_:
|
|
return "SPEC"
|