- Camera2D now tracks player_position from GameState (D-015) - Add SubViewport child to minimap SubViewportContainer (fixes editor warning) - Wire MonologueDisplay into main loop for D-016 perception data path Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
41 lines
1.3 KiB
GDScript
41 lines
1.3 KiB
GDScript
extends Node2D
|
|
|
|
@onready var world_renderer = $World
|
|
@onready var camera = $Camera2D
|
|
@onready var hud = $UILayer/HUD
|
|
@onready var monologue_display = $UILayer/MonologueDisplay
|
|
|
|
func _ready() -> void:
|
|
print("The Settled Reach — client initialized")
|
|
|
|
# Connect to simulation (will use test mode initially)
|
|
SimBridge.connect_to_sim()
|
|
|
|
func _process(_delta: float) -> void:
|
|
# Main game loop: poll snapshot, apply state, flush input
|
|
var snapshot = SimBridge.poll_snapshot()
|
|
if snapshot != null:
|
|
GameState.apply_snapshot(snapshot)
|
|
|
|
# Update renderers with new state
|
|
if world_renderer and world_renderer.has_method("update_from_state"):
|
|
world_renderer.update_from_state()
|
|
|
|
# Track camera to player position (D-015)
|
|
camera.position = GameState.player_position * 32 # tile-space to pixel-space
|
|
|
|
# Update HUD
|
|
if hud and hud.has_method("update_from_hud_data"):
|
|
hud.update_from_hud_data(GameState.hud_data)
|
|
if snapshot.has("player") and snapshot.player.has("health"):
|
|
hud.update_health(snapshot.player.health)
|
|
|
|
# Wire monologue display (D-016 perception data path)
|
|
if snapshot.has("monologue") and monologue_display:
|
|
monologue_display.show_monologue(snapshot.monologue)
|
|
|
|
# Send queued input to simulation
|
|
var inputs = InputMapper.flush_queue()
|
|
for input in inputs:
|
|
SimBridge.send_input(input)
|