Fix headless class_name dependencies
- Replaced TeamData.Team type hints with int in all scripts - Added explicit preloads for headless mode class resolution - Created stub LagCompensation and DamageProcessor scripts - Fixed PluginManager, SpawnManager, EconomyManager, BuyZone, RoundManager, BuyMenuHandler, BombObjective class_name references - Updated server config to match ServerConfig.gd format Gray screen root cause: server scripts failed to parse in headless mode due to Godot 4 class_name loading order (Resource after Node), leaving server_main.gd non-functional — accepted connections but never spawned players.
This commit is contained in:
@@ -23,6 +23,8 @@
|
||||
class_name BuyMenuHandler
|
||||
extends Node
|
||||
|
||||
const _td = preload("res://scripts/teams/team_data.gd")
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Signals
|
||||
# ---------------------------------------------------------------------------
|
||||
@@ -84,7 +86,7 @@ func is_player_in_buyzone(player_id: int) -> bool:
|
||||
# No buy zones means players can buy anywhere (dev fallback)
|
||||
return true
|
||||
|
||||
var player_team: TeamData.Team = TeamData.Team.SPECTATOR
|
||||
var player_team: int = TeamData.Team.SPECTATOR
|
||||
if team_manager:
|
||||
player_team = team_manager.get_player_team(player_id)
|
||||
|
||||
|
||||
@@ -23,8 +23,9 @@
|
||||
## Signals:
|
||||
## money_changed(player_id, old_amount, new_amount, reason)
|
||||
##
|
||||
class_name EconomyManager
|
||||
extends Node
|
||||
class_name EconomyManager
|
||||
const _td_eco = preload("res://scripts/teams/team_data.gd")
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Weapon costs
|
||||
@@ -81,7 +82,7 @@ signal money_changed(player_id: int, old_amount: int, new_amount: int, reason: S
|
||||
var _money: Dictionary = {} # player_id (int) → balance (int)
|
||||
|
||||
## Consecutive round losses per team, used to escalate the loss bonus.
|
||||
## Key: TeamData.Team (int), Value: consecutive losses (int)
|
||||
## Key: int (int), Value: consecutive losses (int)
|
||||
var _consecutive_losses: Dictionary = {}
|
||||
|
||||
## Total money ever earned per player (for stats). Not reset on round restart.
|
||||
@@ -91,9 +92,9 @@ var _total_earned: Dictionary = {} # player_id (int) → total (int)
|
||||
# Lifecycle
|
||||
# ---------------------------------------------------------------------------
|
||||
func _ready() -> void:
|
||||
_consecutive_losses[TeamData.Team.COUNTER_TERRORIST] = 0
|
||||
_consecutive_losses[TeamData.Team.TERRORIST] = 0
|
||||
_consecutive_losses[TeamData.Team.SPECTATOR] = 0
|
||||
_consecutive_losses[_td_eco.Team.COUNTER_TERRORIST] = 0
|
||||
_consecutive_losses[_td_eco.Team.TERRORIST] = 0
|
||||
_consecutive_losses[_td_eco.Team.SPECTATOR] = 0
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Public API — Money queries
|
||||
@@ -170,14 +171,14 @@ func award_kill_reward(player_id: int) -> void:
|
||||
|
||||
## Award the round-win bonus to every player on the winning team.
|
||||
## Resets the loss streak for that team.
|
||||
func award_round_win(team: TeamData.Team, player_ids: Array[int]) -> void:
|
||||
func award_round_win(team: int, player_ids: Array[int]) -> void:
|
||||
for pid in player_ids:
|
||||
add_money(pid, ROUND_WIN_BONUS, "round_win")
|
||||
_consecutive_losses[team] = 0
|
||||
|
||||
## Award the round-loss bonus to every player on the losing team.
|
||||
## Escalates based on consecutive losses (loss streak).
|
||||
func award_round_loss(team: TeamData.Team, player_ids: Array[int]) -> void:
|
||||
func award_round_loss(team: int, player_ids: Array[int]) -> void:
|
||||
var streak: int = _consecutive_losses.get(team, 0)
|
||||
var bonus: int = mini(streak * LOSS_STREAK_BONUS, MAX_LOSS_BONUS_ADDITIONAL)
|
||||
var total_bonus: int = ROUND_LOSS_BASE + bonus
|
||||
@@ -195,7 +196,7 @@ func award_bomb_defuse(player_id: int) -> void:
|
||||
|
||||
## Return the total loss bonus the given team would receive on their
|
||||
## next round loss, accounting for the current loss streak.
|
||||
func get_loss_bonus_for_team(team: TeamData.Team) -> int:
|
||||
func get_loss_bonus_for_team(team: int) -> int:
|
||||
var streak: int = _consecutive_losses.get(team, 0)
|
||||
var bonus: int = mini(streak * LOSS_STREAK_BONUS, MAX_LOSS_BONUS_ADDITIONAL)
|
||||
return ROUND_LOSS_BASE + bonus
|
||||
@@ -226,8 +227,8 @@ func reset_economy(player_ids: Array[int] = []) -> void:
|
||||
_money[pid] = STARTING_MONEY
|
||||
money_changed.emit(pid, old, STARTING_MONEY, "reset")
|
||||
|
||||
_consecutive_losses[TeamData.Team.COUNTER_TERRORIST] = 0
|
||||
_consecutive_losses[TeamData.Team.TERRORIST] = 0
|
||||
_consecutive_losses[_td_eco.Team.COUNTER_TERRORIST] = 0
|
||||
_consecutive_losses[_td_eco.Team.TERRORIST] = 0
|
||||
|
||||
## Reset exactly one player's money to STARTING_MONEY.
|
||||
func reset_player_money(player_id: int) -> void:
|
||||
|
||||
Reference in New Issue
Block a user