🐛 fixed beets double spawning bug

This commit is contained in:
2025-12-04 23:45:35 +01:00
parent 1dd4a694d0
commit 996470f5e6
3 changed files with 17 additions and 2 deletions
@@ -243,6 +243,9 @@ public partial class FieldBehaviour2D : Sprite2D, ISaveable
string id = _saveIdHolder.GetMeta("SaveID").AsString();
Dictionary<string, Variant> save = SavegameService.GetSaveData(id);
// if we already have a plant, don't instantiate another one
int plantCount = PlantingPlaceholder.GetChildCount();
if (save.Count > 0)
{
@@ -253,12 +256,16 @@ public partial class FieldBehaviour2D : Sprite2D, ISaveable
if (plantDataDict.TryGetValue("prefab_path", out Variant prefabPathVar))
{
InstantiatePlant(prefabPathVar.AsString());
if(plantCount == 0)
InstantiatePlant(prefabPathVar.AsString());
else
_currentPlant = PlantingPlaceholder.GetChild(0) as PlantBehaviour2D;
}
else
{
return;
}
if (plantDataDict.TryGetValue("plant_start_day", out Variant plantStartDay) && _currentPlant != null)
{
_currentPlant.DayPlanted = plantStartDay.AsInt32();