fix(client): add pause toggle, hold-to-move, snapshot event carry-forward
Three client input/bridge fixes: 1. Pause toggle: add UNPAUSE action and toggle logic based on GameState.game_time.tick_rate. Wire UNPAUSE in sim_bridge.gd. 2. Hold-to-move: replace press-event movement with polled _process() direction sampling. Composite diagonals via simultaneous keys (W+D → northeast). Client-side throttle per stance (D-053): Sprint=200ms, Walk=400ms, Careful=600ms, Crouch=800ms. 3. Snapshot carry-forward: when a newer snapshot overwrites an unconsumed one, carry forward current_monologue and current_dialogue so one-shot events aren't silently dropped. Fixes bugs #5 (monologue lost on overwrite) and #6 (overwrite spam). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -214,14 +214,21 @@ func poll_snapshot() -> Variant:
|
||||
return null
|
||||
|
||||
# Called by transport layer when raw bytes arrive from the server.
|
||||
# Latest-wins semantics: newer snapshots replace unconsumed ones. This is correct
|
||||
# for real-time rendering (stale frames are worthless). Upgrade to queue if needed.
|
||||
# Latest-wins for positional state (stale frames are worthless), but one-shot
|
||||
# events (monologue, dialogue) are carried forward from overwritten snapshots
|
||||
# so they aren't silently dropped when server ticks faster than client consumes.
|
||||
func receive_bytes(bytes: PackedByteArray) -> void:
|
||||
var snapshot = Protocol.decode_snapshot(bytes)
|
||||
if snapshot != null:
|
||||
if _last_snapshot != null:
|
||||
push_warning("SimBridge: overwriting unconsumed snapshot (tick %s replaced by %s)" % [_last_snapshot.tick, snapshot.tick])
|
||||
_last_snapshot = snapshot
|
||||
if snapshot == null:
|
||||
push_warning("SimBridge: decode_snapshot returned null for %d bytes" % bytes.size())
|
||||
return
|
||||
if _last_snapshot != null:
|
||||
# Carry forward one-shot events the client hasn't consumed yet.
|
||||
if snapshot.get("current_monologue") == null and _last_snapshot.get("current_monologue") != null:
|
||||
snapshot["current_monologue"] = _last_snapshot["current_monologue"]
|
||||
if snapshot.get("current_dialogue") == null and _last_snapshot.get("current_dialogue") != null:
|
||||
snapshot["current_dialogue"] = _last_snapshot["current_dialogue"]
|
||||
_last_snapshot = snapshot
|
||||
|
||||
# Drain the outbound buffer. Returns raw input entries for batch encoding.
|
||||
func drain_outbound() -> Array[Dictionary]:
|
||||
@@ -244,6 +251,7 @@ static func _action_enum_to_wire(action: int) -> String:
|
||||
InputMapper.Action.INTERACT: return "Interact"
|
||||
InputMapper.Action.USE_PERCEPTION_MODE: return "UsePerceptionMode"
|
||||
InputMapper.Action.PAUSE: return "Pause"
|
||||
InputMapper.Action.UNPAUSE: return "Unpause"
|
||||
InputMapper.Action.TOGGLE_STANCE_UP: return "ToggleStanceUp"
|
||||
InputMapper.Action.TOGGLE_STANCE_DOWN: return "ToggleStanceDown"
|
||||
InputMapper.Action.OPEN_MENU:
|
||||
|
||||
Reference in New Issue
Block a user