mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-10 11:15:55 +00:00
Fixed inventory crash when restarting level
This commit is contained in:
parent
62751a66e6
commit
68daf9c372
5 changed files with 32 additions and 17 deletions
|
|
@ -180,12 +180,22 @@ public partial class PlayerWeaponProvider : Node2D
|
|||
|
||||
// Spawn if not present
|
||||
var spawnedWeapon = SpawnWeapon(itemKey);
|
||||
if (spawnedWeapon is null)
|
||||
{
|
||||
GD.Print($"Tried to spawn weapon {itemKey} but failed because it was null.");
|
||||
return null;
|
||||
};
|
||||
return Equip(spawnedWeapon, force);
|
||||
}
|
||||
|
||||
public Weapon Equip(Weapon weapon, bool force)
|
||||
{
|
||||
// When we get here we already have a spawned weapon and it's in the list
|
||||
|
||||
if (weapon is null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
// Always equip it if there's nothing equipped
|
||||
if (this.EquippedWeapon is null)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue