SupaLidlGame/State/Weapon/SwordIdleState.cs

55 lines
1.0 KiB
C#
Raw Permalink Normal View History

2023-05-23 00:23:53 -07:00
using Godot;
2023-06-03 18:21:46 -07:00
namespace SupaLidlGame.State.Weapon;
public partial class SwordIdleState : WeaponState
2023-05-23 00:23:53 -07:00
{
2023-06-03 18:21:46 -07:00
[Export]
2023-08-08 00:54:00 -07:00
public WeaponState UseState { get; set; }
[Export]
public WeaponState UseAltState { get; set; }
2023-05-23 00:23:53 -07:00
2023-06-03 18:21:46 -07:00
[Export]
public SupaLidlGame.Items.Weapons.Sword Sword { get; set; }
2023-05-23 00:23:53 -07:00
2023-06-03 18:21:46 -07:00
private double _attackCooldown;
2023-05-23 00:23:53 -07:00
2023-06-03 18:21:46 -07:00
public override WeaponState Enter(IState<WeaponState> prevState)
{
if (prevState is SwordAttackState)
2023-05-23 00:23:53 -07:00
{
2023-06-03 18:21:46 -07:00
_attackCooldown = Sword.UseTime - Sword.AttackTime;
}
2023-05-28 10:57:23 -07:00
2023-06-03 18:21:46 -07:00
Sword.Visible = !Sword.ShouldHideIdle;
2023-05-28 10:57:23 -07:00
2023-06-03 18:21:46 -07:00
return null;
}
2023-05-23 00:23:53 -07:00
2023-06-03 18:21:46 -07:00
public override void Exit(IState<WeaponState> nextState)
{
Sword.Visible = true;
}
2023-05-28 10:57:23 -07:00
2023-06-03 18:21:46 -07:00
public override WeaponState Use()
{
2023-08-08 00:54:00 -07:00
return UseState;
}
2023-05-23 00:23:53 -07:00
2023-08-08 00:54:00 -07:00
public override WeaponState UseAlt()
{
return UseAltState;
2023-06-03 18:21:46 -07:00
}
2023-05-23 00:23:53 -07:00
2023-06-03 18:21:46 -07:00
public override WeaponState Process(double delta)
{
if (_attackCooldown > 0)
{
_attackCooldown -= delta;
2023-05-23 00:23:53 -07:00
}
2023-06-03 18:21:46 -07:00
return null;
2023-05-23 00:23:53 -07:00
}
}