Manual Reload

This commit is contained in:
MaddoScientisto 2025-05-07 21:50:00 +02:00
commit 3b19e2b76f
10 changed files with 92 additions and 6 deletions

View file

@ -21,4 +21,7 @@ public abstract partial class InputProvider : Node2D
public abstract bool GetFreezeJustPressed();
public abstract bool GetFreezePressed();
public abstract bool GetReloadJustPressed();
public abstract bool GetReloadPressed();
}

View file

@ -36,6 +36,7 @@ public partial class KeyboardInputProvider : InputProvider
[Export] private StringName _inventoryActionName = "inventory";
[Export] private StringName _pauseActionName = "pause";
[Export] private StringName _freezeActionName = "Freeze";
[Export] private StringName _reloadActionName = "Reload";
private enum AimInputMethod { RightStick, Mouse }
private AimInputMethod _lastUsedInput = AimInputMethod.RightStick;
@ -174,5 +175,15 @@ public partial class KeyboardInputProvider : InputProvider
{
return GetActionPressed(_freezeActionName);
}
public override bool GetReloadJustPressed()
{
return GetActionJustPressed(_reloadActionName);
}
public override bool GetReloadPressed()
{
return GetActionPressed(_reloadActionName);
}
}

View file

@ -177,6 +177,14 @@ public partial class PlayerWeaponProvider : Node2D
EquippedWeapon.Shoot();
}
public void Reload()
{
if (EquippedWeapon == null) return;
if (_switching) return;
EquippedWeapon.Reload();
}
// Remastered method
private LootItem GetItemFromInventory(string itemKey)
{

View file

@ -197,6 +197,12 @@ public partial class Active : PlayerStateBase
private void HandleShoot()
{
if (_inputProvider.GetReloadJustPressed())
{
_weaponProvider.Reload();
return;
}
if (!_inputProvider.GetShootPressed()) return;
_weaponProvider.Shoot(this.FacingDirection);
}