gd: some weapon planting and dashing
This commit is contained in:
@ -82,6 +82,7 @@ MantleEndLocationDistanceFromWall = 1.0
|
||||
MantleHeightCastStart = 2.0
|
||||
|
||||
[node name="DashSystem" parent="." instance=ExtResource("18_q5h8a")]
|
||||
PostDashSpeed = 68.0
|
||||
|
||||
[node name="Bobbing" type="Node3D" parent="."]
|
||||
script = ExtResource("10_7wk1w")
|
||||
@ -175,6 +176,12 @@ to = NodePath("../../WeaponInHand")
|
||||
event = &"dash_ended"
|
||||
delay_in_seconds = "0.0"
|
||||
|
||||
[node name="ToHanging" type="Node" parent="StateChart/Root/Dashing"]
|
||||
script = ExtResource("28_n7qhm")
|
||||
to = NodePath("../../Hanging")
|
||||
event = &"dash_to_planted"
|
||||
delay_in_seconds = "0.0"
|
||||
|
||||
[node name="WeaponThrown" type="Node" parent="StateChart/Root"]
|
||||
script = ExtResource("27_34snm")
|
||||
|
||||
@ -184,11 +191,21 @@ to = NodePath("../../Dashing")
|
||||
event = &"aim_pressed"
|
||||
delay_in_seconds = "0.0"
|
||||
|
||||
[node name="Hanging" type="Node" parent="StateChart/Root"]
|
||||
script = ExtResource("27_34snm")
|
||||
|
||||
[node name="ToWeaponInHand" type="Node" parent="StateChart/Root/Hanging"]
|
||||
script = ExtResource("28_n7qhm")
|
||||
to = NodePath("../../WeaponInHand")
|
||||
event = &"jump"
|
||||
delay_in_seconds = "0.0"
|
||||
|
||||
[node name="WeaponRoot" type="Node3D" parent="."]
|
||||
|
||||
[node name="WeaponSystem" parent="WeaponRoot" instance=ExtResource("29_wv70j")]
|
||||
transform = Transform3D(1, 0, 0, 0, 0.173648, -0.984808, 0, 0.984808, 0.173648, 0.45268, 1.44035, -0.692528)
|
||||
ThrowForce = 25.0
|
||||
StraightThrowDuration = 0.07
|
||||
|
||||
[connection signal="input_aim_canceled" from="InputController" to="." method="OnInputAimCanceled"]
|
||||
[connection signal="input_aim_pressed" from="InputController" to="." method="OnInputAimPressed"]
|
||||
|
@ -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