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="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="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="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://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"]
|
||||
@ -49,6 +50,7 @@ aim_released = ExtResource("8_lhb11")
|
||||
aim_canceled = ExtResource("9_5p2qc")
|
||||
jump = ExtResource("10_4u7i3")
|
||||
hit = ExtResource("11_cresl")
|
||||
drop = ExtResource("12_34snm")
|
||||
|
||||
[node name="MeshInstance3D" type="MeshInstance3D" parent="."]
|
||||
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_right = -2.0
|
||||
offset_bottom = 1.0
|
||||
enabled = false
|
||||
initial_node_to_watch = NodePath("../StateChart")
|
||||
|
||||
[node name="WeaponRoot" type="Node3D" parent="."]
|
||||
@ -138,6 +139,7 @@ ThrowForce = 25.0
|
||||
StraightThrowDuration = 0.07
|
||||
|
||||
[node name="CoyoteTime" type="Timer" parent="."]
|
||||
wait_time = 0.2
|
||||
|
||||
[node name="StateChart" type="Node" parent="."]
|
||||
script = ExtResource("25_wv70j")
|
||||
@ -199,7 +201,7 @@ delay_in_seconds = "0.0"
|
||||
[node name="WeaponThrown" type="Node" parent="StateChart/Root/Actions"]
|
||||
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")
|
||||
to = NodePath("../../Dashing")
|
||||
event = &"aim_pressed"
|
||||
@ -208,22 +210,46 @@ delay_in_seconds = "0.0"
|
||||
[node name="Hanging" type="Node" parent="StateChart/Root/Actions"]
|
||||
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")
|
||||
to = NodePath("../../WeaponInHand")
|
||||
event = &"jump"
|
||||
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"]
|
||||
script = ExtResource("26_infe6")
|
||||
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"]
|
||||
script = ExtResource("27_34snm")
|
||||
|
||||
[node name="OnJump" type="Node" parent="StateChart/Root/Movement/Grounded"]
|
||||
script = ExtResource("28_n7qhm")
|
||||
to = NodePath("../../Airborne/DoubleJumpEnabled")
|
||||
to = NodePath("../../Airborne/Jump")
|
||||
event = &"jump"
|
||||
delay_in_seconds = "0.0"
|
||||
|
||||
@ -233,28 +259,43 @@ to = NodePath("../../Airborne/CoyoteEnabled")
|
||||
event = &"start_falling"
|
||||
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"]
|
||||
script = ExtResource("27_34snm")
|
||||
|
||||
[node name="OnJump" type="Node" parent="StateChart/Root/Movement/Hanging"]
|
||||
script = ExtResource("28_n7qhm")
|
||||
to = NodePath("../../Airborne/DoubleJumpEnabled")
|
||||
to = NodePath("../../Airborne/Jump")
|
||||
event = &"jump"
|
||||
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"]
|
||||
script = ExtResource("27_34snm")
|
||||
|
||||
[node name="OnJump" type="Node" parent="StateChart/Root/Movement/WallHugging"]
|
||||
script = ExtResource("28_n7qhm")
|
||||
to = NodePath("../../Airborne/DoubleJumpEnabled")
|
||||
to = NodePath("../../Airborne/Jump")
|
||||
event = &"jump"
|
||||
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")
|
||||
to = NodePath("../../Airborne/CoyoteEnabled")
|
||||
event = &"start_falling"
|
||||
event = &"drop"
|
||||
delay_in_seconds = "0.0"
|
||||
|
||||
[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"]
|
||||
script = ExtResource("28_n7qhm")
|
||||
to = NodePath("../../DoubleJumpEnabled")
|
||||
to = NodePath("../../Jump")
|
||||
event = &"jump"
|
||||
delay_in_seconds = "0.0"
|
||||
|
||||
@ -282,21 +323,40 @@ to = NodePath("../../DoubleJumpEnabled")
|
||||
event = &"coyote_expired"
|
||||
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"]
|
||||
script = ExtResource("27_34snm")
|
||||
|
||||
[node name="OnJump" type="Node" parent="StateChart/Root/Movement/Airborne/DoubleJumpEnabled"]
|
||||
script = ExtResource("28_n7qhm")
|
||||
to = NodePath("../../Falling")
|
||||
to = NodePath("../../DoubleJump")
|
||||
event = &"jump"
|
||||
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"]
|
||||
script = ExtResource("27_34snm")
|
||||
|
||||
[connection signal="input_aim_canceled" from="InputController" to="." method="OnInputAimCanceled"]
|
||||
[connection signal="input_aim_pressed" from="InputController" to="." method="OnInputAimPressed"]
|
||||
[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_jump" from="InputController" to="." method="OnInputJumpPressed"]
|
||||
[connection signal="input_move" from="InputController" to="." method="OnInputMove"]
|
||||
|
@ -40,6 +40,8 @@ public partial class PlayerController : CharacterBody3D
|
||||
private bool _isAiming;
|
||||
private bool _dashCanceled;
|
||||
|
||||
private Timer _coyoteTimer;
|
||||
|
||||
private StateChart _playerState;
|
||||
// Actions state
|
||||
private StateChartState _weaponInHand;
|
||||
@ -49,11 +51,14 @@ public partial class PlayerController : CharacterBody3D
|
||||
private StateChartState _actionHanging;
|
||||
// Movement state
|
||||
private StateChartState _grounded;
|
||||
private StateChartState _mantling;
|
||||
private StateChartState _movHanging;
|
||||
private StateChartState _wallHugging;
|
||||
private StateChartState _airborne;
|
||||
private StateChartState _coyoteEnabled;
|
||||
private StateChartState _jump;
|
||||
private StateChartState _doubleJumpEnabled;
|
||||
private StateChartState _doubleJump;
|
||||
private StateChartState _falling;
|
||||
|
||||
public override void _Ready()
|
||||
@ -110,12 +115,17 @@ public partial class PlayerController : CharacterBody3D
|
||||
_actionHanging = StateChartState.Of(GetNode("StateChart/Root/Actions/Hanging"));
|
||||
// Movement states
|
||||
_grounded = StateChartState.Of(GetNode("StateChart/Root/Movement/Grounded"));
|
||||
_mantling = StateChartState.Of(GetNode("StateChart/Root/Movement/Mantling"));
|
||||
_movHanging = StateChartState.Of(GetNode("StateChart/Root/Movement/Hanging"));
|
||||
_wallHugging = StateChartState.Of(GetNode("StateChart/Root/Movement/WallHugging"));
|
||||
_airborne = StateChartState.Of(GetNode("StateChart/Root/Movement/Airborne"));
|
||||
_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"));
|
||||
_doubleJump = StateChartState.Of(GetNode("StateChart/Root/Movement/Airborne/DoubleJump"));
|
||||
_falling = StateChartState.Of(GetNode("StateChart/Root/Movement/Airborne/Falling"));
|
||||
// State timers
|
||||
_coyoteTimer = GetNode<Timer>("CoyoteTime");
|
||||
|
||||
///////////////////////////
|
||||
// Initialize components //
|
||||
@ -130,7 +140,6 @@ public partial class PlayerController : CharacterBody3D
|
||||
FieldOfView.Init(camera);
|
||||
|
||||
// Movement stuff
|
||||
|
||||
// Getting universal setting from GODOT editor to be in sync
|
||||
float gravitySetting = (float)ProjectSettings.GetSetting("physics/3d/default_gravity");
|
||||
Gravity.Init(gravitySetting);
|
||||
@ -161,11 +170,114 @@ public partial class PlayerController : CharacterBody3D
|
||||
///////////////////////////
|
||||
|
||||
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;
|
||||
_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()
|
||||
{
|
||||
if (WeaponSystem.FlyingState.Active)
|
||||
@ -180,7 +292,6 @@ public partial class PlayerController : CharacterBody3D
|
||||
_dashDirection = (DashSystem.DashResolve.DashLocation - GlobalPosition).Normalized();
|
||||
DashSystem.Dash();
|
||||
}
|
||||
|
||||
public void OnDashEnded()
|
||||
{
|
||||
// Regular dash
|
||||
@ -211,7 +322,6 @@ public partial class PlayerController : CharacterBody3D
|
||||
|
||||
if (isPlantedOnWall)
|
||||
{
|
||||
MoveSystem.CanDoubleJump = true;
|
||||
_playerState.SendEvent("dash_to_planted");
|
||||
return; // In case states aren't exclusives
|
||||
}
|
||||
@ -219,7 +329,6 @@ public partial class PlayerController : CharacterBody3D
|
||||
// Weapon planted anywhere else
|
||||
_playerState.SendEvent("dash_ended");
|
||||
}
|
||||
|
||||
public void OnWeaponThrown()
|
||||
{
|
||||
RemoveChild(WeaponRoot);
|
||||
@ -232,91 +341,53 @@ public partial class PlayerController : CharacterBody3D
|
||||
DashSystem.CancelDash();
|
||||
WeaponSystem.ThrowWeapon(location, hasHit, collisionPoint, collisionNormal);
|
||||
}
|
||||
|
||||
public void OnInputMove(Vector3 value)
|
||||
{
|
||||
_inputMove = value;
|
||||
}
|
||||
|
||||
public void OnInputRotateY(float value)
|
||||
// Regular processes
|
||||
public void HandleWeaponInHand(float delta)
|
||||
{
|
||||
_inputRotateY = value;
|
||||
RotateWeaponWithPlayer();
|
||||
}
|
||||
|
||||
public void OnInputRotateFloorplane(float value)
|
||||
public void HandleAiming(float delta)
|
||||
{
|
||||
_inputRotateFloorplane = value;
|
||||
RotateWeaponWithPlayer();
|
||||
DashSystem.PrepareDash();
|
||||
}
|
||||
|
||||
public void OnInputAimPressed()
|
||||
// Physics processes
|
||||
public void HandleGrounded(float delta)
|
||||
{
|
||||
_playerState.SendEvent("aim_pressed");
|
||||
if (!isOnFloorCustom())
|
||||
_playerState.SendEvent("start_falling");
|
||||
}
|
||||
public void OnInputAimReleased()
|
||||
public void HandleAirborne(float delta)
|
||||
{
|
||||
_playerState.SendEvent("aim_released");
|
||||
}
|
||||
public void OnInputAimCanceled()
|
||||
{
|
||||
_playerState.SendEvent("aim_canceled");
|
||||
DashSystem.CancelDash();
|
||||
if (isOnFloorCustom())
|
||||
_playerState.SendEvent("grounded");
|
||||
}
|
||||
|
||||
public void OnInputHitPressed()
|
||||
///////////////////////////
|
||||
// Stateless logic ////////
|
||||
///////////////////////////
|
||||
private void LookAround()
|
||||
{
|
||||
_playerState.SendEvent("hit_pressed");
|
||||
Vector2 inputLookDir = new Vector2(_inputRotateY, _inputRotateFloorplane);
|
||||
HeadSystem.LookAround(inputLookDir);
|
||||
}
|
||||
|
||||
public void OnInputJumpPressed()
|
||||
private void MoveAround(double delta)
|
||||
{
|
||||
_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();
|
||||
|
||||
var moveAroundParams = new MoveSystem.MoveAroundParameters(
|
||||
delta,
|
||||
_inputMove,
|
||||
isOnFloorCustom(),
|
||||
isPlayerDead,
|
||||
isHeadTouchingCeiling,
|
||||
HealthSystem.IsDead(),
|
||||
IsHeadTouchingCeiling(),
|
||||
_actionHanging.Active);
|
||||
MoveSystem.MoveAround(moveAroundParams);
|
||||
|
||||
Vector2 inputLookDir = new Vector2(_inputRotateY, _inputRotateFloorplane);
|
||||
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);
|
||||
private void HandleStairs(float delta)
|
||||
{
|
||||
|
||||
StairsSystem.UpStairsCheckParams upStairsCheckParams = new StairsSystem.UpStairsCheckParams
|
||||
{
|
||||
@ -331,11 +402,6 @@ public partial class PlayerController : CharacterBody3D
|
||||
GlobalTransformFromDriver = GlobalTransform,
|
||||
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);
|
||||
|
||||
if (upStairsCheckResult.UpdateRequired)
|
||||
@ -378,6 +444,29 @@ public partial class PlayerController : CharacterBody3D
|
||||
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()
|
||||
{
|
||||
for (int i = 0; i < NUM_OF_HEAD_COLLISION_DETECTORS; i++)
|
||||
@ -395,4 +484,22 @@ public partial class PlayerController : CharacterBody3D
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user