mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-01 11:15:33 +00:00
Manual Reload
This commit is contained in:
parent
9a5267b3e9
commit
3b19e2b76f
10 changed files with 92 additions and 6 deletions
|
|
@ -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();
|
||||
}
|
||||
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -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)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue