🚧 WIP binding the plant growth to the day count in the savefile
This commit is contained in:
@@ -195,7 +195,7 @@ public partial class FieldBehaviour2D : Sprite2D, ISaveable
|
||||
{
|
||||
{ "prefab_path", _currentPlant.PrefabPath },
|
||||
{ "plant_state", (int)_currentPlant.State },
|
||||
{ "plant_days_growing", _currentPlant.DaysGrowing }
|
||||
{ "plant_start_day", _currentPlant.DayPlanted }
|
||||
}
|
||||
);
|
||||
}
|
||||
@@ -243,11 +243,18 @@ public partial class FieldBehaviour2D : Sprite2D, ISaveable
|
||||
_currentPlant.GrowPlant();
|
||||
}
|
||||
|
||||
if (plantDataDict.TryGetValue("plant_days_growing", out Variant plantDaysGrowingVar) && _currentPlant != null)
|
||||
if (plantDataDict.TryGetValue("plant_start_day", out Variant plantDaysGrowingVar) && _currentPlant != null)
|
||||
{
|
||||
_currentPlant.DaysGrowing = plantDaysGrowingVar.AsInt32();
|
||||
_currentPlant.DayPlanted = plantDaysGrowingVar.AsInt32();
|
||||
}
|
||||
|
||||
|
||||
if (_currentPlant != null)
|
||||
{
|
||||
//todo: find out how to load the current day from save and provide it to the plant script
|
||||
_currentPlant.CurrentDayInCalendar = GD.RandRange(0, 12);
|
||||
GD.Print($"Set current Day in calendar for plant {_currentPlant.Name} to {_currentPlant.CurrentDayInCalendar}");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user