2025-02-18 17:40:33 +01:00
|
|
|
|
using Godot;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Cirno.Scripts.Components.Actors;
|
|
|
|
|
|
|
|
|
|
|
|
public partial class KeyboardInputProvider : InputProvider
|
|
|
|
|
|
{
|
2025-02-28 22:49:55 +01:00
|
|
|
|
[ExportCategory("Movement")]
|
|
|
|
|
|
[Export]
|
|
|
|
|
|
public string LeftAxisName { get; private set; } = "left";
|
|
|
|
|
|
[Export]
|
|
|
|
|
|
public string RightAxisName { get; private set; } = "right";
|
|
|
|
|
|
[Export]
|
|
|
|
|
|
public string UpAxisName { get; private set; } = "up";
|
|
|
|
|
|
[Export]
|
|
|
|
|
|
public string DownAxisName { get; private set; } = "down";
|
|
|
|
|
|
|
|
|
|
|
|
[ExportCategory("Aiming")]
|
|
|
|
|
|
[Export]
|
|
|
|
|
|
public string LeftAimName { get; private set; } = "aim_left";
|
|
|
|
|
|
[Export]
|
|
|
|
|
|
public string RightAimName { get; private set; } = "aim_right";
|
|
|
|
|
|
[Export]
|
|
|
|
|
|
public string UpAimName { get; private set; } = "aim_up";
|
|
|
|
|
|
[Export]
|
|
|
|
|
|
public string DownAimName { get; private set; } = "aim_down";
|
|
|
|
|
|
|
|
|
|
|
|
[ExportCategory("Action Names")]
|
|
|
|
|
|
[Export] private string _shootActionName = "shoot";
|
|
|
|
|
|
[Export] private string _useActionName = "Use";
|
|
|
|
|
|
[Export] private string _strafeActionName = "strafe";
|
|
|
|
|
|
[Export] private string _nextWeaponActionName = "next_weapon";
|
|
|
|
|
|
[Export] private string _previousWeaponActionName = "previous_weapon";
|
|
|
|
|
|
|
2025-02-18 17:40:33 +01:00
|
|
|
|
public override Vector2 GetMovementInput()
|
|
|
|
|
|
{
|
2025-02-28 22:49:55 +01:00
|
|
|
|
return Input.GetVector(LeftAxisName, RightAxisName, UpAxisName, DownAxisName);
|
2025-02-18 17:40:33 +01:00
|
|
|
|
}
|
2025-02-18 18:18:13 +01:00
|
|
|
|
|
|
|
|
|
|
public override Vector2 GetAimInput()
|
|
|
|
|
|
{
|
2025-02-25 17:29:24 +01:00
|
|
|
|
return GetRightStickInput();
|
2025-02-18 18:18:13 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private Vector2 GetRightStickInput()
|
|
|
|
|
|
{
|
|
|
|
|
|
return new Vector2(
|
2025-02-28 22:49:55 +01:00
|
|
|
|
Input.GetAxis(LeftAimName,RightAimName),
|
|
|
|
|
|
Input.GetAxis(UpAimName, DownAimName)
|
2025-02-18 18:18:13 +01:00
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-02-25 17:29:24 +01:00
|
|
|
|
public override bool GetActionJustPressed(string action)
|
|
|
|
|
|
{
|
|
|
|
|
|
return Input.IsActionJustPressed(action);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override bool GetActionPressed(string action)
|
2025-02-18 18:18:13 +01:00
|
|
|
|
{
|
2025-02-25 17:29:24 +01:00
|
|
|
|
return Input.IsActionPressed(action);
|
2025-02-18 18:18:13 +01:00
|
|
|
|
}
|
2025-02-28 22:49:55 +01:00
|
|
|
|
|
|
|
|
|
|
public override bool GetShootPressed()
|
|
|
|
|
|
{
|
|
|
|
|
|
return GetActionPressed(_shootActionName);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override bool GetUseJustPressed()
|
|
|
|
|
|
{
|
|
|
|
|
|
return GetActionJustPressed(_useActionName);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override bool GetStrafePressed()
|
|
|
|
|
|
{
|
|
|
|
|
|
return GetActionPressed(_strafeActionName);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override bool GetWeaponNextJustPressed()
|
|
|
|
|
|
{
|
|
|
|
|
|
return GetActionJustPressed(_nextWeaponActionName);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override bool GetWeaponPreviousJustPressed()
|
|
|
|
|
|
{
|
|
|
|
|
|
return GetActionJustPressed(_previousWeaponActionName);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-02-18 17:40:33 +01:00
|
|
|
|
}
|