gd: mapped dash actions on guide inputs
This commit is contained in:
@ -126,10 +126,11 @@ target_position = Vector3(0, 1, 0)
|
||||
script = ExtResource("20_rxwoh")
|
||||
WalkSpeed = 10.0
|
||||
SprintSpeed = 15.0
|
||||
DoubleJumpSpeedFactor = 1.4
|
||||
|
||||
[node name="Gravity" type="Node3D" parent="."]
|
||||
script = ExtResource("9_lsueh")
|
||||
Weight = 10.0
|
||||
Weight = 6.5
|
||||
StartVelocity = 4.0
|
||||
|
||||
[node name="TweenQueueSystem" parent="." instance=ExtResource("22_rpwev")]
|
||||
|
@ -14,15 +14,19 @@ public partial class DashSystem: Node3D
|
||||
private Node3D _head;
|
||||
private ShapeCast3D _dashCast3D;
|
||||
private Camera3D _camera;
|
||||
private MeshInstance3D _dashTarget;
|
||||
private TweenQueueSystem _tweenQueueSystem;
|
||||
|
||||
private MantleSystem _mantleSystem;
|
||||
private MeshInstance3D _dashTarget;
|
||||
|
||||
private DashResolve _dashResolve;
|
||||
|
||||
public void Init(Node3D head, Camera3D camera)
|
||||
public void Init(Node3D head, Camera3D camera, TweenQueueSystem tweenQueueSystem)
|
||||
{
|
||||
_dashCast3D = GetNode<ShapeCast3D>("DashCast3D");
|
||||
_head = head;
|
||||
_camera = camera;
|
||||
_tweenQueueSystem = tweenQueueSystem;
|
||||
|
||||
_mantleSystem = GetNode<MantleSystem>("MantleSystem");
|
||||
_mantleSystem.Init(this);
|
||||
@ -69,11 +73,22 @@ public partial class DashSystem: Node3D
|
||||
_dashTarget.SetVisible(true);
|
||||
_dashTarget.SetGlobalPosition(location);
|
||||
|
||||
return new DashResolve(shouldMantle, location, mantleLocation);
|
||||
_dashResolve = new DashResolve(shouldMantle, location, mantleLocation);
|
||||
return _dashResolve;
|
||||
}
|
||||
|
||||
public void CancelDash()
|
||||
{
|
||||
_dashTarget.SetVisible(false);
|
||||
}
|
||||
|
||||
public void Dash()
|
||||
{
|
||||
_dashTarget.SetVisible(false);
|
||||
_tweenQueueSystem.QueueTween(_dashResolve.DashLocation, 0.1f);
|
||||
if (_dashResolve.EndWithMantle)
|
||||
{
|
||||
_tweenQueueSystem.QueueTween(_dashResolve.MantleLocation, 0.1f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -37,6 +37,7 @@ public partial class PlayerController : CharacterBody3D
|
||||
private float _inputRotateFloorplane = 0.0f;
|
||||
|
||||
private bool _isAiming = false;
|
||||
private bool _dashCanceled = false;
|
||||
|
||||
public void OnInputMove(Vector3 value)
|
||||
{
|
||||
@ -55,18 +56,21 @@ public partial class PlayerController : CharacterBody3D
|
||||
|
||||
public void OnInputAimPressed()
|
||||
{
|
||||
_isAiming = true;
|
||||
GD.Print("Aim pressed");
|
||||
if (_dashCanceled)
|
||||
return;
|
||||
|
||||
DashSystem.PrepareDash();
|
||||
}
|
||||
public void OnInputAimReleased()
|
||||
{
|
||||
_isAiming = false;
|
||||
GD.Print("Aim released");
|
||||
if (!_dashCanceled)
|
||||
DashSystem.Dash();
|
||||
_dashCanceled = false;
|
||||
}
|
||||
public void OnInputAimCanceled()
|
||||
{
|
||||
_isAiming = false;
|
||||
GD.Print("Aim canceled");
|
||||
_dashCanceled = true;
|
||||
DashSystem.CancelDash();
|
||||
}
|
||||
|
||||
public void OnInputJumpPressed()
|
||||
@ -144,7 +148,7 @@ public partial class PlayerController : CharacterBody3D
|
||||
StairsSystem.Init(stairsBelowRayCast3D, stairsAheadRayCast3D, cameraSmooth);
|
||||
|
||||
DashSystem = GetNode<DashSystem>("DashSystem");
|
||||
DashSystem.Init(HeadSystem, camera);
|
||||
DashSystem.Init(HeadSystem, camera, TweenQueueSystem);
|
||||
|
||||
HealthSystem = GetNode<HealthSystem>("HealthSystem");
|
||||
|
||||
@ -166,25 +170,17 @@ public partial class PlayerController : CharacterBody3D
|
||||
{
|
||||
TweenQueueSystem.ProcessTweens();
|
||||
|
||||
if (Input.IsActionPressed("aim_dash"))
|
||||
{
|
||||
(_shouldMantle, _dashLocation, _mantleLocation) = DashSystem.PrepareDash();
|
||||
}
|
||||
|
||||
if (Input.IsActionJustReleased("aim_dash"))
|
||||
{
|
||||
DashSystem.Dash();
|
||||
TweenQueueSystem.QueueTween(_dashLocation, 0.1f);
|
||||
if (_shouldMantle)
|
||||
{
|
||||
TweenQueueSystem.QueueTween(_mantleLocation, 0.1f);
|
||||
}
|
||||
}
|
||||
|
||||
var isPlayerDead = HealthSystem.IsDead();
|
||||
var isHeadTouchingCeiling = IsHeadTouchingCeiling();
|
||||
|
||||
MoveSystem.MoveAround(delta, _inputMove, isOnFloorCustom(), isPlayerDead, isHeadTouchingCeiling);
|
||||
|
||||
var moveAroundParams = new MoveSystem.MoveAroundParameters(
|
||||
delta,
|
||||
_inputMove,
|
||||
isOnFloorCustom(),
|
||||
isPlayerDead,
|
||||
isHeadTouchingCeiling);
|
||||
MoveSystem.MoveAround(moveAroundParams);
|
||||
|
||||
Vector2 inputLookDir = new Vector2(_inputRotateY, _inputRotateFloorplane);
|
||||
HeadSystem.LookAround(inputLookDir);
|
||||
|
||||
|
@ -86,7 +86,8 @@ public partial class StairsSystem: Node3D
|
||||
if (parameters.IsCapsuleHeightLessThanNormal)
|
||||
{
|
||||
motionVelocityMultiplier = 1.55f; // Going to crouch mode
|
||||
}else if (parameters.CurrentSpeedGreaterThanWalkSpeed)
|
||||
}
|
||||
else if (parameters.CurrentSpeedGreaterThanWalkSpeed)
|
||||
{
|
||||
motionVelocityMultiplier = 1.1f; // Sprinting
|
||||
}
|
||||
|
Reference in New Issue
Block a user