🐛 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();
|
||||
|
||||
@@ -27,6 +27,7 @@ public partial class PlantBehaviour2D : Node2D
|
||||
[ExportGroup("PlantConfig")]
|
||||
[Export] private string _prefabPath;
|
||||
[Export] private VariableNode _lifecycle;
|
||||
[Export] private int _daysWatered;
|
||||
|
||||
private string _magicWordDialogicEventName = "MagicWord";
|
||||
private Sprite2D? _currentPlantSprite = null;
|
||||
@@ -34,7 +35,6 @@ public partial class PlantBehaviour2D : Node2D
|
||||
private bool _calledOnReady = false;
|
||||
private int _dayPlanted;
|
||||
private int _currentDay;
|
||||
private int _daysWatered;
|
||||
|
||||
public PlantState State
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user