WIP Refactoring to movement component hierarchy
This commit is contained in:
@ -55,13 +55,9 @@ func _ready():
|
||||
func _physics_process(delta: float):
|
||||
# 1. Apply Mouse Rotation (Universal head look)
|
||||
_apply_mouse_rotation()
|
||||
|
||||
if eva_suit_component:
|
||||
# Stabilization is handled within eva_suit_component.process_movement
|
||||
eva_suit_component.process_movement(delta, _move_input, _vertical_input, _roll_input, _r_click_input)
|
||||
|
||||
|
||||
if zero_g_movemement_component: # Fallback to ZeroG controller (for initiating reach)
|
||||
zero_g_movemement_component.process_movement(delta, _move_input, _roll_input, _l_click_input, _r_click_input)
|
||||
zero_g_movemement_component.process_movement(delta, _move_input, _vertical_input, _roll_input, _l_click_input, _r_click_input)
|
||||
|
||||
# 3. Integrate Angular Velocity (Universal)
|
||||
_integrate_angular_velocity(delta)
|
||||
|
||||
@ -49,6 +49,24 @@ func process_movement(delta: float, move_input: Vector2, vertical_input: float,
|
||||
# Apply regular movement/torque only if not stabilizing
|
||||
_apply_floating_movement(delta, move_input, vertical_input, roll_input)
|
||||
|
||||
func apply_thrusters(pawn: CharacterPawn3D, delta: float, move_input: Vector2, vertical_input: float, roll_input: float):
|
||||
if not is_instance_valid(pawn) or not camera: return
|
||||
|
||||
# Apply Linear Velocity
|
||||
var camera_forward = -camera.global_transform.basis.z
|
||||
var camera_right = camera.global_transform.basis.x
|
||||
var camera_up = camera.global_transform.basis.y
|
||||
var move_dir_horizontal = (camera_forward * move_input.y + camera_right * move_input.x)
|
||||
var move_dir_vertical = camera_up * vertical_input
|
||||
var combined_move_dir = move_dir_horizontal + move_dir_vertical
|
||||
|
||||
if combined_move_dir != Vector3.ZERO:
|
||||
pawn.velocity += combined_move_dir.normalized() * move_speed * delta
|
||||
|
||||
# Apply Roll Torque
|
||||
var roll_torque_global = pawn.global_transform.basis.z * (roll_input) * roll_torque # Sign fixed
|
||||
pawn.add_torque(roll_torque_global, delta)
|
||||
|
||||
## Called by Pawn to handle collision response in FLOATING state
|
||||
func handle_collision(collision: KinematicCollision3D, collision_energy_loss: float):
|
||||
if not is_instance_valid(pawn): return
|
||||
|
||||
@ -58,7 +58,7 @@ func _ready():
|
||||
# --- Standardized Movement API ---
|
||||
|
||||
## Called by Pawn when relevant state is active (e.g., GRABBING_GRIP, REACHING_MOVE)
|
||||
func process_movement(delta: float, move_input: Vector2, roll_input: float, reach_input: PlayerController3D.KeyInput, release_input: PlayerController3D.KeyInput):
|
||||
func process_movement(delta: float, move_input: Vector2, vertical_input: float, roll_input: float, reach_input: PlayerController3D.KeyInput, release_input: PlayerController3D.KeyInput):
|
||||
if not is_instance_valid(pawn): return
|
||||
|
||||
_update_state(
|
||||
@ -70,8 +70,16 @@ func process_movement(delta: float, move_input: Vector2, roll_input: float, reac
|
||||
|
||||
match current_state:
|
||||
MovementState.IDLE:
|
||||
# If pawn is FLOATING and interact pressed, try initiating a reach
|
||||
pass
|
||||
# State is IDLE (free-floating).
|
||||
# Check for EVA suit usage.
|
||||
var is_moving = (move_input != Vector2.ZERO or vertical_input != 0.0 or roll_input != 0.0)
|
||||
if is_moving and is_instance_valid(pawn.eva_suit_component):
|
||||
# Use EVA suit
|
||||
pawn.eva_suit_component.apply_thrusters(pawn, delta, move_input, vertical_input, roll_input)
|
||||
|
||||
# Check for body orientation (if applicable)
|
||||
if release_input.held and is_instance_valid(pawn.eva_suit_component):
|
||||
pawn.eva_suit_component._orient_pawn(delta) # Use suit's orient
|
||||
MovementState.REACHING:
|
||||
_process_reaching(delta)
|
||||
MovementState.GRIPPING:
|
||||
|
||||
Reference in New Issue
Block a user