🐛 fixed beets double spawning bug
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user