diff --git a/scenes/Babushka_scene_outside_beets.tscn b/scenes/Babushka_scene_outside_beets.tscn index 2118566..b3d54d8 100644 --- a/scenes/Babushka_scene_outside_beets.tscn +++ b/scenes/Babushka_scene_outside_beets.tscn @@ -1760,6 +1760,7 @@ metadata/SaveID = "7a8210bf-479d-4b4c-9758-98d23e59d5d7" [node name="Beet2" parent="YSorted/Farm visuals/FieldParent/BaseField/FieldBehaviour/PlantPlaceholder" index="0" node_paths=PackedStringArray("_field") instance=ExtResource("41_vyqmy")] _state = 2 _field = NodePath("../..") +_daysWatered = 6 [node name="FieldActivator" parent="YSorted/Farm visuals/FieldParent/BaseField" index="7"] visible = false @@ -1780,6 +1781,7 @@ metadata/SaveID = "a1d8a0a2-c51c-4410-83c3-0edb31cbf2de" [node name="Beet2" parent="YSorted/Farm visuals/FieldParent/BaseField2/FieldBehaviour/PlantPlaceholder" index="0" node_paths=PackedStringArray("_field") instance=ExtResource("41_vyqmy")] _state = 2 _field = NodePath("../..") +_daysWatered = 6 [node name="FieldActivator" parent="YSorted/Farm visuals/FieldParent/BaseField2" index="7"] visible = false @@ -1800,6 +1802,7 @@ metadata/SaveID = "79a65532-cb2b-4268-8eb0-8c41a3935cbb" [node name="Beet2" parent="YSorted/Farm visuals/FieldParent/BaseField3/FieldBehaviour/PlantPlaceholder" index="0" node_paths=PackedStringArray("_field") instance=ExtResource("41_vyqmy")] _state = 2 _field = NodePath("../..") +_daysWatered = 5 [node name="FieldActivator" parent="YSorted/Farm visuals/FieldParent/BaseField3" index="7"] visible = false @@ -1821,6 +1824,7 @@ metadata/SaveID = "13fa64a3-01dc-4fd8-822e-0839c0da3163" [node name="Beet2" parent="YSorted/Farm visuals/FieldParent/BaseField4/FieldBehaviour/PlantPlaceholder" index="0" node_paths=PackedStringArray("_field") instance=ExtResource("41_vyqmy")] _state = 2 _field = NodePath("../..") +_daysWatered = 7 [node name="FieldActivator" parent="YSorted/Farm visuals/FieldParent/BaseField4" index="7"] visible = false @@ -1842,6 +1846,7 @@ metadata/SaveID = "414ecdb9-f3c4-4fb9-81bd-6ca575784f78" [node name="Beet2" parent="YSorted/Farm visuals/FieldParent/BaseField5/FieldBehaviour/PlantPlaceholder" index="0" node_paths=PackedStringArray("_field") instance=ExtResource("41_vyqmy")] _state = 2 _field = NodePath("../..") +_daysWatered = 6 [node name="FieldActivator" parent="YSorted/Farm visuals/FieldParent/BaseField5" index="7"] visible = false @@ -1863,6 +1868,7 @@ metadata/SaveID = "b235febb-b231-4f8c-94e9-1f9d9f115b08" [node name="Beet2" parent="YSorted/Farm visuals/FieldParent/BaseField6/FieldBehaviour/PlantPlaceholder" index="0" node_paths=PackedStringArray("_field") instance=ExtResource("41_vyqmy")] _state = 1 _field = NodePath("../..") +_daysWatered = 5 [node name="FieldActivator" parent="YSorted/Farm visuals/FieldParent/BaseField6" index="7"] visible = false @@ -1884,6 +1890,7 @@ metadata/SaveID = "9ccdba91-812a-4c13-9ee0-12472e174fc9" [node name="Beet2" parent="YSorted/Farm visuals/FieldParent/BaseField7/FieldBehaviour/PlantPlaceholder" index="0" node_paths=PackedStringArray("_field") instance=ExtResource("41_vyqmy")] _state = 2 _field = NodePath("../..") +_daysWatered = 6 [node name="FieldActivator" parent="YSorted/Farm visuals/FieldParent/BaseField7" index="7"] visible = false @@ -1905,6 +1912,7 @@ metadata/SaveID = "da44e54a-0b76-4888-ad8b-782a9d146fa3" [node name="Beet2" parent="YSorted/Farm visuals/FieldParent/BaseField8/FieldBehaviour/PlantPlaceholder" index="0" node_paths=PackedStringArray("_field") instance=ExtResource("41_vyqmy")] _state = 2 _field = NodePath("../..") +_daysWatered = 6 [node name="FieldActivator" parent="YSorted/Farm visuals/FieldParent/BaseField8" index="7"] visible = false diff --git a/scripts/CSharp/Common/Farming/FieldBehaviour2D.cs b/scripts/CSharp/Common/Farming/FieldBehaviour2D.cs index bf9116f..4f1e2c0 100644 --- a/scripts/CSharp/Common/Farming/FieldBehaviour2D.cs +++ b/scripts/CSharp/Common/Farming/FieldBehaviour2D.cs @@ -243,6 +243,9 @@ public partial class FieldBehaviour2D : Sprite2D, ISaveable string id = _saveIdHolder.GetMeta("SaveID").AsString(); Dictionary 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(); diff --git a/scripts/CSharp/Common/Farming/PlantBehaviour2D.cs b/scripts/CSharp/Common/Farming/PlantBehaviour2D.cs index 3b88dd9..7a29df9 100644 --- a/scripts/CSharp/Common/Farming/PlantBehaviour2D.cs +++ b/scripts/CSharp/Common/Farming/PlantBehaviour2D.cs @@ -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 {