mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-01 11:15:33 +00:00
109 lines
No EOL
3.1 KiB
C#
109 lines
No EOL
3.1 KiB
C#
using Godot;
|
|
|
|
namespace Cirno.Scripts.Components.Actors;
|
|
|
|
public partial class KeyboardInputProvider : InputProvider
|
|
{
|
|
[ExportCategory("Movement")]
|
|
[Export]
|
|
public StringName LeftAxisName { get; private set; } = "left";
|
|
[Export]
|
|
public StringName RightAxisName { get; private set; } = "right";
|
|
[Export]
|
|
public StringName UpAxisName { get; private set; } = "up";
|
|
[Export]
|
|
public StringName DownAxisName { get; private set; } = "down";
|
|
|
|
[ExportCategory("Aiming")]
|
|
[Export]
|
|
public StringName LeftAimName { get; private set; } = "aim_left";
|
|
[Export]
|
|
public StringName RightAimName { get; private set; } = "aim_right";
|
|
[Export]
|
|
public StringName UpAimName { get; private set; } = "aim_up";
|
|
[Export]
|
|
public StringName DownAimName { get; private set; } = "aim_down";
|
|
|
|
[ExportCategory("Action Names")]
|
|
[Export] private StringName _shootActionName = "shoot";
|
|
[Export] private StringName _useActionName = "Use";
|
|
[Export] private StringName _scanActionName = "scan";
|
|
[Export] private StringName _strafeActionName = "strafe";
|
|
[Export] private StringName _nextWeaponActionName = "next_weapon";
|
|
[Export] private StringName _previousWeaponActionName = "previous_weapon";
|
|
[Export] private StringName _inventoryActionName = "inventory";
|
|
[Export] private StringName _pauseActionName = "pause";
|
|
|
|
public override Vector2 GetMovementInput()
|
|
{
|
|
return Input.GetVector(LeftAxisName, RightAxisName, UpAxisName, DownAxisName);
|
|
}
|
|
|
|
public override Vector2 GetAimInput()
|
|
{
|
|
return GetRightStickInput();
|
|
}
|
|
|
|
private Vector2 GetRightStickInput()
|
|
{
|
|
return new Vector2(
|
|
Input.GetAxis(LeftAimName,RightAimName),
|
|
Input.GetAxis(UpAimName, DownAimName)
|
|
);
|
|
}
|
|
|
|
public override bool GetActionJustPressed(string action)
|
|
{
|
|
return Input.IsActionJustPressed(action);
|
|
}
|
|
|
|
public override bool GetActionPressed(string action)
|
|
{
|
|
return Input.IsActionPressed(action);
|
|
}
|
|
|
|
public override bool GetInventoryJustPressed()
|
|
{
|
|
return GetActionJustPressed(_inventoryActionName);
|
|
}
|
|
|
|
public override bool GetShootPressed()
|
|
{
|
|
return GetActionPressed(_shootActionName);
|
|
}
|
|
|
|
public override bool GetShootJustPressed()
|
|
{
|
|
return GetActionJustPressed(_shootActionName);
|
|
}
|
|
|
|
public override bool GetUseJustPressed()
|
|
{
|
|
return GetActionJustPressed(_useActionName);
|
|
}
|
|
public override bool GetScanJustPressed()
|
|
{
|
|
return GetActionJustPressed(_scanActionName);
|
|
}
|
|
|
|
public override bool GetStrafePressed()
|
|
{
|
|
return GetActionPressed(_strafeActionName);
|
|
}
|
|
|
|
public override bool GetWeaponNextJustPressed()
|
|
{
|
|
return GetActionJustPressed(_nextWeaponActionName);
|
|
}
|
|
|
|
public override bool GetWeaponPreviousJustPressed()
|
|
{
|
|
return GetActionJustPressed(_previousWeaponActionName);
|
|
}
|
|
|
|
public override bool GetPauseJustPressed()
|
|
{
|
|
return GetActionJustPressed(_pauseActionName);
|
|
}
|
|
|
|
} |