🐛 Fixed ObjectDisposedException Errors on plant/field and InventorySlot
This commit is contained in:
@@ -18,12 +18,17 @@ public partial class VesnaAnimations : Node
|
||||
/// Emits the last look direction of the player to other scripts.
|
||||
/// </summary>
|
||||
[Signal] public delegate void LookDirectionEventHandler(Vector2 direction);
|
||||
|
||||
public override void _Ready()
|
||||
|
||||
public override void _EnterTree()
|
||||
{
|
||||
InventoryManager.Instance.playerInventory.InventoryContentsChanged += HandleNewItemInInventory;
|
||||
}
|
||||
|
||||
public override void _ExitTree()
|
||||
{
|
||||
InventoryManager.Instance.playerInventory.InventoryContentsChanged -= HandleNewItemInInventory;
|
||||
}
|
||||
|
||||
private void HandleNewItemInInventory()
|
||||
{
|
||||
// for future Kathi: this does not, in fact, check if an item has been added only, but triggers on every content change!
|
||||
|
||||
@@ -28,6 +28,7 @@ public partial class InventoryUi : Control
|
||||
|
||||
public override void _ExitTree()
|
||||
{
|
||||
InventoryManager.Instance.playerInventory.InventoryContentsChanged -= SetSlotContent;
|
||||
UnsubscribeSlots();
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ public partial class ItemOnGround2D : Node, ISaveable
|
||||
[Export] public bool IsActive = true;
|
||||
[Export] private bool _infiniteSupply = false;
|
||||
[Export] private int _finiteSupply = 1;
|
||||
[Export] private bool _saveToDisk = true;
|
||||
|
||||
private int pickUpCounter = 0;
|
||||
|
||||
@@ -96,6 +97,9 @@ public partial class ItemOnGround2D : Node, ISaveable
|
||||
// todo: What do we do with instances that are created at runtime?
|
||||
public void UpdateSaveData()
|
||||
{
|
||||
if (!_saveToDisk)
|
||||
return;
|
||||
|
||||
var payloadData = new Dictionary<string, Variant>
|
||||
{
|
||||
{"pickupCounter", pickUpCounter}
|
||||
@@ -107,6 +111,9 @@ public partial class ItemOnGround2D : Node, ISaveable
|
||||
|
||||
public void LoadFromSaveData()
|
||||
{
|
||||
if (!_saveToDisk)
|
||||
return;
|
||||
|
||||
if (_infiniteSupply)
|
||||
return;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user