2023-07-13 23:46:58 -07:00
|
|
|
using Godot;
|
|
|
|
|
|
|
|
namespace SupaLidlGame.State.NPC.Doc;
|
|
|
|
|
|
|
|
public partial class DocExitState : NPCState
|
|
|
|
{
|
|
|
|
[Export]
|
|
|
|
public AnimationPlayer TelegraphAnimationPlayer { get; set; }
|
|
|
|
|
|
|
|
[Export]
|
|
|
|
public DocTelegraphState TelegraphState { get; set; }
|
|
|
|
|
|
|
|
[Export]
|
|
|
|
public double Duration { get; set; } = 1;
|
|
|
|
|
|
|
|
private double _currentDuration = 0;
|
|
|
|
|
2024-09-16 12:33:29 -07:00
|
|
|
private bool _hasPlayedExitAnim = false;
|
|
|
|
|
|
|
|
private bool _previouslyCouldAttack = false;
|
|
|
|
|
2023-07-13 23:46:58 -07:00
|
|
|
public override NPCState Enter(IState<NPCState> previousState)
|
|
|
|
{
|
|
|
|
_currentDuration = Duration;
|
2023-07-24 21:29:14 -07:00
|
|
|
NPC.ShouldMove = false;
|
2024-09-16 12:33:29 -07:00
|
|
|
_hasPlayedExitAnim = false;
|
2023-07-13 23:46:58 -07:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
public override void Exit(IState<NPCState> nextState)
|
|
|
|
{
|
2024-09-16 12:33:29 -07:00
|
|
|
NPC.CanAttack = _previouslyCouldAttack;
|
2023-07-13 23:46:58 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
public override NPCState Process(double delta)
|
|
|
|
{
|
2024-09-16 12:33:29 -07:00
|
|
|
if (!NPC.Inventory.IsUsingItem)
|
2023-07-13 23:46:58 -07:00
|
|
|
{
|
2024-09-16 12:33:29 -07:00
|
|
|
if (!_hasPlayedExitAnim)
|
|
|
|
{
|
|
|
|
_hasPlayedExitAnim = true;
|
|
|
|
_previouslyCouldAttack = NPC.CanAttack;
|
|
|
|
NPC.CanAttack = false;
|
|
|
|
TelegraphAnimationPlayer.Play("exit_out");
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((_currentDuration -= delta) <= 0)
|
|
|
|
{
|
|
|
|
return TelegraphState;
|
|
|
|
}
|
2023-07-13 23:46:58 -07:00
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|