🚧 WIP binding the plant growth to the day count in the savefile

This commit is contained in:
2025-11-26 20:12:27 +01:00
parent 67d5b67c21
commit a1fb71119f
4 changed files with 70 additions and 9 deletions
@@ -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}");
}
}
}
}