2022-11-13 15:42:04 -08:00
|
|
|
using Godot;
|
|
|
|
|
2023-06-03 18:21:46 -07:00
|
|
|
namespace SupaLidlGame.State.Character;
|
|
|
|
|
|
|
|
public partial class PlayerMoveState : PlayerState
|
2022-11-13 15:42:04 -08:00
|
|
|
{
|
2023-06-03 18:21:46 -07:00
|
|
|
[Export]
|
2023-09-16 22:14:23 -07:00
|
|
|
public CharacterState AbilityState { get; set; }
|
2023-07-31 01:12:47 -07:00
|
|
|
|
2023-07-22 20:23:48 -07:00
|
|
|
public double MoveDuration { get; private set; }
|
|
|
|
|
2023-06-03 18:21:46 -07:00
|
|
|
public override IState<CharacterState> Enter(IState<CharacterState> previousState)
|
2022-11-13 15:42:04 -08:00
|
|
|
{
|
2023-07-21 02:54:13 -07:00
|
|
|
_player.MovementAnimation.Play("move");
|
2023-07-22 20:23:48 -07:00
|
|
|
MoveDuration = 0;
|
2023-06-03 18:21:46 -07:00
|
|
|
return base.Enter(previousState);
|
|
|
|
}
|
2022-11-13 15:42:04 -08:00
|
|
|
|
2023-06-03 18:21:46 -07:00
|
|
|
public override CharacterState Process(double delta)
|
|
|
|
{
|
|
|
|
base.Process(delta);
|
2023-07-22 20:23:48 -07:00
|
|
|
MoveDuration += delta;
|
2023-06-03 18:21:46 -07:00
|
|
|
if (Character.Direction.LengthSquared() == 0)
|
2022-11-13 15:42:04 -08:00
|
|
|
{
|
2023-06-03 18:21:46 -07:00
|
|
|
return IdleState;
|
2022-11-13 15:42:04 -08:00
|
|
|
}
|
2023-06-03 18:21:46 -07:00
|
|
|
return null;
|
|
|
|
}
|
2022-11-13 15:42:04 -08:00
|
|
|
|
2023-06-03 18:21:46 -07:00
|
|
|
public override CharacterState Input(InputEvent @event)
|
|
|
|
{
|
|
|
|
if (@event.IsActionPressed("roll"))
|
2022-11-13 15:42:04 -08:00
|
|
|
{
|
2023-06-03 18:21:46 -07:00
|
|
|
if (Character.Inventory.SelectedItem is Items.Weapon weapon)
|
2022-11-13 15:42:04 -08:00
|
|
|
{
|
2023-09-16 22:14:23 -07:00
|
|
|
bool canUseAbility = true;
|
|
|
|
|
|
|
|
if (!AbilityState.CanEnterWhileUsingItem && weapon.IsUsing)
|
|
|
|
{
|
|
|
|
canUseAbility = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (canUseAbility)
|
2022-11-19 21:21:12 -08:00
|
|
|
{
|
2023-09-16 22:14:23 -07:00
|
|
|
return AbilityState;
|
2022-11-19 21:21:12 -08:00
|
|
|
}
|
2022-11-13 15:42:04 -08:00
|
|
|
}
|
2023-06-03 18:21:46 -07:00
|
|
|
else
|
|
|
|
{
|
2023-09-16 22:14:23 -07:00
|
|
|
return AbilityState;
|
2023-06-03 18:21:46 -07:00
|
|
|
}
|
2022-11-13 15:42:04 -08:00
|
|
|
}
|
2023-06-03 18:21:46 -07:00
|
|
|
return base.Input(@event);
|
2022-11-13 15:42:04 -08:00
|
|
|
}
|
|
|
|
}
|