gd: added the drop action. Set up state managed coyote time, jump, double jump and overall movement.
This commit is contained in:
@ -1,4 +1,4 @@
|
|||||||
[gd_scene load_steps=33 format=3 uid="uid://bei4nhkf8lwdo"]
|
[gd_scene load_steps=34 format=3 uid="uid://bei4nhkf8lwdo"]
|
||||||
|
|
||||||
[ext_resource type="Script" uid="uid://bbbrf5ckydfna" path="res://player_controller/Scripts/PlayerController.cs" id="1_poq2x"]
|
[ext_resource type="Script" uid="uid://bbbrf5ckydfna" path="res://player_controller/Scripts/PlayerController.cs" id="1_poq2x"]
|
||||||
[ext_resource type="Resource" uid="uid://bl5crtu1gkrtr" path="res://systems/inputs/base_mode/base_mode.tres" id="3_cresl"]
|
[ext_resource type="Resource" uid="uid://bl5crtu1gkrtr" path="res://systems/inputs/base_mode/base_mode.tres" id="3_cresl"]
|
||||||
@ -17,6 +17,7 @@
|
|||||||
[ext_resource type="Script" uid="uid://g8idirw62qe0" path="res://player_controller/Scripts/Bobbing.cs" id="10_7wk1w"]
|
[ext_resource type="Script" uid="uid://g8idirw62qe0" path="res://player_controller/Scripts/Bobbing.cs" id="10_7wk1w"]
|
||||||
[ext_resource type="Resource" uid="uid://b5gx3q8nvu72e" path="res://systems/inputs/base_mode/hit.tres" id="11_cresl"]
|
[ext_resource type="Resource" uid="uid://b5gx3q8nvu72e" path="res://systems/inputs/base_mode/hit.tres" id="11_cresl"]
|
||||||
[ext_resource type="PackedScene" uid="uid://0ysqmqphq6mq" path="res://systems/head/head_system.tscn" id="11_rxwoh"]
|
[ext_resource type="PackedScene" uid="uid://0ysqmqphq6mq" path="res://systems/head/head_system.tscn" id="11_rxwoh"]
|
||||||
|
[ext_resource type="Resource" uid="uid://d2r0ur8k3cuu3" path="res://systems/inputs/base_mode/drop.tres" id="12_34snm"]
|
||||||
[ext_resource type="Script" uid="uid://b6k73aj5povgv" path="res://player_controller/Scripts/FieldOfView.cs" id="12_m2mxi"]
|
[ext_resource type="Script" uid="uid://b6k73aj5povgv" path="res://player_controller/Scripts/FieldOfView.cs" id="12_m2mxi"]
|
||||||
[ext_resource type="Script" uid="uid://b5nk6ntlps3x0" path="res://systems/inputs/input_system.gd" id="16_v31n3"]
|
[ext_resource type="Script" uid="uid://b5nk6ntlps3x0" path="res://systems/inputs/input_system.gd" id="16_v31n3"]
|
||||||
[ext_resource type="Resource" uid="uid://htqvokm8mufq" path="res://systems/inputs/base_mode/move.tres" id="17_h6vvl"]
|
[ext_resource type="Resource" uid="uid://htqvokm8mufq" path="res://systems/inputs/base_mode/move.tres" id="17_h6vvl"]
|
||||||
@ -49,6 +50,7 @@ aim_released = ExtResource("8_lhb11")
|
|||||||
aim_canceled = ExtResource("9_5p2qc")
|
aim_canceled = ExtResource("9_5p2qc")
|
||||||
jump = ExtResource("10_4u7i3")
|
jump = ExtResource("10_4u7i3")
|
||||||
hit = ExtResource("11_cresl")
|
hit = ExtResource("11_cresl")
|
||||||
|
drop = ExtResource("12_34snm")
|
||||||
|
|
||||||
[node name="MeshInstance3D" type="MeshInstance3D" parent="."]
|
[node name="MeshInstance3D" type="MeshInstance3D" parent="."]
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0)
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0)
|
||||||
@ -127,7 +129,6 @@ offset_left = 840.0
|
|||||||
offset_top = 1.0
|
offset_top = 1.0
|
||||||
offset_right = -2.0
|
offset_right = -2.0
|
||||||
offset_bottom = 1.0
|
offset_bottom = 1.0
|
||||||
enabled = false
|
|
||||||
initial_node_to_watch = NodePath("../StateChart")
|
initial_node_to_watch = NodePath("../StateChart")
|
||||||
|
|
||||||
[node name="WeaponRoot" type="Node3D" parent="."]
|
[node name="WeaponRoot" type="Node3D" parent="."]
|
||||||
@ -138,6 +139,7 @@ ThrowForce = 25.0
|
|||||||
StraightThrowDuration = 0.07
|
StraightThrowDuration = 0.07
|
||||||
|
|
||||||
[node name="CoyoteTime" type="Timer" parent="."]
|
[node name="CoyoteTime" type="Timer" parent="."]
|
||||||
|
wait_time = 0.2
|
||||||
|
|
||||||
[node name="StateChart" type="Node" parent="."]
|
[node name="StateChart" type="Node" parent="."]
|
||||||
script = ExtResource("25_wv70j")
|
script = ExtResource("25_wv70j")
|
||||||
@ -199,7 +201,7 @@ delay_in_seconds = "0.0"
|
|||||||
[node name="WeaponThrown" type="Node" parent="StateChart/Root/Actions"]
|
[node name="WeaponThrown" type="Node" parent="StateChart/Root/Actions"]
|
||||||
script = ExtResource("27_34snm")
|
script = ExtResource("27_34snm")
|
||||||
|
|
||||||
[node name="ToDashing" type="Node" parent="StateChart/Root/Actions/WeaponThrown"]
|
[node name="OnAim" type="Node" parent="StateChart/Root/Actions/WeaponThrown"]
|
||||||
script = ExtResource("28_n7qhm")
|
script = ExtResource("28_n7qhm")
|
||||||
to = NodePath("../../Dashing")
|
to = NodePath("../../Dashing")
|
||||||
event = &"aim_pressed"
|
event = &"aim_pressed"
|
||||||
@ -208,22 +210,46 @@ delay_in_seconds = "0.0"
|
|||||||
[node name="Hanging" type="Node" parent="StateChart/Root/Actions"]
|
[node name="Hanging" type="Node" parent="StateChart/Root/Actions"]
|
||||||
script = ExtResource("27_34snm")
|
script = ExtResource("27_34snm")
|
||||||
|
|
||||||
[node name="ToWeaponInHand" type="Node" parent="StateChart/Root/Actions/Hanging"]
|
[node name="OnJump" type="Node" parent="StateChart/Root/Actions/Hanging"]
|
||||||
script = ExtResource("28_n7qhm")
|
script = ExtResource("28_n7qhm")
|
||||||
to = NodePath("../../WeaponInHand")
|
to = NodePath("../../WeaponInHand")
|
||||||
event = &"jump"
|
event = &"jump"
|
||||||
delay_in_seconds = "0.0"
|
delay_in_seconds = "0.0"
|
||||||
|
|
||||||
|
[node name="OnDrop" type="Node" parent="StateChart/Root/Actions/Hanging"]
|
||||||
|
script = ExtResource("28_n7qhm")
|
||||||
|
to = NodePath("../../WeaponInHand")
|
||||||
|
event = &"drop"
|
||||||
|
delay_in_seconds = "0.0"
|
||||||
|
|
||||||
|
[node name="OnMantle" type="Node" parent="StateChart/Root/Actions/Hanging"]
|
||||||
|
script = ExtResource("28_n7qhm")
|
||||||
|
to = NodePath("../../WeaponInHand")
|
||||||
|
event = &"mantle"
|
||||||
|
delay_in_seconds = "0.0"
|
||||||
|
|
||||||
[node name="Movement" type="Node" parent="StateChart/Root"]
|
[node name="Movement" type="Node" parent="StateChart/Root"]
|
||||||
script = ExtResource("26_infe6")
|
script = ExtResource("26_infe6")
|
||||||
initial_state = NodePath("Grounded")
|
initial_state = NodePath("Grounded")
|
||||||
|
|
||||||
|
[node name="OnMantle" type="Node" parent="StateChart/Root/Movement"]
|
||||||
|
script = ExtResource("28_n7qhm")
|
||||||
|
to = NodePath("../Mantling")
|
||||||
|
event = &"mantle"
|
||||||
|
delay_in_seconds = "0.0"
|
||||||
|
|
||||||
|
[node name="OnHang" type="Node" parent="StateChart/Root/Movement"]
|
||||||
|
script = ExtResource("28_n7qhm")
|
||||||
|
to = NodePath("../Hanging")
|
||||||
|
event = &"dash_to_planted"
|
||||||
|
delay_in_seconds = "0.0"
|
||||||
|
|
||||||
[node name="Grounded" type="Node" parent="StateChart/Root/Movement"]
|
[node name="Grounded" type="Node" parent="StateChart/Root/Movement"]
|
||||||
script = ExtResource("27_34snm")
|
script = ExtResource("27_34snm")
|
||||||
|
|
||||||
[node name="OnJump" type="Node" parent="StateChart/Root/Movement/Grounded"]
|
[node name="OnJump" type="Node" parent="StateChart/Root/Movement/Grounded"]
|
||||||
script = ExtResource("28_n7qhm")
|
script = ExtResource("28_n7qhm")
|
||||||
to = NodePath("../../Airborne/DoubleJumpEnabled")
|
to = NodePath("../../Airborne/Jump")
|
||||||
event = &"jump"
|
event = &"jump"
|
||||||
delay_in_seconds = "0.0"
|
delay_in_seconds = "0.0"
|
||||||
|
|
||||||
@ -233,28 +259,43 @@ to = NodePath("../../Airborne/CoyoteEnabled")
|
|||||||
event = &"start_falling"
|
event = &"start_falling"
|
||||||
delay_in_seconds = "0.0"
|
delay_in_seconds = "0.0"
|
||||||
|
|
||||||
|
[node name="Mantling" type="Node" parent="StateChart/Root/Movement"]
|
||||||
|
script = ExtResource("27_34snm")
|
||||||
|
|
||||||
|
[node name="ToGrounded" type="Node" parent="StateChart/Root/Movement/Mantling"]
|
||||||
|
script = ExtResource("28_n7qhm")
|
||||||
|
to = NodePath("../../Grounded")
|
||||||
|
event = &"to_grounded"
|
||||||
|
delay_in_seconds = "0.0"
|
||||||
|
|
||||||
[node name="Hanging" type="Node" parent="StateChart/Root/Movement"]
|
[node name="Hanging" type="Node" parent="StateChart/Root/Movement"]
|
||||||
script = ExtResource("27_34snm")
|
script = ExtResource("27_34snm")
|
||||||
|
|
||||||
[node name="OnJump" type="Node" parent="StateChart/Root/Movement/Hanging"]
|
[node name="OnJump" type="Node" parent="StateChart/Root/Movement/Hanging"]
|
||||||
script = ExtResource("28_n7qhm")
|
script = ExtResource("28_n7qhm")
|
||||||
to = NodePath("../../Airborne/DoubleJumpEnabled")
|
to = NodePath("../../Airborne/Jump")
|
||||||
event = &"jump"
|
event = &"jump"
|
||||||
delay_in_seconds = "0.0"
|
delay_in_seconds = "0.0"
|
||||||
|
|
||||||
|
[node name="OnDrop" type="Node" parent="StateChart/Root/Movement/Hanging"]
|
||||||
|
script = ExtResource("28_n7qhm")
|
||||||
|
to = NodePath("../../Airborne/CoyoteEnabled")
|
||||||
|
event = &"drop"
|
||||||
|
delay_in_seconds = "0.0"
|
||||||
|
|
||||||
[node name="WallHugging" type="Node" parent="StateChart/Root/Movement"]
|
[node name="WallHugging" type="Node" parent="StateChart/Root/Movement"]
|
||||||
script = ExtResource("27_34snm")
|
script = ExtResource("27_34snm")
|
||||||
|
|
||||||
[node name="OnJump" type="Node" parent="StateChart/Root/Movement/WallHugging"]
|
[node name="OnJump" type="Node" parent="StateChart/Root/Movement/WallHugging"]
|
||||||
script = ExtResource("28_n7qhm")
|
script = ExtResource("28_n7qhm")
|
||||||
to = NodePath("../../Airborne/DoubleJumpEnabled")
|
to = NodePath("../../Airborne/Jump")
|
||||||
event = &"jump"
|
event = &"jump"
|
||||||
delay_in_seconds = "0.0"
|
delay_in_seconds = "0.0"
|
||||||
|
|
||||||
[node name="OnLeaveWall" type="Node" parent="StateChart/Root/Movement/WallHugging"]
|
[node name="OnDrop" type="Node" parent="StateChart/Root/Movement/WallHugging"]
|
||||||
script = ExtResource("28_n7qhm")
|
script = ExtResource("28_n7qhm")
|
||||||
to = NodePath("../../Airborne/CoyoteEnabled")
|
to = NodePath("../../Airborne/CoyoteEnabled")
|
||||||
event = &"start_falling"
|
event = &"drop"
|
||||||
delay_in_seconds = "0.0"
|
delay_in_seconds = "0.0"
|
||||||
|
|
||||||
[node name="Airborne" type="Node" parent="StateChart/Root/Movement"]
|
[node name="Airborne" type="Node" parent="StateChart/Root/Movement"]
|
||||||
@ -272,7 +313,7 @@ script = ExtResource("27_34snm")
|
|||||||
|
|
||||||
[node name="OnJump" type="Node" parent="StateChart/Root/Movement/Airborne/CoyoteEnabled"]
|
[node name="OnJump" type="Node" parent="StateChart/Root/Movement/Airborne/CoyoteEnabled"]
|
||||||
script = ExtResource("28_n7qhm")
|
script = ExtResource("28_n7qhm")
|
||||||
to = NodePath("../../DoubleJumpEnabled")
|
to = NodePath("../../Jump")
|
||||||
event = &"jump"
|
event = &"jump"
|
||||||
delay_in_seconds = "0.0"
|
delay_in_seconds = "0.0"
|
||||||
|
|
||||||
@ -282,21 +323,40 @@ to = NodePath("../../DoubleJumpEnabled")
|
|||||||
event = &"coyote_expired"
|
event = &"coyote_expired"
|
||||||
delay_in_seconds = "0.0"
|
delay_in_seconds = "0.0"
|
||||||
|
|
||||||
|
[node name="Jump" type="Node" parent="StateChart/Root/Movement/Airborne"]
|
||||||
|
script = ExtResource("27_34snm")
|
||||||
|
|
||||||
|
[node name="ToDoubleJump" type="Node" parent="StateChart/Root/Movement/Airborne/Jump"]
|
||||||
|
script = ExtResource("28_n7qhm")
|
||||||
|
to = NodePath("../../DoubleJumpEnabled")
|
||||||
|
event = &"to_double_jump"
|
||||||
|
delay_in_seconds = "0.0"
|
||||||
|
|
||||||
[node name="DoubleJumpEnabled" type="Node" parent="StateChart/Root/Movement/Airborne"]
|
[node name="DoubleJumpEnabled" type="Node" parent="StateChart/Root/Movement/Airborne"]
|
||||||
script = ExtResource("27_34snm")
|
script = ExtResource("27_34snm")
|
||||||
|
|
||||||
[node name="OnJump" type="Node" parent="StateChart/Root/Movement/Airborne/DoubleJumpEnabled"]
|
[node name="OnJump" type="Node" parent="StateChart/Root/Movement/Airborne/DoubleJumpEnabled"]
|
||||||
script = ExtResource("28_n7qhm")
|
script = ExtResource("28_n7qhm")
|
||||||
to = NodePath("../../Falling")
|
to = NodePath("../../DoubleJump")
|
||||||
event = &"jump"
|
event = &"jump"
|
||||||
delay_in_seconds = "0.0"
|
delay_in_seconds = "0.0"
|
||||||
|
|
||||||
|
[node name="DoubleJump" type="Node" parent="StateChart/Root/Movement/Airborne"]
|
||||||
|
script = ExtResource("27_34snm")
|
||||||
|
|
||||||
|
[node name="ToFalling" type="Node" parent="StateChart/Root/Movement/Airborne/DoubleJump"]
|
||||||
|
script = ExtResource("28_n7qhm")
|
||||||
|
to = NodePath("../../Falling")
|
||||||
|
event = &"to_falling"
|
||||||
|
delay_in_seconds = "0.0"
|
||||||
|
|
||||||
[node name="Falling" type="Node" parent="StateChart/Root/Movement/Airborne"]
|
[node name="Falling" type="Node" parent="StateChart/Root/Movement/Airborne"]
|
||||||
script = ExtResource("27_34snm")
|
script = ExtResource("27_34snm")
|
||||||
|
|
||||||
[connection signal="input_aim_canceled" from="InputController" to="." method="OnInputAimCanceled"]
|
[connection signal="input_aim_canceled" from="InputController" to="." method="OnInputAimCanceled"]
|
||||||
[connection signal="input_aim_pressed" from="InputController" to="." method="OnInputAimPressed"]
|
[connection signal="input_aim_pressed" from="InputController" to="." method="OnInputAimPressed"]
|
||||||
[connection signal="input_aim_released" from="InputController" to="." method="OnInputAimReleased"]
|
[connection signal="input_aim_released" from="InputController" to="." method="OnInputAimReleased"]
|
||||||
|
[connection signal="input_drop" from="InputController" to="." method="OnInputDropPressed"]
|
||||||
[connection signal="input_hit" from="InputController" to="." method="OnInputHitPressed"]
|
[connection signal="input_hit" from="InputController" to="." method="OnInputHitPressed"]
|
||||||
[connection signal="input_jump" from="InputController" to="." method="OnInputJumpPressed"]
|
[connection signal="input_jump" from="InputController" to="." method="OnInputJumpPressed"]
|
||||||
[connection signal="input_move" from="InputController" to="." method="OnInputMove"]
|
[connection signal="input_move" from="InputController" to="." method="OnInputMove"]
|
||||||
|
@ -40,6 +40,8 @@ public partial class PlayerController : CharacterBody3D
|
|||||||
private bool _isAiming;
|
private bool _isAiming;
|
||||||
private bool _dashCanceled;
|
private bool _dashCanceled;
|
||||||
|
|
||||||
|
private Timer _coyoteTimer;
|
||||||
|
|
||||||
private StateChart _playerState;
|
private StateChart _playerState;
|
||||||
// Actions state
|
// Actions state
|
||||||
private StateChartState _weaponInHand;
|
private StateChartState _weaponInHand;
|
||||||
@ -49,11 +51,14 @@ public partial class PlayerController : CharacterBody3D
|
|||||||
private StateChartState _actionHanging;
|
private StateChartState _actionHanging;
|
||||||
// Movement state
|
// Movement state
|
||||||
private StateChartState _grounded;
|
private StateChartState _grounded;
|
||||||
|
private StateChartState _mantling;
|
||||||
private StateChartState _movHanging;
|
private StateChartState _movHanging;
|
||||||
private StateChartState _wallHugging;
|
private StateChartState _wallHugging;
|
||||||
private StateChartState _airborne;
|
private StateChartState _airborne;
|
||||||
private StateChartState _coyoteEnabled;
|
private StateChartState _coyoteEnabled;
|
||||||
|
private StateChartState _jump;
|
||||||
private StateChartState _doubleJumpEnabled;
|
private StateChartState _doubleJumpEnabled;
|
||||||
|
private StateChartState _doubleJump;
|
||||||
private StateChartState _falling;
|
private StateChartState _falling;
|
||||||
|
|
||||||
public override void _Ready()
|
public override void _Ready()
|
||||||
@ -110,12 +115,17 @@ public partial class PlayerController : CharacterBody3D
|
|||||||
_actionHanging = StateChartState.Of(GetNode("StateChart/Root/Actions/Hanging"));
|
_actionHanging = StateChartState.Of(GetNode("StateChart/Root/Actions/Hanging"));
|
||||||
// Movement states
|
// Movement states
|
||||||
_grounded = StateChartState.Of(GetNode("StateChart/Root/Movement/Grounded"));
|
_grounded = StateChartState.Of(GetNode("StateChart/Root/Movement/Grounded"));
|
||||||
|
_mantling = StateChartState.Of(GetNode("StateChart/Root/Movement/Mantling"));
|
||||||
_movHanging = StateChartState.Of(GetNode("StateChart/Root/Movement/Hanging"));
|
_movHanging = StateChartState.Of(GetNode("StateChart/Root/Movement/Hanging"));
|
||||||
_wallHugging = StateChartState.Of(GetNode("StateChart/Root/Movement/WallHugging"));
|
_wallHugging = StateChartState.Of(GetNode("StateChart/Root/Movement/WallHugging"));
|
||||||
_airborne = StateChartState.Of(GetNode("StateChart/Root/Movement/Airborne"));
|
_airborne = StateChartState.Of(GetNode("StateChart/Root/Movement/Airborne"));
|
||||||
_coyoteEnabled = StateChartState.Of(GetNode("StateChart/Root/Movement/Airborne/CoyoteEnabled"));
|
_coyoteEnabled = StateChartState.Of(GetNode("StateChart/Root/Movement/Airborne/CoyoteEnabled"));
|
||||||
|
_jump = StateChartState.Of(GetNode("StateChart/Root/Movement/Airborne/Jump"));
|
||||||
_doubleJumpEnabled = StateChartState.Of(GetNode("StateChart/Root/Movement/Airborne/DoubleJumpEnabled"));
|
_doubleJumpEnabled = StateChartState.Of(GetNode("StateChart/Root/Movement/Airborne/DoubleJumpEnabled"));
|
||||||
|
_doubleJump = StateChartState.Of(GetNode("StateChart/Root/Movement/Airborne/DoubleJump"));
|
||||||
_falling = StateChartState.Of(GetNode("StateChart/Root/Movement/Airborne/Falling"));
|
_falling = StateChartState.Of(GetNode("StateChart/Root/Movement/Airborne/Falling"));
|
||||||
|
// State timers
|
||||||
|
_coyoteTimer = GetNode<Timer>("CoyoteTime");
|
||||||
|
|
||||||
///////////////////////////
|
///////////////////////////
|
||||||
// Initialize components //
|
// Initialize components //
|
||||||
@ -130,7 +140,6 @@ public partial class PlayerController : CharacterBody3D
|
|||||||
FieldOfView.Init(camera);
|
FieldOfView.Init(camera);
|
||||||
|
|
||||||
// Movement stuff
|
// Movement stuff
|
||||||
|
|
||||||
// Getting universal setting from GODOT editor to be in sync
|
// Getting universal setting from GODOT editor to be in sync
|
||||||
float gravitySetting = (float)ProjectSettings.GetSetting("physics/3d/default_gravity");
|
float gravitySetting = (float)ProjectSettings.GetSetting("physics/3d/default_gravity");
|
||||||
Gravity.Init(gravitySetting);
|
Gravity.Init(gravitySetting);
|
||||||
@ -162,10 +171,113 @@ public partial class PlayerController : CharacterBody3D
|
|||||||
|
|
||||||
DashSystem.DashEnded += OnDashEnded;
|
DashSystem.DashEnded += OnDashEnded;
|
||||||
|
|
||||||
|
_weaponInHand.StateProcessing += HandleWeaponInHand;
|
||||||
|
_aiming.StateProcessing += HandleAiming;
|
||||||
|
|
||||||
|
_grounded.StatePhysicsProcessing += HandleGrounded;
|
||||||
|
_airborne.StatePhysicsProcessing += HandleAirborne;
|
||||||
|
_coyoteEnabled.StateEntered += StartCoyoteTime;
|
||||||
|
_coyoteTimer.Timeout += CoyoteExpired;
|
||||||
|
_jump.StateEntered += Jump;
|
||||||
|
_doubleJump.StateEntered += DoubleJump;
|
||||||
|
_mantling.StateEntered += Mantle;
|
||||||
|
|
||||||
_dashing.StateEntered += OnDashStarted;
|
_dashing.StateEntered += OnDashStarted;
|
||||||
_weaponThrown.StateEntered += OnWeaponThrown;
|
_weaponThrown.StateEntered += OnWeaponThrown;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
///////////////////////////
|
||||||
|
// Input Management ///////
|
||||||
|
///////////////////////////
|
||||||
|
public void OnInputMove(Vector3 value)
|
||||||
|
{
|
||||||
|
_inputMove = value;
|
||||||
|
}
|
||||||
|
public void OnInputRotateY(float value)
|
||||||
|
{
|
||||||
|
_inputRotateY = value;
|
||||||
|
}
|
||||||
|
public void OnInputRotateFloorplane(float value)
|
||||||
|
{
|
||||||
|
_inputRotateFloorplane = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void OnInputAimPressed()
|
||||||
|
{
|
||||||
|
_playerState.SendEvent("aim_pressed");
|
||||||
|
}
|
||||||
|
public void OnInputAimReleased()
|
||||||
|
{
|
||||||
|
_playerState.SendEvent("aim_released");
|
||||||
|
}
|
||||||
|
public void OnInputAimCanceled()
|
||||||
|
{
|
||||||
|
_playerState.SendEvent("aim_canceled");
|
||||||
|
DashSystem.CancelDash();
|
||||||
|
}
|
||||||
|
public void OnInputHitPressed()
|
||||||
|
{
|
||||||
|
_playerState.SendEvent("hit_pressed");
|
||||||
|
}
|
||||||
|
public void OnInputJumpPressed()
|
||||||
|
{
|
||||||
|
if (MoveSystem.CanMantle())
|
||||||
|
{
|
||||||
|
_playerState.SendEvent("mantle");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_playerState.SendEvent("jump");
|
||||||
|
}
|
||||||
|
public void OnInputDropPressed()
|
||||||
|
{
|
||||||
|
_playerState.SendEvent("drop");
|
||||||
|
}
|
||||||
|
|
||||||
|
///////////////////////////
|
||||||
|
// Stateful logic /////////
|
||||||
|
///////////////////////////
|
||||||
|
|
||||||
|
// Jumping
|
||||||
|
public void StartCoyoteTime()
|
||||||
|
{
|
||||||
|
_coyoteTimer.Start();
|
||||||
|
}
|
||||||
|
public void CoyoteExpired()
|
||||||
|
{
|
||||||
|
_playerState.SendEvent("coyote_expired");
|
||||||
|
}
|
||||||
|
public void Jump()
|
||||||
|
{
|
||||||
|
_playerState.SendEvent("to_double_jump");
|
||||||
|
PerformJump(false);
|
||||||
|
}
|
||||||
|
public void DoubleJump()
|
||||||
|
{
|
||||||
|
_playerState.SendEvent("to_falling");
|
||||||
|
PerformJump(true);
|
||||||
|
}
|
||||||
|
private void PerformJump(bool isDoubleJump)
|
||||||
|
{
|
||||||
|
bool doesCapsuleHaveCrouchingHeight = CapsuleCollider.IsCrouchingHeight();
|
||||||
|
bool isPlayerDead = HealthSystem.IsDead();
|
||||||
|
if (!doesCapsuleHaveCrouchingHeight && !isPlayerDead)
|
||||||
|
MoveSystem.Jump(isDoubleJump);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mantling
|
||||||
|
public void Mantle()
|
||||||
|
{
|
||||||
|
var optionTween = MoveSystem.Mantle();
|
||||||
|
if (optionTween.IsSome(out var tween))
|
||||||
|
tween.Finished += MantleFinished;
|
||||||
|
}
|
||||||
|
public void MantleFinished()
|
||||||
|
{
|
||||||
|
_playerState.SendEvent("to_grounded");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Dashing and weapon throwing
|
||||||
public void OnDashStarted()
|
public void OnDashStarted()
|
||||||
{
|
{
|
||||||
if (WeaponSystem.FlyingState.Active)
|
if (WeaponSystem.FlyingState.Active)
|
||||||
@ -180,7 +292,6 @@ public partial class PlayerController : CharacterBody3D
|
|||||||
_dashDirection = (DashSystem.DashResolve.DashLocation - GlobalPosition).Normalized();
|
_dashDirection = (DashSystem.DashResolve.DashLocation - GlobalPosition).Normalized();
|
||||||
DashSystem.Dash();
|
DashSystem.Dash();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnDashEnded()
|
public void OnDashEnded()
|
||||||
{
|
{
|
||||||
// Regular dash
|
// Regular dash
|
||||||
@ -211,7 +322,6 @@ public partial class PlayerController : CharacterBody3D
|
|||||||
|
|
||||||
if (isPlantedOnWall)
|
if (isPlantedOnWall)
|
||||||
{
|
{
|
||||||
MoveSystem.CanDoubleJump = true;
|
|
||||||
_playerState.SendEvent("dash_to_planted");
|
_playerState.SendEvent("dash_to_planted");
|
||||||
return; // In case states aren't exclusives
|
return; // In case states aren't exclusives
|
||||||
}
|
}
|
||||||
@ -219,7 +329,6 @@ public partial class PlayerController : CharacterBody3D
|
|||||||
// Weapon planted anywhere else
|
// Weapon planted anywhere else
|
||||||
_playerState.SendEvent("dash_ended");
|
_playerState.SendEvent("dash_ended");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnWeaponThrown()
|
public void OnWeaponThrown()
|
||||||
{
|
{
|
||||||
RemoveChild(WeaponRoot);
|
RemoveChild(WeaponRoot);
|
||||||
@ -233,90 +342,52 @@ public partial class PlayerController : CharacterBody3D
|
|||||||
WeaponSystem.ThrowWeapon(location, hasHit, collisionPoint, collisionNormal);
|
WeaponSystem.ThrowWeapon(location, hasHit, collisionPoint, collisionNormal);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnInputMove(Vector3 value)
|
// Regular processes
|
||||||
|
public void HandleWeaponInHand(float delta)
|
||||||
{
|
{
|
||||||
_inputMove = value;
|
RotateWeaponWithPlayer();
|
||||||
}
|
}
|
||||||
|
public void HandleAiming(float delta)
|
||||||
public void OnInputRotateY(float value)
|
|
||||||
{
|
{
|
||||||
_inputRotateY = value;
|
RotateWeaponWithPlayer();
|
||||||
}
|
|
||||||
|
|
||||||
public void OnInputRotateFloorplane(float value)
|
|
||||||
{
|
|
||||||
_inputRotateFloorplane = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void OnInputAimPressed()
|
|
||||||
{
|
|
||||||
_playerState.SendEvent("aim_pressed");
|
|
||||||
}
|
|
||||||
public void OnInputAimReleased()
|
|
||||||
{
|
|
||||||
_playerState.SendEvent("aim_released");
|
|
||||||
}
|
|
||||||
public void OnInputAimCanceled()
|
|
||||||
{
|
|
||||||
_playerState.SendEvent("aim_canceled");
|
|
||||||
DashSystem.CancelDash();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void OnInputHitPressed()
|
|
||||||
{
|
|
||||||
_playerState.SendEvent("hit_pressed");
|
|
||||||
}
|
|
||||||
|
|
||||||
public void OnInputJumpPressed()
|
|
||||||
{
|
|
||||||
_playerState.SendEvent("jump");
|
|
||||||
bool doesCapsuleHaveCrouchingHeight = CapsuleCollider.IsCrouchingHeight();
|
|
||||||
bool isPlayerDead = HealthSystem.IsDead();
|
|
||||||
|
|
||||||
if (!doesCapsuleHaveCrouchingHeight && !isPlayerDead)
|
|
||||||
MoveSystem.Jump(IsOnFloor());
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void _PhysicsProcess(double delta)
|
|
||||||
{
|
|
||||||
var isPlayerDead = HealthSystem.IsDead();
|
|
||||||
var isHeadTouchingCeiling = IsHeadTouchingCeiling();
|
|
||||||
|
|
||||||
TweenQueueSystem.ProcessTweens();
|
|
||||||
|
|
||||||
if (_weaponInHand.Active || _aiming.Active)
|
|
||||||
WeaponRoot.SetRotation(HeadSystem.Rotation);
|
|
||||||
if (_aiming.Active)
|
|
||||||
DashSystem.PrepareDash();
|
DashSystem.PrepareDash();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Physics processes
|
||||||
|
public void HandleGrounded(float delta)
|
||||||
|
{
|
||||||
|
if (!isOnFloorCustom())
|
||||||
|
_playerState.SendEvent("start_falling");
|
||||||
|
}
|
||||||
|
public void HandleAirborne(float delta)
|
||||||
|
{
|
||||||
|
if (isOnFloorCustom())
|
||||||
|
_playerState.SendEvent("grounded");
|
||||||
|
}
|
||||||
|
|
||||||
|
///////////////////////////
|
||||||
|
// Stateless logic ////////
|
||||||
|
///////////////////////////
|
||||||
|
private void LookAround()
|
||||||
|
{
|
||||||
|
Vector2 inputLookDir = new Vector2(_inputRotateY, _inputRotateFloorplane);
|
||||||
|
HeadSystem.LookAround(inputLookDir);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void MoveAround(double delta)
|
||||||
|
{
|
||||||
var moveAroundParams = new MoveSystem.MoveAroundParameters(
|
var moveAroundParams = new MoveSystem.MoveAroundParameters(
|
||||||
delta,
|
delta,
|
||||||
_inputMove,
|
_inputMove,
|
||||||
isOnFloorCustom(),
|
isOnFloorCustom(),
|
||||||
isPlayerDead,
|
HealthSystem.IsDead(),
|
||||||
isHeadTouchingCeiling,
|
IsHeadTouchingCeiling(),
|
||||||
_actionHanging.Active);
|
_actionHanging.Active);
|
||||||
MoveSystem.MoveAround(moveAroundParams);
|
MoveSystem.MoveAround(moveAroundParams);
|
||||||
|
}
|
||||||
|
|
||||||
Vector2 inputLookDir = new Vector2(_inputRotateY, _inputRotateFloorplane);
|
private void HandleStairs(float delta)
|
||||||
HeadSystem.LookAround(inputLookDir);
|
|
||||||
|
|
||||||
Bobbing.CameraBobbingParams cameraBobbingParams = new Bobbing.CameraBobbingParams
|
|
||||||
{
|
{
|
||||||
Delta = (float)delta,
|
|
||||||
IsOnFloorCustom = isOnFloorCustom(),
|
|
||||||
Velocity = Velocity
|
|
||||||
};
|
|
||||||
Bobbing.PerformCameraBobbing(cameraBobbingParams);
|
|
||||||
|
|
||||||
FieldOfView.FovParameters fovParams = new FieldOfView.FovParameters
|
|
||||||
{
|
|
||||||
IsCrouchingHeight = CapsuleCollider.IsCrouchingHeight(),
|
|
||||||
Delta = (float)delta,
|
|
||||||
SprintSpeed = MoveSystem.SprintSpeed,
|
|
||||||
Velocity = Velocity
|
|
||||||
};
|
|
||||||
FieldOfView.PerformFovAdjustment(fovParams);
|
|
||||||
|
|
||||||
StairsSystem.UpStairsCheckParams upStairsCheckParams = new StairsSystem.UpStairsCheckParams
|
StairsSystem.UpStairsCheckParams upStairsCheckParams = new StairsSystem.UpStairsCheckParams
|
||||||
{
|
{
|
||||||
@ -331,11 +402,6 @@ public partial class PlayerController : CharacterBody3D
|
|||||||
GlobalTransformFromDriver = GlobalTransform,
|
GlobalTransformFromDriver = GlobalTransform,
|
||||||
Rid = GetRid()
|
Rid = GetRid()
|
||||||
};
|
};
|
||||||
|
|
||||||
// TODO: SnapUpStairsCheck influences the ability of player to crouch because of `stepHeightY <= 0.01` part
|
|
||||||
// Ideally, it should not. SnapUpStairsCheck and SnapDownStairsCheck should be called, when player is actually
|
|
||||||
// on the stairs
|
|
||||||
|
|
||||||
StairsSystem.UpStairsCheckResult upStairsCheckResult = StairsSystem.SnapUpStairsCheck(upStairsCheckParams);
|
StairsSystem.UpStairsCheckResult upStairsCheckResult = StairsSystem.SnapUpStairsCheck(upStairsCheckParams);
|
||||||
|
|
||||||
if (upStairsCheckResult.UpdateRequired)
|
if (upStairsCheckResult.UpdateRequired)
|
||||||
@ -378,6 +444,29 @@ public partial class PlayerController : CharacterBody3D
|
|||||||
StairsSystem.SlideCameraSmoothBackToOrigin(slideCameraParams);
|
StairsSystem.SlideCameraSmoothBackToOrigin(slideCameraParams);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void CameraModifications(float delta)
|
||||||
|
{
|
||||||
|
Bobbing.CameraBobbingParams cameraBobbingParams = new Bobbing.CameraBobbingParams
|
||||||
|
{
|
||||||
|
Delta = delta,
|
||||||
|
IsOnFloorCustom = isOnFloorCustom(),
|
||||||
|
Velocity = Velocity
|
||||||
|
};
|
||||||
|
Bobbing.PerformCameraBobbing(cameraBobbingParams);
|
||||||
|
|
||||||
|
FieldOfView.FovParameters fovParams = new FieldOfView.FovParameters
|
||||||
|
{
|
||||||
|
IsCrouchingHeight = CapsuleCollider.IsCrouchingHeight(),
|
||||||
|
Delta = (float)delta,
|
||||||
|
SprintSpeed = MoveSystem.SprintSpeed,
|
||||||
|
Velocity = Velocity
|
||||||
|
};
|
||||||
|
FieldOfView.PerformFovAdjustment(fovParams);
|
||||||
|
}
|
||||||
|
|
||||||
|
///////////////////////////
|
||||||
|
// Helpers ////////////////
|
||||||
|
///////////////////////////
|
||||||
private bool IsHeadTouchingCeiling()
|
private bool IsHeadTouchingCeiling()
|
||||||
{
|
{
|
||||||
for (int i = 0; i < NUM_OF_HEAD_COLLISION_DETECTORS; i++)
|
for (int i = 0; i < NUM_OF_HEAD_COLLISION_DETECTORS; i++)
|
||||||
@ -395,4 +484,22 @@ public partial class PlayerController : CharacterBody3D
|
|||||||
{
|
{
|
||||||
return IsOnFloor() || StairsSystem.WasSnappedToStairsLastFrame();
|
return IsOnFloor() || StairsSystem.WasSnappedToStairsLastFrame();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void RotateWeaponWithPlayer()
|
||||||
|
{
|
||||||
|
WeaponRoot.SetRotation(HeadSystem.Rotation);
|
||||||
|
}
|
||||||
|
|
||||||
|
///////////////////////////
|
||||||
|
// Processes //////////////
|
||||||
|
///////////////////////////
|
||||||
|
public override void _PhysicsProcess(double delta)
|
||||||
|
{
|
||||||
|
TweenQueueSystem.ProcessTweens();
|
||||||
|
|
||||||
|
LookAround();
|
||||||
|
MoveAround(delta);
|
||||||
|
CameraModifications((float) delta);
|
||||||
|
HandleStairs((float) delta);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
[gd_resource type="Resource" script_class="GUIDEMappingContext" load_steps=60 format=3 uid="uid://bl5crtu1gkrtr"]
|
[gd_resource type="Resource" script_class="GUIDEMappingContext" load_steps=65 format=3 uid="uid://bl5crtu1gkrtr"]
|
||||||
|
|
||||||
[ext_resource type="Script" uid="uid://cpplm41b5bt6m" path="res://addons/guide/guide_action_mapping.gd" id="1_qmhk6"]
|
[ext_resource type="Script" uid="uid://cpplm41b5bt6m" path="res://addons/guide/guide_action_mapping.gd" id="1_qmhk6"]
|
||||||
[ext_resource type="Resource" uid="uid://htqvokm8mufq" path="res://systems/inputs/base_mode/move.tres" id="2_g6bbx"]
|
[ext_resource type="Resource" uid="uid://htqvokm8mufq" path="res://systems/inputs/base_mode/move.tres" id="2_g6bbx"]
|
||||||
@ -21,6 +21,7 @@
|
|||||||
[ext_resource type="Script" uid="uid://rvttn472ix6v" path="res://addons/guide/inputs/guide_input_joy_button.gd" id="19_qkgmj"]
|
[ext_resource type="Script" uid="uid://rvttn472ix6v" path="res://addons/guide/inputs/guide_input_joy_button.gd" id="19_qkgmj"]
|
||||||
[ext_resource type="Resource" uid="uid://bdit2jy5gbpts" path="res://systems/inputs/base_mode/jump.tres" id="21_818lq"]
|
[ext_resource type="Resource" uid="uid://bdit2jy5gbpts" path="res://systems/inputs/base_mode/jump.tres" id="21_818lq"]
|
||||||
[ext_resource type="Resource" uid="uid://b5gx3q8nvu72e" path="res://systems/inputs/base_mode/hit.tres" id="22_2hs2y"]
|
[ext_resource type="Resource" uid="uid://b5gx3q8nvu72e" path="res://systems/inputs/base_mode/hit.tres" id="22_2hs2y"]
|
||||||
|
[ext_resource type="Resource" uid="uid://d2r0ur8k3cuu3" path="res://systems/inputs/base_mode/drop.tres" id="22_qmhk6"]
|
||||||
[ext_resource type="Script" uid="uid://dsa1dnifd6w32" path="res://addons/guide/guide_mapping_context.gd" id="23_llfhp"]
|
[ext_resource type="Script" uid="uid://dsa1dnifd6w32" path="res://addons/guide/guide_mapping_context.gd" id="23_llfhp"]
|
||||||
|
|
||||||
[sub_resource type="Resource" id="Resource_vkvga"]
|
[sub_resource type="Resource" id="Resource_vkvga"]
|
||||||
@ -251,8 +252,33 @@ script = ExtResource("1_qmhk6")
|
|||||||
action = ExtResource("22_2hs2y")
|
action = ExtResource("22_2hs2y")
|
||||||
input_mappings = Array[ExtResource("3_yp12v")]([SubResource("Resource_500v3")])
|
input_mappings = Array[ExtResource("3_yp12v")]([SubResource("Resource_500v3")])
|
||||||
|
|
||||||
|
[sub_resource type="Resource" id="Resource_g6bbx"]
|
||||||
|
script = ExtResource("19_qkgmj")
|
||||||
|
button = 1
|
||||||
|
joy_index = -1
|
||||||
|
|
||||||
|
[sub_resource type="Resource" id="Resource_yp12v"]
|
||||||
|
script = ExtResource("15_fykw6")
|
||||||
|
actuation_threshold = 0.5
|
||||||
|
|
||||||
|
[sub_resource type="Resource" id="Resource_1rw8g"]
|
||||||
|
script = ExtResource("3_yp12v")
|
||||||
|
override_action_settings = false
|
||||||
|
is_remappable = false
|
||||||
|
display_name = ""
|
||||||
|
display_category = ""
|
||||||
|
input = SubResource("Resource_g6bbx")
|
||||||
|
modifiers = Array[ExtResource("5_0qat1")]([])
|
||||||
|
triggers = Array[ExtResource("8_2tfaw")]([SubResource("Resource_yp12v")])
|
||||||
|
|
||||||
|
[sub_resource type="Resource" id="Resource_0qat1"]
|
||||||
|
script = ExtResource("1_qmhk6")
|
||||||
|
action = ExtResource("22_qmhk6")
|
||||||
|
input_mappings = Array[ExtResource("3_yp12v")]([SubResource("Resource_1rw8g")])
|
||||||
|
metadata/_guide_input_mappings_collapsed = false
|
||||||
|
|
||||||
[resource]
|
[resource]
|
||||||
script = ExtResource("23_llfhp")
|
script = ExtResource("23_llfhp")
|
||||||
display_name = ""
|
display_name = ""
|
||||||
mappings = Array[ExtResource("1_qmhk6")]([SubResource("Resource_88x08"), SubResource("Resource_tgr2g"), SubResource("Resource_iarn8"), SubResource("Resource_0hmrk"), SubResource("Resource_iihs4"), SubResource("Resource_0s4kt"), SubResource("Resource_xt1x5"), SubResource("Resource_ew1hw")])
|
mappings = Array[ExtResource("1_qmhk6")]([SubResource("Resource_88x08"), SubResource("Resource_tgr2g"), SubResource("Resource_iarn8"), SubResource("Resource_0hmrk"), SubResource("Resource_iihs4"), SubResource("Resource_0s4kt"), SubResource("Resource_xt1x5"), SubResource("Resource_ew1hw"), SubResource("Resource_0qat1")])
|
||||||
metadata/_custom_type_script = "uid://dsa1dnifd6w32"
|
metadata/_custom_type_script = "uid://dsa1dnifd6w32"
|
||||||
|
14
systems/inputs/base_mode/drop.tres
Normal file
14
systems/inputs/base_mode/drop.tres
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
[gd_resource type="Resource" script_class="GUIDEAction" load_steps=2 format=3 uid="uid://d2r0ur8k3cuu3"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" uid="uid://cluhc11vixkf1" path="res://addons/guide/guide_action.gd" id="1_3acf8"]
|
||||||
|
|
||||||
|
[resource]
|
||||||
|
script = ExtResource("1_3acf8")
|
||||||
|
name = &""
|
||||||
|
action_value_type = 0
|
||||||
|
block_lower_priority_actions = true
|
||||||
|
emit_as_godot_actions = false
|
||||||
|
is_remappable = false
|
||||||
|
display_name = ""
|
||||||
|
display_category = ""
|
||||||
|
metadata/_custom_type_script = "uid://cluhc11vixkf1"
|
@ -15,6 +15,7 @@ class_name InputController
|
|||||||
@export var aim_canceled:GUIDEAction
|
@export var aim_canceled:GUIDEAction
|
||||||
@export var jump:GUIDEAction
|
@export var jump:GUIDEAction
|
||||||
@export var hit:GUIDEAction
|
@export var hit:GUIDEAction
|
||||||
|
@export var drop:GUIDEAction
|
||||||
|
|
||||||
signal input_move(value: Vector3)
|
signal input_move(value: Vector3)
|
||||||
signal input_rotate_y(value: float)
|
signal input_rotate_y(value: float)
|
||||||
@ -25,6 +26,7 @@ signal input_aim_released
|
|||||||
signal input_aim_canceled
|
signal input_aim_canceled
|
||||||
signal input_jump
|
signal input_jump
|
||||||
signal input_hit
|
signal input_hit
|
||||||
|
signal input_drop
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
GUIDE.enable_mapping_context(base_mode)
|
GUIDE.enable_mapping_context(base_mode)
|
||||||
@ -34,6 +36,10 @@ func _ready() -> void:
|
|||||||
aim_canceled.triggered.connect(on_input_aim_canceled)
|
aim_canceled.triggered.connect(on_input_aim_canceled)
|
||||||
jump.triggered.connect(on_input_jump)
|
jump.triggered.connect(on_input_jump)
|
||||||
hit.triggered.connect(on_input_hit)
|
hit.triggered.connect(on_input_hit)
|
||||||
|
drop.triggered.connect(on_input_drop)
|
||||||
|
|
||||||
|
func on_input_drop():
|
||||||
|
input_drop.emit()
|
||||||
|
|
||||||
func on_input_hit():
|
func on_input_hit():
|
||||||
input_hit.emit()
|
input_hit.emit()
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
using Godot;
|
using Godot;
|
||||||
using Movementtests.player_controller.Scripts;
|
using Movementtests.player_controller.Scripts;
|
||||||
|
using RustyOptions;
|
||||||
|
|
||||||
namespace Movementtests.systems;
|
namespace Movementtests.systems;
|
||||||
|
|
||||||
@ -38,8 +39,6 @@ public partial class MoveSystem : Node3D
|
|||||||
[Export(PropertyHint.Range, "0,5,0.1,or_greater")]
|
[Export(PropertyHint.Range, "0,5,0.1,or_greater")]
|
||||||
public float DoubleJumpSpeedFactor { get; set; } = 2f;
|
public float DoubleJumpSpeedFactor { get; set; } = 2f;
|
||||||
|
|
||||||
public bool CanDoubleJump { get; set; } = true;
|
|
||||||
private float _lastFrameWasOnFloor = -Mathf.Inf;
|
|
||||||
|
|
||||||
private Gravity _gravity;
|
private Gravity _gravity;
|
||||||
private CharacterBody3D _parent;
|
private CharacterBody3D _parent;
|
||||||
@ -82,12 +81,6 @@ public partial class MoveSystem : Node3D
|
|||||||
z: _parent.Velocity.Z);
|
z: _parent.Velocity.Z);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isOnFloor)
|
|
||||||
{
|
|
||||||
_lastFrameWasOnFloor = Engine.GetPhysicsFrames();
|
|
||||||
CanDoubleJump = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// The code below is required to quickly adjust player's position on Y-axis when there's a ceiling on the
|
// The code below is required to quickly adjust player's position on Y-axis when there's a ceiling on the
|
||||||
// trajectory of player's jump and player is standing
|
// trajectory of player's jump and player is standing
|
||||||
if (isHeadTouchingCeiling && doesCapsuleHaveDefaultHeight)
|
if (isHeadTouchingCeiling && doesCapsuleHaveDefaultHeight)
|
||||||
@ -174,29 +167,33 @@ public partial class MoveSystem : Node3D
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Jump(bool isOnFloor)
|
public void Jump(bool isDoubleJump)
|
||||||
|
{
|
||||||
|
var jumpForce = isDoubleJump
|
||||||
|
? _gravity.CalculateJumpForce() * DoubleJumpSpeedFactor
|
||||||
|
: _gravity.CalculateJumpForce();
|
||||||
|
|
||||||
|
_parent.Velocity = new Vector3(
|
||||||
|
x: _parent.Velocity.X,
|
||||||
|
y: jumpForce,
|
||||||
|
z: _parent.Velocity.Z);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool CanMantle()
|
||||||
|
{
|
||||||
|
var mantleLocationResult = _mantleSystem.FindMantleInFrontOfPlayer();
|
||||||
|
return mantleLocationResult.IsSome(out _);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Option<Tween> Mantle()
|
||||||
{
|
{
|
||||||
var mantleLocationResult = _mantleSystem.FindMantleInFrontOfPlayer();
|
var mantleLocationResult = _mantleSystem.FindMantleInFrontOfPlayer();
|
||||||
if (mantleLocationResult.IsSome(out var mantleLocation))
|
if (mantleLocationResult.IsSome(out var mantleLocation))
|
||||||
{
|
{
|
||||||
var duration = 0.1f * mantleLocation.DistanceTo(_parent.Position);
|
var duration = 0.1f * mantleLocation.DistanceTo(_parent.Position);
|
||||||
_tweenQueueSystem.QueueTween(mantleLocation, duration);
|
var tween = _tweenQueueSystem.TweenToLocation(new TweenQueueSystem.TweenInputs(mantleLocation, duration));
|
||||||
|
return tween.Some();
|
||||||
}
|
}
|
||||||
else if (isOnFloor)
|
return Option<Tween>.None;
|
||||||
{
|
|
||||||
_parent.Velocity = new Vector3(
|
|
||||||
x: _parent.Velocity.X,
|
|
||||||
y: _gravity.CalculateJumpForce(),
|
|
||||||
z: _parent.Velocity.Z);
|
|
||||||
}
|
|
||||||
else if (CanDoubleJump)
|
|
||||||
{
|
|
||||||
CanDoubleJump = false;
|
|
||||||
_parent.Velocity = new Vector3(
|
|
||||||
x: _parent.Velocity.X,
|
|
||||||
y: _gravity.CalculateJumpForce() * DoubleJumpSpeedFactor,
|
|
||||||
z: _parent.Velocity.Z);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Reference in New Issue
Block a user