modular movement ability states
parent
42da94cd63
commit
b167354ba7
|
@ -18,6 +18,11 @@ public partial class CharacterDashState : CharacterState
|
||||||
|
|
||||||
public Vector2 DashDirection = Vector2.Zero;
|
public Vector2 DashDirection = Vector2.Zero;
|
||||||
|
|
||||||
|
public CharacterDashState()
|
||||||
|
{
|
||||||
|
CanEnterWhileUsingItem = true;
|
||||||
|
}
|
||||||
|
|
||||||
public override IState<CharacterState> Enter(IState<CharacterState> previousState)
|
public override IState<CharacterState> Enter(IState<CharacterState> previousState)
|
||||||
{
|
{
|
||||||
_timeLeftToDash = TimeToDash;
|
_timeLeftToDash = TimeToDash;
|
||||||
|
|
|
@ -7,6 +7,8 @@ public abstract partial class CharacterState : Node, IState<CharacterState>
|
||||||
[Export]
|
[Export]
|
||||||
public Characters.Character Character { get; set; }
|
public Characters.Character Character { get; set; }
|
||||||
|
|
||||||
|
public bool CanEnterWhileUsingItem { get; set; }
|
||||||
|
|
||||||
public virtual IState<CharacterState> Enter(IState<CharacterState> prev) => null;
|
public virtual IState<CharacterState> Enter(IState<CharacterState> prev) => null;
|
||||||
|
|
||||||
public virtual void Exit(IState<CharacterState> next)
|
public virtual void Exit(IState<CharacterState> next)
|
||||||
|
|
|
@ -5,10 +5,7 @@ namespace SupaLidlGame.State.Character;
|
||||||
public partial class PlayerMoveState : PlayerState
|
public partial class PlayerMoveState : PlayerState
|
||||||
{
|
{
|
||||||
[Export]
|
[Export]
|
||||||
public PlayerRollState RollState { get; set; }
|
public CharacterState AbilityState { get; set; }
|
||||||
|
|
||||||
[Export]
|
|
||||||
public CharacterDashState DashState { get; set; }
|
|
||||||
|
|
||||||
public double MoveDuration { get; private set; }
|
public double MoveDuration { get; private set; }
|
||||||
|
|
||||||
|
@ -36,14 +33,21 @@ public partial class PlayerMoveState : PlayerState
|
||||||
{
|
{
|
||||||
if (Character.Inventory.SelectedItem is Items.Weapon weapon)
|
if (Character.Inventory.SelectedItem is Items.Weapon weapon)
|
||||||
{
|
{
|
||||||
if (!weapon.IsUsing)
|
bool canUseAbility = true;
|
||||||
|
|
||||||
|
if (!AbilityState.CanEnterWhileUsingItem && weapon.IsUsing)
|
||||||
{
|
{
|
||||||
return RollState;
|
canUseAbility = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (canUseAbility)
|
||||||
|
{
|
||||||
|
return AbilityState;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return RollState;
|
return AbilityState;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return base.Input(@event);
|
return base.Input(@event);
|
||||||
|
|
|
@ -10,6 +10,11 @@ public partial class PlayerRollState : PlayerState
|
||||||
|
|
||||||
private GpuParticles2D _particles;
|
private GpuParticles2D _particles;
|
||||||
|
|
||||||
|
public PlayerRollState()
|
||||||
|
{
|
||||||
|
CanEnterWhileUsingItem = false;
|
||||||
|
}
|
||||||
|
|
||||||
public override void _Ready()
|
public override void _Ready()
|
||||||
{
|
{
|
||||||
base._Ready();
|
base._Ready();
|
||||||
|
|
Loading…
Reference in New Issue