Add wait/delay for Doc to exit when attacking

pull/43/head
John Montagu, the 4th Earl of Sandvich 2024-09-16 12:23:32 -07:00
parent abf6316146
commit f5444dd55f
Signed by: sandvich
GPG Key ID: 9A39BE37E602B22D
2 changed files with 20 additions and 11 deletions

View File

@ -804,14 +804,8 @@ script = ExtResource("8_r8ejq")
Hotbar = []
Items = []
[node name="DocLance" parent="Inventory" node_paths=PackedStringArray("Hitbox", "AnimationPlayer", "ParryParticles", "StateMachine", "Anchor", "HandAnchor") instance=ExtResource("24_2es2r")]
[node name="DocLance" parent="Inventory" instance=ExtResource("24_2es2r")]
unique_name_in_owner = true
Hitbox = NodePath("Hitbox")
AnimationPlayer = NodePath("AnimationPlayer")
ParryParticles = NodePath("Anchor/Node2D/Sprite2D/ParryParticles")
StateMachine = NodePath("State")
Anchor = NodePath("Anchor")
HandAnchor = NodePath("Anchor/Node2D/Sprite2D/Hand")
[node name="InteractionTrigger" parent="." instance=ExtResource("33_08dyq")]

View File

@ -15,25 +15,40 @@ public partial class DocExitState : NPCState
private double _currentDuration = 0;
private bool _hasPlayedExitAnim = false;
private bool _previouslyCouldAttack = false;
public override NPCState Enter(IState<NPCState> previousState)
{
_currentDuration = Duration;
TelegraphAnimationPlayer.Play("exit_out");
NPC.ShouldMove = false;
_hasPlayedExitAnim = false;
return null;
}
public override void Exit(IState<NPCState> nextState)
{
NPC.CanAttack = _previouslyCouldAttack;
}
public override NPCState Process(double delta)
{
if (!NPC.Inventory.IsUsingItem)
{
if (!_hasPlayedExitAnim)
{
_hasPlayedExitAnim = true;
_previouslyCouldAttack = NPC.CanAttack;
NPC.CanAttack = false;
TelegraphAnimationPlayer.Play("exit_out");
}
if ((_currentDuration -= delta) <= 0)
{
return TelegraphState;
}
}
return null;
}
}