handle unhandled input for `CharacterState`
parent
b79c2d0e3a
commit
05ae280785
|
@ -70,4 +70,6 @@ public abstract partial class CharacterState : Node, IState<CharacterState>
|
|||
}
|
||||
|
||||
public virtual CharacterState Input(InputEvent @event) => null;
|
||||
|
||||
public virtual CharacterState UnhandledInput(InputEvent @event) => null;
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ public abstract partial class PlayerState : CharacterState
|
|||
[Export]
|
||||
public PlayerMaxLevelState MaxLevelState { get; set; }
|
||||
|
||||
public override CharacterState Input(InputEvent @event)
|
||||
public override CharacterState UnhandledInput(InputEvent @event)
|
||||
{
|
||||
var inventory = Character.Inventory;
|
||||
var player = _player;
|
||||
|
@ -60,16 +60,16 @@ public abstract partial class PlayerState : CharacterState
|
|||
}
|
||||
}
|
||||
|
||||
return base.Input(@event);
|
||||
return base.UnhandledInput(@event);
|
||||
}
|
||||
|
||||
public override CharacterState Process(double delta)
|
||||
{
|
||||
Character.Direction = Godot.Input.GetVector("left", "right",
|
||||
"up", "down");
|
||||
Character.LookTowardsDirection();
|
||||
|
||||
var player = _player;
|
||||
|
||||
var desiredTarget = player.GetDesiredInputFromInput();
|
||||
if (!desiredTarget.IsZeroApprox())
|
||||
{
|
||||
|
@ -77,6 +77,8 @@ public abstract partial class PlayerState : CharacterState
|
|||
player.DesiredTarget = desiredTarget;
|
||||
}
|
||||
|
||||
Character.LookTowardsDirection();
|
||||
|
||||
if (Character.Inventory.SelectedItem is Items.Weapon weapon)
|
||||
{
|
||||
var isAttack1On = Godot.Input.IsActionPressed("attack1");
|
||||
|
|
Loading…
Reference in New Issue