2023-05-26 22:28:08 -07:00
|
|
|
using Godot;
|
2023-08-08 00:54:00 -07:00
|
|
|
using SupaLidlGame.Extensions;
|
2023-05-26 22:28:08 -07:00
|
|
|
|
2023-06-03 18:21:46 -07:00
|
|
|
namespace SupaLidlGame.State.Weapon;
|
|
|
|
|
|
|
|
public partial class RangedFireState : WeaponState
|
2023-05-26 22:28:08 -07:00
|
|
|
{
|
2023-06-03 18:21:46 -07:00
|
|
|
[Export]
|
|
|
|
public Items.Weapons.Ranged Weapon { get; set; }
|
2023-05-26 22:28:08 -07:00
|
|
|
|
2023-06-03 18:21:46 -07:00
|
|
|
[Export]
|
|
|
|
public RangedIdleState IdleState { get; set; }
|
2023-05-26 22:28:08 -07:00
|
|
|
|
2023-08-08 00:54:00 -07:00
|
|
|
[Export]
|
|
|
|
public AnimationPlayer AnimationPlayer { get; set; }
|
|
|
|
|
|
|
|
[Export]
|
|
|
|
public string AnimationKey { get; set; }
|
|
|
|
|
2023-06-03 18:21:46 -07:00
|
|
|
private double _timeLeft = 0;
|
2023-05-26 22:28:08 -07:00
|
|
|
|
2023-06-03 18:21:46 -07:00
|
|
|
public override IState<WeaponState> Enter(IState<WeaponState> prev)
|
|
|
|
{
|
|
|
|
//_timeLeft
|
|
|
|
_timeLeft = Weapon.UseTime;
|
|
|
|
Weapon.Attack();
|
|
|
|
Weapon.UseDirection = Weapon.Character.Target;
|
2023-08-08 00:54:00 -07:00
|
|
|
AnimationPlayer?.TryPlay(AnimationKey);
|
2023-06-03 18:21:46 -07:00
|
|
|
return null;
|
|
|
|
}
|
2023-05-26 22:28:08 -07:00
|
|
|
|
2023-06-03 18:21:46 -07:00
|
|
|
public override WeaponState Process(double delta)
|
|
|
|
{
|
|
|
|
if ((_timeLeft -= delta) <= 0)
|
2023-05-26 22:28:08 -07:00
|
|
|
{
|
2023-06-03 18:21:46 -07:00
|
|
|
return IdleState;
|
2023-05-26 22:28:08 -07:00
|
|
|
}
|
2023-06-03 18:21:46 -07:00
|
|
|
return null;
|
|
|
|
}
|
2023-05-26 22:28:08 -07:00
|
|
|
|
2023-06-03 18:21:46 -07:00
|
|
|
public override void Exit(IState<WeaponState> nextState)
|
|
|
|
{
|
2023-05-26 22:28:08 -07:00
|
|
|
|
|
|
|
}
|
|
|
|
}
|