X-Git-Url: http://git.purplebirdman.com/frog-ninja.git/blobdiff_plain/992458ba0caf1d218a85c4bf10e48fd304c85626..HEAD:/asset/character/player/player.gd diff --git a/asset/character/player/player.gd b/asset/character/player/player.gd index 8666036..02f6288 100644 --- a/asset/character/player/player.gd +++ b/asset/character/player/player.gd @@ -11,52 +11,91 @@ class_name Player ## Human-readable name for UI display @export var display_name := "" -## Ceiling for hit points +## Ceiling for hit points. @export var max_hit_points: float = 100.0 -## Ceiling for stamina points +## Ceiling for stamina points. @export var max_stamina_points: float = 100.0 -## Ceiling for energy points +## Ceiling for energy points. @export var max_energy_points: float = 100.0 -## Rate of stamina regeneration +## Rate of stamina regeneration. @export var stamina_regain_per_sec: float = 80.0 + +@export_group("Camera") + +## Distance that the camera retreats from the player. +## Mostly relevant for the player's own CameraHandler instance. +@export_range(1.0, 10.0) var camera_distance := 4.0 + ## Remaps absolute input relative to current camera. ## Bad idea for robots, good idea for player control! [br] ## [br] ## TODO: Probably should be all managed by the InputHandler! -@export var input_is_relative_to_camera: bool = false +@export var camera_relative_input: bool = false -## Current state name of the PlayerModel state machine. For debugging. -var state_name := "" +@export_group("Movement") -## How long the player has been idle. Populated by the Idle state. -var idle_time := 0.00 +## Rate of speed while walking. +## Used to override the Walk state's default speed. +@export var walk_speed := 5.0 -## Points to the last meaningful movement of the Player. -var last_movement_vector: Vector3 +## Rate of acceleration while doing any sort of movement. +## Used mostly by the Walk state. +@export var acceleration := 20.0 -## For debugging. Records the floor normal. -var floor_normal := Vector3.ZERO +## Rate of rotation while turning. +@export var rotation_speed := 10.0 -## For debugging. How much the immediate slope influences velocity. -var ground_slope_input := 0.0 +## Vertical velocity limit for when a fall should trigger a hard landing. +@export var fall_landing_limit := 3.0 + +## Vertical velocity limit for when a fall should trigger a roll. +@export var fall_roll_limit := 6.0 + + +@export_group("Combat") + +## The time window in seconds for player to escape subsequent hits. +## Used by the Hit state. +@export var hit_escape_window := 1.0 -@export_category("Instance") +@export_group("Resources") -## Current hit points +## Current hit points. @export var hit_points: float = 100.0 -## Current stamina points +## Current stamina points. @export var stamina_points: float = 100.0 -## Current energy points +## Current energy points. @export var energy_points: float = 0.0 +## Current state name of the PlayerModel state machine. +## For debugging. +var state_name := "" + +## How long the player has been idle. +## Populated by the Idle state. +var idle_time := 0.00 + +## Points to the last meaningful movement of the Player. +## Useful for debugging, movement, and targeting. +var last_movement_vector: Vector3 + +## Records the floor normal. +## For debugging. +var floor_normal := Vector3.ZERO + +## How much the immediate slope influences velocity. +## For debugging. +var ground_slope_input := 0.0 + + # onready @onready var input: InputHandler = $Input @onready var model: CharacterModel = $Model @@ -73,13 +112,12 @@ func _ready() -> void: func _physics_process(delta: float) -> void: var input_pkt := input.get_player_input() - if input_is_relative_to_camera: + if camera_relative_input: cameraHandler.update(input_pkt, delta) - cameraHandler.camera_distance = PlayerVariables.camera_distance + velocity.length() / 4 + cameraHandler.camera_distance = camera_distance + velocity.length() / 4 input_pkt.player_movement_direction = cameraHandler.get_xz_direction_relative_to_camera( input_pkt.player_movement_direction ) model.update(input_pkt, delta) - input_pkt.queue_free()