recover weapon if walking on it
This commit is contained in:
@@ -317,6 +317,7 @@ public partial class PlayerController : CharacterBody3D,
|
||||
|
||||
// Timers
|
||||
private Timer _timeScaleAimInAirTimer;
|
||||
private Timer _weaponThrowUncatchableTimer;
|
||||
private Timer _simpleDashCooldownTimer;
|
||||
private Timer _airborneDashCooldownTimer;
|
||||
private Timer _powerCooldownTimer;
|
||||
@@ -516,6 +517,7 @@ public partial class PlayerController : CharacterBody3D,
|
||||
|
||||
// State timers
|
||||
_powerCooldownTimer = GetNode<Timer>("PowerCooldown");
|
||||
_weaponThrowUncatchableTimer = GetNode<Timer>("WeaponThrowUncatchable");
|
||||
_timeScaleAimInAirTimer = GetNode<Timer>("TimeScaleAimInAir");
|
||||
_simpleDashCooldownTimer = GetNode<Timer>("DashCooldown");
|
||||
_airborneDashCooldownTimer = GetNode<Timer>("AirborneDashCooldown");
|
||||
@@ -1892,7 +1894,7 @@ public partial class PlayerController : CharacterBody3D,
|
||||
var plannedDashLocation = targetable.GetTargetGlobalPosition() + Vector3.Down*_playerHeight/2;
|
||||
travel = plannedDashLocation - GlobalPosition;
|
||||
_dashDirection = travel.Normalized();
|
||||
var postDashLocation = plannedDashLocation + 2*_dashDirection;
|
||||
var postDashLocation = plannedDashLocation + _dashDirection;
|
||||
var wallBehindQuery = PhysicsRayQueryParameters3D.Create(GlobalPosition + Vector3.Up*HeadSystem.Position.Y, postDashLocation, GroundDetector.CollisionMask);
|
||||
var wallBehindResult = _spaceState.IntersectRay(wallBehindQuery);
|
||||
shouldRebound = wallBehindResult.Count > 0;
|
||||
@@ -1960,6 +1962,7 @@ public partial class PlayerController : CharacterBody3D,
|
||||
public void ThrowWeapon()
|
||||
{
|
||||
_audioStream.SwitchToClipByName("attacks");
|
||||
_weaponThrowUncatchableTimer.Start();
|
||||
|
||||
_playerState.SendEvent("cancel_aim");
|
||||
RemoveChildNode(WeaponSystem);
|
||||
@@ -1980,6 +1983,7 @@ public partial class PlayerController : CharacterBody3D,
|
||||
HeadSystem.ShowWeapon();
|
||||
WeaponSystem.ResetWeapon();
|
||||
RecoverChildNode(WeaponSystem);
|
||||
_audioStream.SwitchToClipByName("parry");
|
||||
}
|
||||
|
||||
public void DashToFlyingWeapon()
|
||||
@@ -2061,6 +2065,16 @@ public partial class PlayerController : CharacterBody3D,
|
||||
|
||||
_playerState.SendEvent(resultingEvent);
|
||||
}
|
||||
public void WalkOnWeapon(Node3D other)
|
||||
{
|
||||
if (_weaponDash.Active) return; // Don't recover weapon if already dashing to it
|
||||
if (WeaponSystem.InHandState.Active) return; // Don't recover weapon if in hand
|
||||
if (!_weaponThrowUncatchableTimer.IsStopped()) return; // Don't get weapon back if timer is still running
|
||||
if (WeaponSystem.PlantObject is ITargetable) return; // Don't recover weapon planted in target
|
||||
|
||||
RecoverWeapon();
|
||||
WeaponSystem.PlantObject = null;
|
||||
}
|
||||
|
||||
public void ManageAttackedEnemyPostDash(Node enemy)
|
||||
{
|
||||
@@ -2229,7 +2243,7 @@ public partial class PlayerController : CharacterBody3D,
|
||||
var travel = plannedDashLocation - GlobalPosition;
|
||||
_dashDirection = travel.Normalized();
|
||||
|
||||
var postDashLocation = plannedDashLocation + 2*_dashDirection;
|
||||
var postDashLocation = plannedDashLocation + _dashDirection;
|
||||
var wallBehindQuery = PhysicsRayQueryParameters3D.Create(GlobalPosition + Vector3.Up*HeadSystem.Position.Y, postDashLocation, GroundDetector.CollisionMask);
|
||||
var wallBehindResult = _spaceState.IntersectRay(wallBehindQuery);
|
||||
var shouldRebound = wallBehindResult.Count > 0;
|
||||
@@ -2293,7 +2307,7 @@ public partial class PlayerController : CharacterBody3D,
|
||||
|
||||
if (_onWallHanging.Active) return;
|
||||
|
||||
if (_aiming.Active && WeaponSystem.InHandState.Active)
|
||||
if (_aiming.Active && WeaponSystem.InHandState.Active && CanPerformEmpoweredAction())
|
||||
{
|
||||
ThrowWeapon();
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user