Add wait/delay for Doc to exit when attacking
parent
abf6316146
commit
f5444dd55f
|
@ -804,14 +804,8 @@ script = ExtResource("8_r8ejq")
|
||||||
Hotbar = []
|
Hotbar = []
|
||||||
Items = []
|
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
|
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")]
|
[node name="InteractionTrigger" parent="." instance=ExtResource("33_08dyq")]
|
||||||
|
|
||||||
|
|
|
@ -15,25 +15,40 @@ public partial class DocExitState : NPCState
|
||||||
|
|
||||||
private double _currentDuration = 0;
|
private double _currentDuration = 0;
|
||||||
|
|
||||||
|
private bool _hasPlayedExitAnim = false;
|
||||||
|
|
||||||
|
private bool _previouslyCouldAttack = false;
|
||||||
|
|
||||||
public override NPCState Enter(IState<NPCState> previousState)
|
public override NPCState Enter(IState<NPCState> previousState)
|
||||||
{
|
{
|
||||||
_currentDuration = Duration;
|
_currentDuration = Duration;
|
||||||
TelegraphAnimationPlayer.Play("exit_out");
|
|
||||||
NPC.ShouldMove = false;
|
NPC.ShouldMove = false;
|
||||||
|
_hasPlayedExitAnim = false;
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Exit(IState<NPCState> nextState)
|
public override void Exit(IState<NPCState> nextState)
|
||||||
{
|
{
|
||||||
|
NPC.CanAttack = _previouslyCouldAttack;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override NPCState Process(double delta)
|
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)
|
if ((_currentDuration -= delta) <= 0)
|
||||||
{
|
{
|
||||||
return TelegraphState;
|
return TelegraphState;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue