|
|
|
|
@ -74,9 +74,13 @@ public partial class FieldBehaviour2D : Sprite2D, ISaveable
|
|
|
|
|
UpdateInteractionArea();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void _Ready()
|
|
|
|
|
public override void _EnterTree()
|
|
|
|
|
{
|
|
|
|
|
LoadFromSaveData();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void _Ready()
|
|
|
|
|
{
|
|
|
|
|
if(PlantingPlaceholder.GetChildCount() > 0)
|
|
|
|
|
_currentPlant = PlantingPlaceholder.GetChild<PlantBehaviour2D>(0);
|
|
|
|
|
UpdateFieldState(FieldState);
|
|
|
|
|
@ -169,6 +173,16 @@ public partial class FieldBehaviour2D : Sprite2D, ISaveable
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void PlantPrefab(string prefabPath)
|
|
|
|
|
{
|
|
|
|
|
InstantiatePlant(prefabPath);
|
|
|
|
|
|
|
|
|
|
if (_currentPlant != null)
|
|
|
|
|
{
|
|
|
|
|
_currentPlant.DayPlanted = _currentDay;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void InstantiatePlant(string prefabPath)
|
|
|
|
|
{
|
|
|
|
|
PackedScene prefab = ResourceLoader.Load<PackedScene>(prefabPath, nameof(PackedScene));
|
|
|
|
|
Node2D plant2d = prefab.Instantiate<Node2D>();
|
|
|
|
|
@ -179,7 +193,6 @@ public partial class FieldBehaviour2D : Sprite2D, ISaveable
|
|
|
|
|
if (_currentPlant != null)
|
|
|
|
|
{
|
|
|
|
|
_currentPlant.Field = this;
|
|
|
|
|
_currentPlant.DayPlanted = _currentDay;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -234,15 +247,16 @@ public partial class FieldBehaviour2D : Sprite2D, ISaveable
|
|
|
|
|
|
|
|
|
|
if (plantDataDict.TryGetValue("prefab_path", out Variant prefabPathVar))
|
|
|
|
|
{
|
|
|
|
|
PlantPrefab(prefabPathVar.AsString());
|
|
|
|
|
InstantiatePlant(prefabPathVar.AsString());
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (plantDataDict.TryGetValue("plant_start_day", out Variant plantDaysGrowingVar) && _currentPlant != null)
|
|
|
|
|
if (plantDataDict.TryGetValue("plant_start_day", out Variant plantStartDay) && _currentPlant != null)
|
|
|
|
|
{
|
|
|
|
|
_currentPlant.DayPlanted = plantDaysGrowingVar.AsInt32();
|
|
|
|
|
_currentPlant.DayPlanted = plantStartDay.AsInt32();
|
|
|
|
|
GD.Print($"Current plant {_currentPlant.Name} was planted on day: {_currentPlant.DayPlanted}");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -255,7 +269,9 @@ public partial class FieldBehaviour2D : Sprite2D, ISaveable
|
|
|
|
|
{
|
|
|
|
|
_currentDay = dayCountVar.AsInt32();
|
|
|
|
|
if (_currentPlant != null)
|
|
|
|
|
_currentPlant.CurrentDayInCalendar = dayCountVar.AsInt32();
|
|
|
|
|
{
|
|
|
|
|
_currentPlant.CurrentDayInCalendar = _currentDay;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|