use Player.DesiredTarget
parent
6c5bc4edac
commit
17104e7b74
|
@ -119,4 +119,26 @@ public sealed partial class Player : Character
|
||||||
.WithPitchDeviation(0.125f)
|
.WithPitchDeviation(0.125f)
|
||||||
.Play();
|
.Play();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Vector2 GetDesiredInputFromInput()
|
||||||
|
{
|
||||||
|
Vector2 mousePos = GetGlobalMousePosition();
|
||||||
|
Vector2 dirToMouse = GlobalPosition.DirectionTo(mousePos);
|
||||||
|
Vector2 joystick = Godot.Input.GetVector("look_left", "look_right",
|
||||||
|
"look_up", "look_down");
|
||||||
|
|
||||||
|
var inputMethod = Utils.World.Instance.GlobalState
|
||||||
|
.Settings.InputMethod;
|
||||||
|
switch (inputMethod)
|
||||||
|
{
|
||||||
|
case State.Global.InputMethod.Joystick:
|
||||||
|
if (joystick.IsZeroApprox())
|
||||||
|
{
|
||||||
|
return Direction;
|
||||||
|
}
|
||||||
|
return joystick;
|
||||||
|
default:
|
||||||
|
return dirToMouse;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,10 +55,8 @@ public abstract partial class PlayerState : CharacterState
|
||||||
"up", "down");
|
"up", "down");
|
||||||
Character.LookTowardsDirection();
|
Character.LookTowardsDirection();
|
||||||
|
|
||||||
Vector2 mousePos = Character.GetGlobalMousePosition();
|
var player = _player;
|
||||||
Vector2 dirToMouse = Character.GlobalPosition.DirectionTo(mousePos);
|
player.DesiredTarget = player.GetDesiredInputFromInput();
|
||||||
Vector2 joystick = Godot.Input.GetVector("look_left", "look_right",
|
|
||||||
"look_up", "look_down");
|
|
||||||
|
|
||||||
if (Character.Inventory.SelectedItem is Items.Weapon weapon)
|
if (Character.Inventory.SelectedItem is Items.Weapon weapon)
|
||||||
{
|
{
|
||||||
|
@ -67,24 +65,7 @@ public abstract partial class PlayerState : CharacterState
|
||||||
|
|
||||||
if (!weapon.ShouldHideIdle || isAttack1On)
|
if (!weapon.ShouldHideIdle || isAttack1On)
|
||||||
{
|
{
|
||||||
var inputMethod = Utils.World.Instance.GlobalState
|
player.Target = player.DesiredTarget;
|
||||||
.Settings.InputMethod;
|
|
||||||
switch (inputMethod)
|
|
||||||
{
|
|
||||||
case Global.InputMethod.Joystick:
|
|
||||||
if (joystick.IsZeroApprox())
|
|
||||||
{
|
|
||||||
Character.Target = Character.Direction;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Character.Target = joystick;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
Character.Target = dirToMouse;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isAttack1On)
|
if (isAttack1On)
|
||||||
|
@ -95,7 +76,6 @@ public abstract partial class PlayerState : CharacterState
|
||||||
{
|
{
|
||||||
Character.UseCurrentItemAlt();
|
Character.UseCurrentItemAlt();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return base.Process(delta);
|
return base.Process(delta);
|
||||||
|
|
Loading…
Reference in New Issue