Enable the interaction data attachment in main.gd game loop. When E is pressed and the prompt is active, target_entity_id and verb are attached to the Interact action before sending to the server. Without a target, bare Interact is still sent as safe fallback. Completes the v0.1 interaction prompt data flow: server sends nearby_interactions → client shows prompt → E press attaches target+verb → SimBridge encodes and sends to server. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
40 lines
1.3 KiB
GDScript
40 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
|
|
@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:
|
|
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)
|