Server-driven interaction prompt that displays "E - Talk" when near an interactable NPC. Decodes v4 nearby_interactions from snapshot, stores in GameState, renders via InteractionPrompt UI with fade animation. Extensible interface (get_interaction_target/get_selected_verb) for future radial verb menu (v0.2). - Protocol: decode nearby_interactions array with nested VerbOption structs, entity relationship/observation fields, tick_rate in GameTime - GameState: store/clear nearby_interactions per snapshot - SimBridge: test mode generates v4 format with structured verbs - InteractionPrompt: PanelContainer with fade in/out, polls GameState - Tests: 19 new test cases covering protocol, state, sim bridge, UI, encoding - Fixture assertions updated for v4 protocol version Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
41 lines
1.5 KiB
GDScript
41 lines
1.5 KiB
GDScript
extends Node2D
|
|
|
|
@onready var world_renderer = $World
|
|
@onready var camera = $Camera2D
|
|
@onready var hud = $UILayer/HUD
|
|
@onready var monologue_display = $UILayer/MonologueDisplay
|
|
@onready var interaction_prompt = $UILayer/InteractionPrompt
|
|
|
|
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 every frame (D-015: locked, no panning)
|
|
# Camera2D smoothing handles interpolation — we just set the target
|
|
camera.global_position = GameState.player_position * Constants.TILE_SIZE
|
|
|
|
# Send queued input to simulation
|
|
var inputs = InputMapper.flush_queue()
|
|
for input in inputs:
|
|
# TODO: Once server accepts Interact(InteractData), attach target + verb:
|
|
# if input.action == InputMapper.Action.INTERACT:
|
|
# var target_id: int = interaction_prompt.get_interaction_target()
|
|
# if target_id >= 0:
|
|
# input["action_data"] = {
|
|
# "target_entity_id": target_id,
|
|
# "verb": interaction_prompt.get_selected_verb(),
|
|
# }
|
|
SimBridge.send_input(input)
|