🐛 Fixed ObjectDisposedException Errors on plant/field and InventorySlot
This commit is contained in:
@@ -138,6 +138,7 @@ shape = SubResource("CircleShape2D_vjw4j")
|
|||||||
[node name="ReadyPlantInventoryItem" parent="." instance=ExtResource("6_gdrin")]
|
[node name="ReadyPlantInventoryItem" parent="." instance=ExtResource("6_gdrin")]
|
||||||
position = Vector2(0, 2.3)
|
position = Vector2(0, 2.3)
|
||||||
IsActive = false
|
IsActive = false
|
||||||
|
_saveToDisk = false
|
||||||
|
|
||||||
[node name="SpawnWithItem" parent="ReadyPlantInventoryItem" index="0"]
|
[node name="SpawnWithItem" parent="ReadyPlantInventoryItem" index="0"]
|
||||||
_blueprint = ExtResource("7_vjw4j")
|
_blueprint = ExtResource("7_vjw4j")
|
||||||
|
|||||||
@@ -19,11 +19,16 @@ public partial class VesnaAnimations : Node
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
[Signal] public delegate void LookDirectionEventHandler(Vector2 direction);
|
[Signal] public delegate void LookDirectionEventHandler(Vector2 direction);
|
||||||
|
|
||||||
public override void _Ready()
|
public override void _EnterTree()
|
||||||
{
|
{
|
||||||
InventoryManager.Instance.playerInventory.InventoryContentsChanged += HandleNewItemInInventory;
|
InventoryManager.Instance.playerInventory.InventoryContentsChanged += HandleNewItemInInventory;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override void _ExitTree()
|
||||||
|
{
|
||||||
|
InventoryManager.Instance.playerInventory.InventoryContentsChanged -= HandleNewItemInInventory;
|
||||||
|
}
|
||||||
|
|
||||||
private void 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!
|
// 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()
|
public override void _ExitTree()
|
||||||
{
|
{
|
||||||
|
InventoryManager.Instance.playerInventory.InventoryContentsChanged -= SetSlotContent;
|
||||||
UnsubscribeSlots();
|
UnsubscribeSlots();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ public partial class ItemOnGround2D : Node, ISaveable
|
|||||||
[Export] public bool IsActive = true;
|
[Export] public bool IsActive = true;
|
||||||
[Export] private bool _infiniteSupply = false;
|
[Export] private bool _infiniteSupply = false;
|
||||||
[Export] private int _finiteSupply = 1;
|
[Export] private int _finiteSupply = 1;
|
||||||
|
[Export] private bool _saveToDisk = true;
|
||||||
|
|
||||||
private int pickUpCounter = 0;
|
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?
|
// todo: What do we do with instances that are created at runtime?
|
||||||
public void UpdateSaveData()
|
public void UpdateSaveData()
|
||||||
{
|
{
|
||||||
|
if (!_saveToDisk)
|
||||||
|
return;
|
||||||
|
|
||||||
var payloadData = new Dictionary<string, Variant>
|
var payloadData = new Dictionary<string, Variant>
|
||||||
{
|
{
|
||||||
{"pickupCounter", pickUpCounter}
|
{"pickupCounter", pickUpCounter}
|
||||||
@@ -107,6 +111,9 @@ public partial class ItemOnGround2D : Node, ISaveable
|
|||||||
|
|
||||||
public void LoadFromSaveData()
|
public void LoadFromSaveData()
|
||||||
{
|
{
|
||||||
|
if (!_saveToDisk)
|
||||||
|
return;
|
||||||
|
|
||||||
if (_infiniteSupply)
|
if (_infiniteSupply)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user