gd: dash target
This commit is contained in:
@ -11,6 +11,7 @@ public partial class PlayerController : CharacterBody3D
|
||||
public Stamina Stamina;
|
||||
public StairsSystem StairsSystem;
|
||||
public MantleSystem MantleSystem;
|
||||
public DashSystem DashSystem;
|
||||
public CapsuleCollider CapsuleCollider;
|
||||
public Gravity Gravity;
|
||||
public HealthSystem HealthSystem;
|
||||
@ -27,8 +28,12 @@ public partial class PlayerController : CharacterBody3D
|
||||
|
||||
[Export(PropertyHint.Range, "0,5,0.1,or_greater")]
|
||||
public float DoubleJumpSpeedFactor { get; set; } = 2f;
|
||||
|
||||
[Export(PropertyHint.Range, "1,50,1,or_greater")]
|
||||
public float ControllerSensitivity { get; set; } = 20f;
|
||||
|
||||
private bool _canDoubleJump = true;
|
||||
private bool _movementEnabled = true;
|
||||
|
||||
private float _currentSpeed;
|
||||
|
||||
@ -95,6 +100,9 @@ public partial class PlayerController : CharacterBody3D
|
||||
|
||||
MantleSystem = GetNode<MantleSystem>("MantleSystem");
|
||||
MantleSystem.Init(wallInFrontCast3D, Head, mantleCast3D);
|
||||
|
||||
DashSystem = GetNode<DashSystem>("DashSystem");
|
||||
DashSystem.Init(Head, camera);
|
||||
|
||||
CapsuleCollider = GetNode<CapsuleCollider>("CapsuleCollider");
|
||||
|
||||
@ -121,8 +129,19 @@ public partial class PlayerController : CharacterBody3D
|
||||
Mouse.Init(Head, camera, HealthSystem.IsDead);
|
||||
}
|
||||
|
||||
private void DisableMovement()
|
||||
{
|
||||
_movementEnabled = false;
|
||||
}
|
||||
public void EnableMovement()
|
||||
{
|
||||
_movementEnabled = true;
|
||||
}
|
||||
|
||||
public override void _PhysicsProcess(double delta)
|
||||
{
|
||||
var dashLocation = DashSystem.PrepareDash().Unwrap();
|
||||
|
||||
var mantleLocationResult = MantleSystem.CheckWallInFront();
|
||||
if (isOnFloorCustom())
|
||||
{
|
||||
@ -143,14 +162,22 @@ public partial class PlayerController : CharacterBody3D
|
||||
|
||||
bool isPlayerDead = HealthSystem.IsDead();
|
||||
|
||||
// Handle Jumping
|
||||
// Handle Jump input
|
||||
if (Input.IsActionJustPressed("jump")
|
||||
&& !doesCapsuleHaveCrouchingHeight
|
||||
&& !isPlayerDead)
|
||||
{
|
||||
if (mantleLocationResult.IsOk(out var mantleLocation))
|
||||
{
|
||||
Position = mantleLocation;
|
||||
Tween tween = GetTree().CreateTween();
|
||||
var duration = 0.1f * mantleLocation.DistanceTo(Position);
|
||||
var callback = new Callable(this, MethodName.EnableMovement);
|
||||
|
||||
tween.TweenProperty(this, "position", mantleLocation, duration);
|
||||
tween.TweenCallback(callback);
|
||||
|
||||
DisableMovement();
|
||||
tween.Play();
|
||||
}
|
||||
else if (isOnFloorCustom())
|
||||
{
|
||||
@ -170,7 +197,6 @@ public partial class PlayerController : CharacterBody3D
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool isHeadTouchingCeiling = IsHeadTouchingCeiling();
|
||||
bool doesCapsuleHaveDefaultHeight = CapsuleCollider.IsDefaultHeight();
|
||||
|
||||
@ -209,6 +235,9 @@ public partial class PlayerController : CharacterBody3D
|
||||
{
|
||||
_currentSpeed = SprintSpeed;
|
||||
}
|
||||
|
||||
Vector2 inputLookDir = Input.GetVector("look_left", "look_right", "look_up", "look_down");
|
||||
Mouse.LookAround(-1 * ControllerSensitivity * inputLookDir);
|
||||
|
||||
// Get the input direction
|
||||
Vector2 inputDir = Input.GetVector("left", "right", "up", "down");
|
||||
|
Reference in New Issue
Block a user