|
|
|
|
@ -50,12 +50,14 @@ public partial class InventoryInstance : Node, ISaveable
|
|
|
|
|
LoadFromSaveData();
|
|
|
|
|
InventoryContentsChanged += UpdateSaveData;
|
|
|
|
|
SlotAmountChanged += UpdateSaveData;
|
|
|
|
|
SavegameService.OnSaveGameReset += SaveGameReset;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public override void _ExitTree()
|
|
|
|
|
{
|
|
|
|
|
InventoryContentsChanged -= UpdateSaveData;
|
|
|
|
|
SlotAmountChanged -= UpdateSaveData;
|
|
|
|
|
SavegameService.OnSaveGameReset -= SaveGameReset;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public InventoryActionResult AddItem(ItemInstance newItem)
|
|
|
|
|
@ -216,5 +218,17 @@ public partial class InventoryInstance : Node, ISaveable
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Called when a new save is created.
|
|
|
|
|
/// Needs to do a runtime check because the InventoryInstance is already in existence at the beginning of the first scene.
|
|
|
|
|
/// </summary>
|
|
|
|
|
private void SaveGameReset()
|
|
|
|
|
{
|
|
|
|
|
foreach (var slot in _slots)
|
|
|
|
|
{
|
|
|
|
|
slot.itemInstance = null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
|