gd: some weapon planting and dashing
This commit is contained in:
@ -25,8 +25,8 @@ public partial class PlayerController : CharacterBody3D
|
||||
private bool _movementEnabled = true;
|
||||
|
||||
private bool _shouldMantle;
|
||||
private Vector3 _dashLocation = Vector3.Zero;
|
||||
private Vector3 _mantleLocation = Vector3.Zero;
|
||||
private Vector3 _dashDirection = Vector3.Zero;
|
||||
|
||||
private float _lastFrameWasOnFloor = -Mathf.Inf;
|
||||
|
||||
@ -45,6 +45,7 @@ public partial class PlayerController : CharacterBody3D
|
||||
private StateChartState _aiming;
|
||||
private StateChartState _dashing;
|
||||
private StateChartState _weaponThrown;
|
||||
private StateChartState _hanging;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
@ -96,6 +97,7 @@ public partial class PlayerController : CharacterBody3D
|
||||
_aiming = StateChartState.Of(GetNode("StateChart/Root/Aiming"));
|
||||
_dashing = StateChartState.Of(GetNode("StateChart/Root/Dashing"));
|
||||
_weaponThrown = StateChartState.Of(GetNode("StateChart/Root/WeaponThrown"));
|
||||
_hanging = StateChartState.Of(GetNode("StateChart/Root/Hanging"));
|
||||
|
||||
///////////////////////////
|
||||
// Initialize components //
|
||||
@ -148,6 +150,16 @@ public partial class PlayerController : CharacterBody3D
|
||||
|
||||
public void OnDashStarted()
|
||||
{
|
||||
if (WeaponSystem.FlyingState.Active)
|
||||
{
|
||||
DashSystem.DashResolve = new DashResolveRecord(false, WeaponSystem.PlayerDashLocation, Vector3.Zero);
|
||||
}
|
||||
else if (WeaponSystem.PlantedState.Active)
|
||||
{
|
||||
// Should we try to resolve with mantle?
|
||||
DashSystem.DashResolve = new DashResolveRecord(false, WeaponSystem.PlayerDashLocation, Vector3.Zero);
|
||||
}
|
||||
_dashDirection = (DashSystem.DashResolve.DashLocation - GlobalPosition).Normalized();
|
||||
DashSystem.Dash();
|
||||
}
|
||||
|
||||
@ -166,14 +178,39 @@ public partial class PlayerController : CharacterBody3D
|
||||
|
||||
public void OnDashEnded()
|
||||
{
|
||||
// Generates an error when dashing normally
|
||||
// This should solve itself when we handle weapon thrown dashes and regular dashes through different states
|
||||
// Regular dash
|
||||
if (WeaponSystem.InHandState.Active)
|
||||
{
|
||||
_playerState.SendEvent("dash_ended");
|
||||
return;
|
||||
}
|
||||
|
||||
// Store the weapon state before resetting it
|
||||
var isPlantedOnWall = WeaponSystem.PlantedState.Active && WeaponSystem.GlobalRotation.Dot(Vector3.Up) < 0.1;
|
||||
var isFlying = WeaponSystem.FlyingState.Active;
|
||||
|
||||
// Get the weapon back
|
||||
GetTree().GetRoot().RemoveChild(WeaponRoot);
|
||||
AddChild(WeaponRoot);
|
||||
|
||||
WeaponRoot.SetGlobalPosition(GlobalPosition);
|
||||
WeaponSystem.ResetWeapon();
|
||||
|
||||
if (isFlying)
|
||||
{
|
||||
var vel = _dashDirection * DashSystem.PostDashSpeed;
|
||||
SetVelocity(vel);
|
||||
_playerState.SendEvent("dash_ended");
|
||||
return; // In case states aren't exclusives
|
||||
}
|
||||
|
||||
if (isPlantedOnWall)
|
||||
{
|
||||
MoveSystem.CanDoubleJump = true;
|
||||
_playerState.SendEvent("dash_to_planted");
|
||||
return; // In case states aren't exclusives
|
||||
}
|
||||
|
||||
// Weapon planted anywhere else
|
||||
_playerState.SendEvent("dash_ended");
|
||||
}
|
||||
|
||||
@ -213,6 +250,7 @@ public partial class PlayerController : CharacterBody3D
|
||||
|
||||
public void OnInputJumpPressed()
|
||||
{
|
||||
_playerState.SendEvent("jump");
|
||||
bool doesCapsuleHaveCrouchingHeight = CapsuleCollider.IsCrouchingHeight();
|
||||
bool isPlayerDead = HealthSystem.IsDead();
|
||||
|
||||
@ -237,7 +275,8 @@ public partial class PlayerController : CharacterBody3D
|
||||
_inputMove,
|
||||
isOnFloorCustom(),
|
||||
isPlayerDead,
|
||||
isHeadTouchingCeiling);
|
||||
isHeadTouchingCeiling,
|
||||
_hanging.Active);
|
||||
MoveSystem.MoveAround(moveAroundParams);
|
||||
|
||||
Vector2 inputLookDir = new Vector2(_inputRotateY, _inputRotateFloorplane);
|
||||
|
Reference in New Issue
Block a user