mirror of
https://github.com/jcreek/CosmicClash.git
synced 2026-09-11 08:23:45 +00:00
refactor(*): Restructure game into reusable Arena/GameMode architecture with controller-driven ships, adding Free Play and Match modes
This commit is contained in:
@@ -25,22 +25,26 @@ func _initialize_hud():
|
||||
# Find the ship
|
||||
ship = get_tree().get_first_node_in_group("ship")
|
||||
if not ship:
|
||||
# Try to find it as our parent (ship contains this HUD)
|
||||
var parent_node = get_parent()
|
||||
if parent_node and parent_node.is_in_group("ship"):
|
||||
ship = parent_node
|
||||
else:
|
||||
push_error("HUDController: No ship found in 'ship' group")
|
||||
return
|
||||
|
||||
push_error("HUDController: No ship found in 'ship' group")
|
||||
return
|
||||
|
||||
print("HUDController: Found ship: ", ship.name)
|
||||
_connect_ship_signals()
|
||||
|
||||
# Connect to game manager's timer signal
|
||||
|
||||
# Camera mode comes from the camera rig, not the ship
|
||||
var camera_rig = get_tree().get_first_node_in_group("ship_camera")
|
||||
if camera_rig and camera_rig.has_signal("camera_mode_changed"):
|
||||
camera_rig.camera_mode_changed.connect(_on_ship_camera_mode_changed)
|
||||
|
||||
# Connect to game manager's timer signal; modes without a timer
|
||||
# (e.g. free play) just don't show one
|
||||
var game_manager = get_tree().get_first_node_in_group("game")
|
||||
if game_manager and game_manager.has_signal("timer_updated"):
|
||||
var has_timer = game_manager and game_manager.has_signal("timer_updated")
|
||||
if has_timer:
|
||||
game_manager.timer_updated.connect(_on_timer_updated)
|
||||
print("HUDController: Connected to game timer")
|
||||
if timer_label and is_instance_valid(timer_label):
|
||||
timer_label.visible = has_timer
|
||||
|
||||
func _connect_ship_signals():
|
||||
# Connect ship signals to label update methods
|
||||
@@ -51,8 +55,6 @@ func _connect_ship_signals():
|
||||
ship.altitude_changed.connect(_on_ship_altitude_changed)
|
||||
if ship.has_signal("angular_velocity_changed"):
|
||||
ship.angular_velocity_changed.connect(_on_ship_angular_velocity_changed)
|
||||
if ship.has_signal("camera_mode_changed"):
|
||||
ship.camera_mode_changed.connect(_on_ship_camera_mode_changed)
|
||||
if ship.has_signal("attitude_changed"):
|
||||
ship.attitude_changed.connect(_on_ship_attitude_changed)
|
||||
if ship.has_signal("heading_changed"):
|
||||
@@ -79,7 +81,7 @@ func _on_ship_camera_mode_changed(is_ball_cam: bool):
|
||||
var camera_mode = "Ball Cam" if is_ball_cam else "Ship Cam"
|
||||
camera_mode_label.text = "Camera: %s" % camera_mode
|
||||
|
||||
func _on_ship_attitude_changed(pitch: float, roll: float, yaw: float):
|
||||
func _on_ship_attitude_changed(pitch: float, roll: float, _yaw: float):
|
||||
if attitude_label and is_instance_valid(attitude_label):
|
||||
attitude_label.text = "Pitch: %.0f° Roll: %.0f°" % [pitch, roll]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user