Reverted ItemOnGround to make everything compile again

pull/52/head
Katharina Ziolkowski 2 months ago
parent 8a93b00e72
commit 0dfbd73978

@ -2545,7 +2545,7 @@ visible = false
texture = ExtResource("83_50rxh")
[node name="TrashPlacer3" type="Node2D" parent="."]
position = Vector2(10825, 3362)
position = Vector2(9897, 3328)
script = ExtResource("82_ec5sc")
[node name="icon" type="Sprite2D" parent="TrashPlacer3"]
@ -2554,13 +2554,27 @@ texture = ExtResource("83_50rxh")
[connection signal="FilledWateringCan" from="YSorted/Vesna" to="Audio/SFX/FillWater SFX2" method="PlayOneShot"]
[connection signal="InteractedTool" from="YSorted/Well/InteractionArea" to="YSorted/Vesna" method="TryFillWateringCan"]
[connection signal="area_entered" from="YSorted/Well/InteractionArea/Area2D" to="YSorted/Well/InteractionArea" method="OnPlayerEntered"]
[connection signal="area_exited" from="YSorted/Well/InteractionArea/Area2D" to="YSorted/Well/InteractionArea" method="OnPlayerExited"]
[connection signal="SuccessfulPickUp" from="YSorted/CanGenericPickup" to="YSorted/Vesna" method="HandlePickUp"]
[connection signal="area_entered" from="YSorted/CanGenericPickup/PickupInteractionArea/Area2D" to="YSorted/CanGenericPickup/PickupInteractionArea" method="OnPlayerEntered"]
[connection signal="area_exited" from="YSorted/CanGenericPickup/PickupInteractionArea/Area2D" to="YSorted/CanGenericPickup/PickupInteractionArea" method="OnPlayerExited"]
[connection signal="SuccessfulPickUp" from="YSorted/RakeGenericPickup" to="YSorted/Vesna" method="HandlePickUp"]
[connection signal="area_entered" from="YSorted/RakeGenericPickup/PickupInteractionArea/Area2D" to="YSorted/RakeGenericPickup/PickupInteractionArea" method="OnPlayerEntered"]
[connection signal="area_exited" from="YSorted/RakeGenericPickup/PickupInteractionArea/Area2D" to="YSorted/RakeGenericPickup/PickupInteractionArea" method="OnPlayerExited"]
[connection signal="SuccessfulPickUp" from="YSorted/SeedPickup" to="YSorted/Vesna" method="HandlePickUp"]
[connection signal="area_entered" from="YSorted/SeedPickup/PickupInteractionArea/Area2D" to="YSorted/SeedPickup/PickupInteractionArea" method="OnPlayerEntered"]
[connection signal="area_exited" from="YSorted/SeedPickup/PickupInteractionArea/Area2D" to="YSorted/SeedPickup/PickupInteractionArea" method="OnPlayerExited"]
[connection signal="SuccessfulPickUp" from="YSorted/BeetPickup" to="YSorted/Vesna" method="HandlePickUp"]
[connection signal="area_entered" from="YSorted/BeetPickup/PickupInteractionArea/Area2D" to="YSorted/BeetPickup/PickupInteractionArea" method="OnPlayerEntered"]
[connection signal="area_exited" from="YSorted/BeetPickup/PickupInteractionArea/Area2D" to="YSorted/BeetPickup/PickupInteractionArea" method="OnPlayerExited"]
[connection signal="SuccessfulPickUp" from="YSorted/SeedPickup2" to="YSorted/Vesna" method="HandlePickUp"]
[connection signal="area_entered" from="YSorted/SeedPickup2/PickupInteractionArea/Area2D" to="YSorted/SeedPickup2/PickupInteractionArea" method="OnPlayerEntered"]
[connection signal="area_exited" from="YSorted/SeedPickup2/PickupInteractionArea/Area2D" to="YSorted/SeedPickup2/PickupInteractionArea" method="OnPlayerExited"]
[connection signal="InteractedTool" from="YSorted/Farm visuals/Static/EnterHouseInteraction" to="." method="LoadSceneAtIndex"]
[connection signal="InteractedTool" from="YSorted/Blocker/Fence Door/InteractionArea" to="." method="LoadSceneAtIndex"]
[connection signal="area_entered" from="YSorted/Blocker/Fence Door/InteractionArea/Area2D" to="YSorted/Blocker/Fence Door/InteractionArea" method="OnPlayerEntered"]
[connection signal="area_exited" from="YSorted/Blocker/Fence Door/InteractionArea/Area2D" to="YSorted/Blocker/Fence Door/InteractionArea" method="OnPlayerExited"]
[connection signal="GoalReached" from="YSorted/ducks" to="YSorted/ducks/DialogicToggle" method="ToggleDialogue"]
[connection signal="DuckCollected" from="YSorted/ducks/Duck2" to="YSorted/ducks" method="Increment"]
[connection signal="DuckCollected" from="YSorted/ducks/Duck3" to="YSorted/ducks" method="Increment"]

@ -1,16 +1,20 @@
using Babushka.scripts.CSharp.Common.Savegame;
using Babushka.scripts.CSharp.GameEntity.Entities;
using Babushka.scripts.CSharp.GameEntity.LoadSave;
using Godot;
using Godot.Collections;
using Newtonsoft.Json.Linq;
namespace Babushka.scripts.CSharp.Common.Inventory;
public partial class ItemOnGround2D : Node2D
public partial class ItemOnGround2D : Node, ISaveable
{
private ItemInstance _itemInstance;
[Export] public bool IsActive = true;
[Export] private bool _infiniteSupply = false;
[Export] private int _finiteSupply = 1;
[Export] private bool _saveToDisk = true;
private int pickUpCounter = 0;
[Signal] public delegate void SuccessfulPickUpEventHandler();
@ -30,12 +34,16 @@ public partial class ItemOnGround2D : Node2D
public override void _Ready()
{
LoadFromSaveData();
UpdateVisuals();
_pickupErrorLabel.Text = "";
}
public void TryPickUp()
{
if (!IsActive)
return;
var result = InventoryManager.Instance.CollectItem(itemInstance.Clone());
EmitSignal(SignalName.SuccessfulPickUp);
if (result == InventoryActionResult.Success)
@ -50,7 +58,16 @@ public partial class ItemOnGround2D : Node2D
private void Pickup()
{
// remove from entity manager
if (!_infiniteSupply)
{
pickUpCounter++;
if (pickUpCounter >= _finiteSupply)
{
QueueFree();
}
UpdateSaveData();
}
}
private void FailToPickup()
@ -63,6 +80,9 @@ public partial class ItemOnGround2D : Node2D
public void UpdateVisuals()
{
if (!IsActive)
return;
_iconSprite.Texture = itemInstance?.blueprint?.icon;
if (_iconSprite.Texture == null)
{
@ -74,22 +94,7 @@ public partial class ItemOnGround2D : Node2D
}
}
/*
protected override void LoadEntity(JObject json)
{
base.LoadEntity(json);
_itemInstance.LoadFromJson(json.GetObject("item"));
}
protected override void SaveEntity(JObject json)
{
base.SaveEntity(json);
json["item"] = _itemInstance.SaveToJson();
}
*/
// old save
/*
// todo: What do we do with instances that are created at runtime?
public void UpdateSaveData()
{
if (!_saveToDisk)
@ -152,5 +157,5 @@ public partial class ItemOnGround2D : Node2D
}
}
}
}*/
}
}

Loading…
Cancel
Save