rename player things
This commit is contained in:
@@ -80,12 +80,12 @@ func _follow(player: Player, delta: float) -> Vector3:
|
||||
if not Player.is_single_player():
|
||||
player_offset.aim_offset = Vector3.ZERO
|
||||
elif player.input_mode_is(Inputer.Mode.KB_MOUSE):
|
||||
player_offset.aim_offset = player.aiming.aim_offset
|
||||
player_offset.aim_offset = player.aimer.aim_offset
|
||||
elif player.input_mode_is(Inputer.Mode.CONTROLLER):
|
||||
var new_aim_offset := (
|
||||
Vector3.ZERO
|
||||
if player.aiming.aim_input.length() == 0
|
||||
else player.aiming.aim_offset
|
||||
if player.aimer.aim_input.length() == 0
|
||||
else player.aimer.aim_offset
|
||||
)
|
||||
player_offset.aim_offset = player_offset.aim_offset.lerp(
|
||||
new_aim_offset, _aim_damping * delta
|
||||
|
||||
@@ -13,8 +13,8 @@ static var instances: Array[Player]
|
||||
@export_group("References")
|
||||
@export var attack: PlayerAttacker
|
||||
@export var stats: PlayerStats
|
||||
@export var movement: PlayerMovementHandler
|
||||
@export var aiming: PlayerAimingHandler
|
||||
@export var mover: PlayerMover
|
||||
@export var aimer: PlayerAimer
|
||||
@export var _cursor: PlayerCursor
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ func _ready() -> void:
|
||||
|
||||
|
||||
func _process(_delta: float) -> void:
|
||||
var aim_pos := global_position + aiming.aim_offset
|
||||
var aim_pos := global_position + aimer.aim_offset
|
||||
Debugger.marker("aim", aim_pos + Vector3.UP)
|
||||
Debugger.vector("aimv", Vector3(aim_pos.x, 0, aim_pos.z), aim_pos + Vector3.UP)
|
||||
|
||||
@@ -39,12 +39,12 @@ func _process(_delta: float) -> void:
|
||||
func _physics_process(delta: float) -> void:
|
||||
_aiming()
|
||||
var can_move := not attack.is_hitting()
|
||||
velocity = movement.movement(velocity, delta, is_on_floor(), can_move)
|
||||
velocity = mover.process_movement(velocity, delta, is_on_floor(), can_move)
|
||||
|
||||
move_and_slide()
|
||||
|
||||
if not attack.is_hitting() and aiming.aim_offset.length() > 0:
|
||||
look_at(global_position + aiming.aim_offset, Vector3.UP, true)
|
||||
if not attack.is_hitting() and aimer.aim_offset.length() > 0:
|
||||
look_at(global_position + aimer.aim_offset, Vector3.UP, true)
|
||||
|
||||
_process_respawning()
|
||||
_cursor.handle_cursor(self, delta)
|
||||
@@ -62,8 +62,8 @@ func _unhandled_input(event: InputEvent) -> void:
|
||||
):
|
||||
return
|
||||
|
||||
aiming.handle_input(event, mode)
|
||||
movement.handle_input(event, mode)
|
||||
aimer.handle_input(event, mode)
|
||||
mover.handle_input(event, mode)
|
||||
|
||||
if event.is_action_pressed("attack"):
|
||||
attack.attack()
|
||||
@@ -78,12 +78,12 @@ func input_mode_is(mode: Inputer.Mode) -> bool:
|
||||
|
||||
func _aiming() -> void:
|
||||
if input_mode_is(Inputer.Mode.CONTROLLER):
|
||||
aiming.controller_aiming(movement.move_input)
|
||||
aimer.aim_controller(mover.move_input)
|
||||
|
||||
if input_mode_is(Inputer.Mode.KB_MOUSE):
|
||||
var mouse_pos := get_viewport().get_mouse_position()
|
||||
if get_viewport().get_visible_rect().has_point(mouse_pos):
|
||||
aiming.mouse_aiming(mouse_pos, global_position, is_on_floor())
|
||||
aimer.aim_mouse(mouse_pos, global_position, is_on_floor())
|
||||
|
||||
|
||||
func _process_respawning() -> void:
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
class_name PlayerAimingHandler
|
||||
class_name PlayerAimer
|
||||
extends Node
|
||||
|
||||
@export var _controller_aim_offset: float = 6
|
||||
@@ -31,7 +31,7 @@ func handle_input(event: InputEvent, mode: Inputer.Mode) -> void:
|
||||
_aim_down = motion_event.get_action_strength("aim_down")
|
||||
|
||||
|
||||
func controller_aiming(move_input: Vector2) -> void:
|
||||
func aim_controller(move_input: Vector2) -> void:
|
||||
if Player.is_single_player():
|
||||
aim_input = Input.get_vector(
|
||||
"aim_left",
|
||||
@@ -58,7 +58,7 @@ func controller_aiming(move_input: Vector2) -> void:
|
||||
)
|
||||
|
||||
|
||||
func mouse_aiming(
|
||||
func aim_mouse(
|
||||
mouse_pos: Vector2, player_position: Vector3, is_on_floor: bool
|
||||
) -> void:
|
||||
var position_y := player_position.y
|
||||
@@ -37,16 +37,16 @@ func _process(_delta: float) -> void:
|
||||
_bone_flipper.flip = _is_left()
|
||||
var has_input_prev := _has_input
|
||||
|
||||
_speed = _player.velocity.length() / _player.movement.move_speed
|
||||
_speed = _player.velocity.length() / _player.mover.move_speed
|
||||
_has_input = (
|
||||
_player.movement.move_input.length() > 0 and not _player.attack.is_hitting()
|
||||
_player.mover.move_input.length() > 0 and not _player.attack.is_hitting()
|
||||
)
|
||||
|
||||
var velocity_relative := _player.to_local(
|
||||
_player.global_position + _player.velocity
|
||||
)
|
||||
var velocity_blend := (
|
||||
Vector2(-velocity_relative.x, velocity_relative.z) / _player.movement.move_speed
|
||||
Vector2(-velocity_relative.x, velocity_relative.z) / _player.mover.move_speed
|
||||
)
|
||||
|
||||
if _is_left():
|
||||
|
||||
@@ -13,7 +13,7 @@ var _side: float = 0
|
||||
|
||||
|
||||
func handle_cursor(player: Player, delta: float) -> void:
|
||||
var cursor_pos_world := player.attack.global_position + player.aiming.aim_offset
|
||||
var cursor_pos_world := player.attack.global_position + player.aimer.aim_offset
|
||||
var cursor_pos_screen := MainCamera.instance.unproject_position(cursor_pos_world)
|
||||
|
||||
var clamp_corner_min := Vector2.ZERO
|
||||
@@ -32,7 +32,7 @@ func handle_cursor(player: Player, delta: float) -> void:
|
||||
_side_change_speed * delta
|
||||
)
|
||||
|
||||
var aim_offset_normalized := player.aiming.aim_offset.normalized()
|
||||
var aim_offset_normalized := player.aimer.aim_offset.normalized()
|
||||
var bat_rotation_point_screen := MainCamera.instance.unproject_position(
|
||||
cursor_pos_world + aim_offset_normalized.rotated(Vector3.UP, _side as float)
|
||||
)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
class_name PlayerMovementHandler
|
||||
class_name PlayerMover
|
||||
extends Node
|
||||
|
||||
@export var move_speed: float = 8
|
||||
@@ -54,7 +54,7 @@ func handle_input(event: InputEvent, mode: Inputer.Mode) -> void:
|
||||
_move_down = motion_event.get_action_strength("move_down")
|
||||
|
||||
|
||||
func movement(
|
||||
func process_movement(
|
||||
velocity: Vector3, delta: float, is_on_floor: bool, can_move: bool
|
||||
) -> Vector3:
|
||||
velocity = _lateral_movement(velocity, delta, can_move)
|
||||
Reference in New Issue
Block a user