gmp(M02): add player input intent seam
Work-Package: M02-GMP-INPUT-001 Agent: sindo-main-codex Tests: verify_player_input; renderer baseline dry-run; coordinate, streaming, documentation and coordination gates Fidelity: preserves current sandbox bindings and movement/camera behavior; exact build-12340 semantics remain unverified
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
class_name PlayerInputActions
|
||||
extends RefCounted
|
||||
|
||||
## Stable Input Map action names consumed by the runtime player input adapter.
|
||||
## Defaults preserve the current render-sandbox controls; users may remap every
|
||||
## action through Godot's Input Map without changing gameplay code.
|
||||
|
||||
const MOVE_FORWARD := &"openwc_player_move_forward"
|
||||
const MOVE_BACKWARD := &"openwc_player_move_backward"
|
||||
const STRAFE_LEFT := &"openwc_player_strafe_left"
|
||||
const STRAFE_RIGHT := &"openwc_player_strafe_right"
|
||||
const DEBUG_FLY_UP := &"openwc_player_debug_fly_up"
|
||||
const DEBUG_FLY_DOWN := &"openwc_player_debug_fly_down"
|
||||
const DEBUG_SPRINT := &"openwc_player_debug_sprint"
|
||||
const DEBUG_TOGGLE_FLIGHT := &"openwc_player_debug_toggle_flight"
|
||||
const CAMERA_ROTATE := &"openwc_player_camera_rotate"
|
||||
const CAMERA_ZOOM_IN := &"openwc_player_camera_zoom_in"
|
||||
const CAMERA_ZOOM_OUT := &"openwc_player_camera_zoom_out"
|
||||
const RELEASE_CURSOR := &"openwc_player_release_cursor"
|
||||
|
||||
const REQUIRED_ACTIONS: Array[StringName] = [
|
||||
MOVE_FORWARD,
|
||||
MOVE_BACKWARD,
|
||||
STRAFE_LEFT,
|
||||
STRAFE_RIGHT,
|
||||
DEBUG_FLY_UP,
|
||||
DEBUG_FLY_DOWN,
|
||||
DEBUG_SPRINT,
|
||||
DEBUG_TOGGLE_FLIGHT,
|
||||
CAMERA_ROTATE,
|
||||
CAMERA_ZOOM_IN,
|
||||
CAMERA_ZOOM_OUT,
|
||||
RELEASE_CURSOR,
|
||||
]
|
||||
@@ -0,0 +1 @@
|
||||
uid://bbhtyxm428bkm
|
||||
@@ -0,0 +1,45 @@
|
||||
class_name PlayerInputSource
|
||||
extends RefCounted
|
||||
|
||||
## Converts remappable Godot Input Map actions into immutable [MoveIntent] values.
|
||||
## This adapter owns no movement state and may be replaced independently of the
|
||||
## local movement controller.
|
||||
|
||||
|
||||
## Samples the current Input singleton state for one physics tick.
|
||||
func sample_move_intent() -> MoveIntent:
|
||||
return compose_move_intent(
|
||||
Input.get_action_strength(PlayerInputActions.MOVE_FORWARD),
|
||||
Input.get_action_strength(PlayerInputActions.MOVE_BACKWARD),
|
||||
Input.get_action_strength(PlayerInputActions.STRAFE_LEFT),
|
||||
Input.get_action_strength(PlayerInputActions.STRAFE_RIGHT),
|
||||
Input.get_action_strength(PlayerInputActions.DEBUG_FLY_UP),
|
||||
Input.get_action_strength(PlayerInputActions.DEBUG_FLY_DOWN),
|
||||
Input.is_action_pressed(PlayerInputActions.DEBUG_SPRINT)
|
||||
)
|
||||
|
||||
|
||||
## Builds a normalized intent from action strengths for deterministic tests and
|
||||
## alternative input adapters. Strengths outside `[0, 1]` are clamped.
|
||||
static func compose_move_intent(
|
||||
forward_strength: float,
|
||||
backward_strength: float,
|
||||
strafe_left_strength: float,
|
||||
strafe_right_strength: float,
|
||||
fly_up_strength: float,
|
||||
fly_down_strength: float,
|
||||
sprint_requested: bool
|
||||
) -> MoveIntent:
|
||||
var planar_axis := Vector2(
|
||||
clampf(strafe_right_strength, 0.0, 1.0) - clampf(strafe_left_strength, 0.0, 1.0),
|
||||
clampf(forward_strength, 0.0, 1.0) - clampf(backward_strength, 0.0, 1.0)
|
||||
)
|
||||
if planar_axis.length_squared() > 1.0:
|
||||
planar_axis = planar_axis.normalized()
|
||||
var vertical_axis := clampf(fly_up_strength, 0.0, 1.0) - clampf(fly_down_strength, 0.0, 1.0)
|
||||
return MoveIntent.new(
|
||||
planar_axis.y,
|
||||
planar_axis.x,
|
||||
vertical_axis,
|
||||
sprint_requested
|
||||
)
|
||||
@@ -0,0 +1 @@
|
||||
uid://b050i2lnei8qq
|
||||
Reference in New Issue
Block a user