making dash through target a dedicated dash action
This commit is contained in:
@@ -1262,6 +1262,13 @@ public partial class PlayerController : CharacterBody3D, IForgeEntity, ICueHandl
|
||||
return;
|
||||
}
|
||||
|
||||
var isInputtingForward = IsPlayerInputtingForward() || GetMoveInput().Length() < Mathf.Epsilon;
|
||||
if (_isEnemyInDashAttackRange && isInputtingForward)
|
||||
{
|
||||
_playerState.SendEvent("dash_attack");
|
||||
return;
|
||||
}
|
||||
|
||||
if (GetMoveInput().Length() < Mathf.Epsilon) return;
|
||||
|
||||
// Buffer dash in case of mantle or inputting dash airborne before touching the ground without air dash available
|
||||
@@ -2400,7 +2407,6 @@ public partial class PlayerController : CharacterBody3D, IForgeEntity, ICueHandl
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (!CloseEnemyDetector.IsColliding())
|
||||
{
|
||||
PlayerUi.SetEnemyTargetProperties(new PlayerUi.TargetProperties(enemyTargetState, positionOnScreen));
|
||||
@@ -2419,15 +2425,15 @@ public partial class PlayerController : CharacterBody3D, IForgeEntity, ICueHandl
|
||||
// var targetDistance = _targetLocation.DistanceTo(GlobalPosition);
|
||||
positionOnScreen = Camera.UnprojectPosition(_targetLocation);
|
||||
|
||||
var wouldKill = false;
|
||||
if (_targetObject is IHealthable h and IDamageable d)
|
||||
{
|
||||
var wouldBeDamage = d.ComputeDamage(new DamageRecord(GlobalPosition, RDamage));
|
||||
if (h.CurrentHealth < wouldBeDamage.Damage.DamageDealt) wouldKill = true;
|
||||
}
|
||||
// var wouldKill = false;
|
||||
// if (_targetObject is IHealthable h and IDamageable d)
|
||||
// {
|
||||
// var wouldBeDamage = d.ComputeDamage(new DamageRecord(GlobalPosition, RDamage));
|
||||
// if (h.CurrentHealth < wouldBeDamage.Damage.DamageDealt) wouldKill = true;
|
||||
// }
|
||||
_isEnemyInDashAttackRange = true;
|
||||
enemyTargetState = wouldKill ? PlayerUi.TargetState.TargetWouldKill : PlayerUi.TargetState.TargetWouldNotKill;
|
||||
PlayerUi.SetEnemyTargetProperties(new PlayerUi.TargetProperties(enemyTargetState, positionOnScreen));
|
||||
// enemyTargetState = wouldKill ? PlayerUi.TargetState.TargetWouldKill : PlayerUi.TargetState.TargetWouldNotKill;
|
||||
PlayerUi.SetEnemyTargetProperties(new PlayerUi.TargetProperties(PlayerUi.TargetState.TargetWouldNotKill, positionOnScreen));
|
||||
}
|
||||
|
||||
public DamageRecord TakeDamage(DamageRecord damageRecord)
|
||||
@@ -2475,11 +2481,10 @@ public partial class PlayerController : CharacterBody3D, IForgeEntity, ICueHandl
|
||||
private PhysicsDirectSpaceState3D _spaceState = null!;
|
||||
public void StartDashAction(bool isParry)
|
||||
{
|
||||
if (isParry) HeadSystem.OnParry();
|
||||
else HeadSystem.OnHit();
|
||||
|
||||
var streamName = isParry ? "parry" : "attacks";
|
||||
_audioStream.SwitchToClipByName(streamName);
|
||||
// if (isParry) HeadSystem.OnParry();
|
||||
// else HeadSystem.OnHit();
|
||||
// var streamName = isParry ? "parry" : "attacks";
|
||||
_audioStream.SwitchToClipByName("dash");
|
||||
IsInvincible = true;
|
||||
|
||||
var plannedDashLocation = _targetLocation + Vector3.Down*_playerHeight/2;
|
||||
@@ -2518,8 +2523,7 @@ public partial class PlayerController : CharacterBody3D, IForgeEntity, ICueHandl
|
||||
{
|
||||
if (_targetObject is IForgeEntity entity)
|
||||
{
|
||||
_hitEnemies.Add(entity);
|
||||
TriggerDamage();
|
||||
TriggerSimpleDashThroughDamage(entity);
|
||||
}
|
||||
if (_targetObject is IStunnable stunnable)
|
||||
{
|
||||
@@ -2529,6 +2533,13 @@ public partial class PlayerController : CharacterBody3D, IForgeEntity, ICueHandl
|
||||
_playerState.SendEvent("attack_finished");
|
||||
}
|
||||
|
||||
public void TriggerSimpleDashThroughDamage(IForgeEntity entity)
|
||||
{
|
||||
// Emulate normal hit
|
||||
_hitEnemies.Add(entity);
|
||||
TriggerDamage();
|
||||
}
|
||||
|
||||
public void OnDashAttackEnded()
|
||||
{
|
||||
StopDashAction();
|
||||
|
||||
Reference in New Issue
Block a user