Add wait/delay for Doc to exit when attacking
parent
abf6316146
commit
f5444dd55f
|
@ -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")]
|
||||
|
||||
|
|
|
@ -15,24 +15,39 @@ 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 ((_currentDuration -= delta) <= 0)
|
||||
if (!NPC.Inventory.IsUsingItem)
|
||||
{
|
||||
return TelegraphState;
|
||||
if (!_hasPlayedExitAnim)
|
||||
{
|
||||
_hasPlayedExitAnim = true;
|
||||
_previouslyCouldAttack = NPC.CanAttack;
|
||||
NPC.CanAttack = false;
|
||||
TelegraphAnimationPlayer.Play("exit_out");
|
||||
}
|
||||
|
||||
if ((_currentDuration -= delta) <= 0)
|
||||
{
|
||||
return TelegraphState;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue