Weapon equip fix

This commit is contained in:
Marco 2025-03-13 14:20:30 +01:00
commit 27fb8fb4bd
5 changed files with 14 additions and 6 deletions

View file

@ -15,6 +15,6 @@ InfiniteAmmo = false
BulletsPerShot = 1
SpreadAngle = 0.0
RandomSpread = 0.0
ItemKey = &"YINYAN_GUN"
AmmoKey = &"YINYAN_AMMO"
ItemKey = &"YINYANG_GUN"
AmmoKey = &"YINYANG_AMMO"
_rotationOffset = 0.0

View file

@ -192,6 +192,7 @@ offset_right = 226.0
offset_bottom = 144.0
[node name="InventoryMenu" type="TabContainer" parent="."]
visible = false
offset_left = 16.0
offset_top = 9.0
offset_right = 305.0

View file

@ -52,7 +52,13 @@ public partial class PlayerWeaponProvider : Node2D
if (string.IsNullOrWhiteSpace(itemKey)) return;
var weapon = EquippedWeapons.FirstOrDefault(x => x.WeaponData.ItemKey == itemKey);
if (weapon is null) return;
if (weapon is null)
{
// Spawn a weapon
InventoryManager.Instance.TryGetItem(itemKey, out var item);
SpawnPlayerWeapon(item.Item);
return;
};
EquipWeapon(weapon);
}

View file

@ -43,7 +43,7 @@ public partial class GameManager : Node2D
//public AlarmManager AlarmManager => _alarmManager;
[Export]
public string PauseActionName { get; private set; } = "pause";
public StringName PauseActionName { get; private set; } = "pause";
private Node2D _bulletsContainer;
public Node2D BulletsContainer => _bulletsContainer;

View file

@ -25,11 +25,12 @@ public partial class InventoryMenu : TabContainer
public override void _Process(double delta)
{
if (Input.IsActionJustPressed(InventoryActionName) || Input.IsActionJustPressed(PauseActionName))
if (Input.IsActionJustPressed(InventoryActionName) || Input.IsActionJustPressed(PauseActionName) || Input.IsActionJustPressed(CancelActionName))
{
if (Visible)
{
CallDeferred(MethodName.HideInventory);
GameManager.Instance.ChangeState(GameState.Playing);
//CallDeferred(MethodName.HideInventory);
}
// else
// {