🚧 days are counted, plants know which day it is, but harvestables are still broken
This commit is contained in:
@@ -0,0 +1,15 @@
|
|||||||
|
[gd_scene load_steps=3 format=3 uid="uid://cqy831wnquvpc"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" uid="uid://d27xoo1reo5gu" path="res://scripts/CSharp/Low Code/Variables/SaveableVariableNode.cs" id="1_386s0"]
|
||||||
|
[ext_resource type="Script" uid="uid://du5facslfvg77" path="res://scripts/CSharp/Common/DayAndNight/CalendarController.cs" id="2_bl8tj"]
|
||||||
|
|
||||||
|
[node name="Day and Night" type="Node"]
|
||||||
|
|
||||||
|
[node name="Controller" type="Node" parent="." node_paths=PackedStringArray("_dayCounter")]
|
||||||
|
script = ExtResource("2_bl8tj")
|
||||||
|
_dayCounter = NodePath("../DayCounter")
|
||||||
|
|
||||||
|
[node name="DayCounter" type="Node" parent="." groups=["Saveable"]]
|
||||||
|
script = ExtResource("1_386s0")
|
||||||
|
Payload = 0
|
||||||
|
metadata/SaveID = "12c6da2e-fc71-4281-a04a-dfd3c7943975"
|
||||||
@@ -34,6 +34,7 @@ Signal_Debugger="*res://addons/SignalVisualizer/Debugger/SignalDebugger.gd"
|
|||||||
FightWorldAutoload="*res://prefabs/fight/fight_world_autoload.tscn"
|
FightWorldAutoload="*res://prefabs/fight/fight_world_autoload.tscn"
|
||||||
SaveGameManager="*res://scripts/CSharp/Common/Savegame/SaveGameManager.cs"
|
SaveGameManager="*res://scripts/CSharp/Common/Savegame/SaveGameManager.cs"
|
||||||
SettingsSaveController="*res://scripts/CSharp/Common/Savegame/SettingsSaveController.cs"
|
SettingsSaveController="*res://scripts/CSharp/Common/Savegame/SettingsSaveController.cs"
|
||||||
|
DayAndNight="*res://prefabs/day and night/day_and_night.tscn"
|
||||||
|
|
||||||
[dialogic]
|
[dialogic]
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
[gd_scene load_steps=7 format=3 uid="uid://bopv10dqm1knc"]
|
[gd_scene load_steps=5 format=3 uid="uid://bopv10dqm1knc"]
|
||||||
|
|
||||||
[ext_resource type="PackedScene" uid="uid://c6wnoif01ltld" path="res://scenes/Babushka_scene_startMenu.tscn" id="1_15ton"]
|
[ext_resource type="PackedScene" uid="uid://c6wnoif01ltld" path="res://scenes/Babushka_scene_startMenu.tscn" id="1_15ton"]
|
||||||
[ext_resource type="Script" uid="uid://bbp0dyddwdbl8" path="res://scripts/CSharp/Common/Savegame/WindowSettingsSync.cs" id="2_d3jfo"]
|
[ext_resource type="Script" uid="uid://bbp0dyddwdbl8" path="res://scripts/CSharp/Common/Savegame/WindowSettingsSync.cs" id="2_d3jfo"]
|
||||||
[ext_resource type="Script" uid="uid://d27xoo1reo5gu" path="res://scripts/CSharp/Low Code/Variables/SaveableVariableNode.cs" id="3_ocsjo"]
|
|
||||||
[ext_resource type="Script" uid="uid://du5facslfvg77" path="res://scripts/CSharp/Common/DayAndNight/CalendarController.cs" id="4_iyo8m"]
|
|
||||||
[ext_resource type="Script" uid="uid://iquhbkr7pqeg" path="res://scripts/CSharp/Common/Savegame/SaveCheats.cs" id="4_ocsjo"]
|
[ext_resource type="Script" uid="uid://iquhbkr7pqeg" path="res://scripts/CSharp/Common/Savegame/SaveCheats.cs" id="4_ocsjo"]
|
||||||
[ext_resource type="Script" uid="uid://ca4s0algeij1h" path="res://scripts/CSharp/Common/Savegame/SaveIDProviderTool.cs" id="5_iyo8m"]
|
[ext_resource type="Script" uid="uid://ca4s0algeij1h" path="res://scripts/CSharp/Common/Savegame/SaveIDProviderTool.cs" id="5_iyo8m"]
|
||||||
|
|
||||||
@@ -16,17 +14,6 @@
|
|||||||
[node name="WindowSettings" type="Node" parent="."]
|
[node name="WindowSettings" type="Node" parent="."]
|
||||||
script = ExtResource("2_d3jfo")
|
script = ExtResource("2_d3jfo")
|
||||||
|
|
||||||
[node name="Day and Night" type="Node" parent="."]
|
|
||||||
|
|
||||||
[node name="DayCounter" type="Node" parent="Day and Night" groups=["Saveable"]]
|
|
||||||
script = ExtResource("3_ocsjo")
|
|
||||||
Payload = 0
|
|
||||||
metadata/SaveID = "b46b67a2-427b-4f43-8066-4ffebf17b75f"
|
|
||||||
|
|
||||||
[node name="Controller" type="Node" parent="Day and Night" node_paths=PackedStringArray("_dayCounter")]
|
|
||||||
script = ExtResource("4_iyo8m")
|
|
||||||
_dayCounter = NodePath("../DayCounter")
|
|
||||||
|
|
||||||
[node name="SaveSystem" type="Node" parent="."]
|
[node name="SaveSystem" type="Node" parent="."]
|
||||||
|
|
||||||
[node name="SaveGameCheat" type="Node" parent="SaveSystem"]
|
[node name="SaveGameCheat" type="Node" parent="SaveSystem"]
|
||||||
|
|||||||
@@ -45,8 +45,11 @@ public partial class FieldBehaviour2D : Sprite2D, ISaveable
|
|||||||
|
|
||||||
private bool _canPlant;
|
private bool _canPlant;
|
||||||
private bool _canWater;
|
private bool _canWater;
|
||||||
|
private int _currentDay;
|
||||||
|
|
||||||
private PlantBehaviour2D? _currentPlant;
|
private PlantBehaviour2D? _currentPlant;
|
||||||
|
|
||||||
|
private const string DAY_COUNTER_SAVE_ID = "12c6da2e-fc71-4281-a04a-dfd3c7943975";
|
||||||
|
|
||||||
[Signal] public delegate void PlantedEventHandler();
|
[Signal] public delegate void PlantedEventHandler();
|
||||||
|
|
||||||
@@ -176,6 +179,7 @@ public partial class FieldBehaviour2D : Sprite2D, ISaveable
|
|||||||
if (_currentPlant != null)
|
if (_currentPlant != null)
|
||||||
{
|
{
|
||||||
_currentPlant.Field = this;
|
_currentPlant.Field = this;
|
||||||
|
_currentPlant.DayPlanted = _currentDay;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -194,7 +198,6 @@ public partial class FieldBehaviour2D : Sprite2D, ISaveable
|
|||||||
"plant_data", new Dictionary<string, Variant>()
|
"plant_data", new Dictionary<string, Variant>()
|
||||||
{
|
{
|
||||||
{ "prefab_path", _currentPlant.PrefabPath },
|
{ "prefab_path", _currentPlant.PrefabPath },
|
||||||
{ "plant_state", (int)_currentPlant.State },
|
|
||||||
{ "plant_start_day", _currentPlant.DayPlanted }
|
{ "plant_start_day", _currentPlant.DayPlanted }
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@@ -206,6 +209,7 @@ public partial class FieldBehaviour2D : Sprite2D, ISaveable
|
|||||||
|
|
||||||
public void LoadFromSaveData()
|
public void LoadFromSaveData()
|
||||||
{
|
{
|
||||||
|
// Get field and plant data
|
||||||
string id = _saveIdHolder.GetMeta("SaveID").AsString();
|
string id = _saveIdHolder.GetMeta("SaveID").AsString();
|
||||||
|
|
||||||
Dictionary<string, Variant> save = SavegameService.GetSaveData(id);
|
Dictionary<string, Variant> save = SavegameService.GetSaveData(id);
|
||||||
@@ -236,25 +240,23 @@ public partial class FieldBehaviour2D : Sprite2D, ISaveable
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (plantDataDict.TryGetValue("plant_state", out Variant plantStateVar) && _currentPlant != null)
|
|
||||||
{
|
|
||||||
_currentPlant.State = (PlantState) plantStateVar.AsInt32();
|
|
||||||
_currentPlant.GrowPlant();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (plantDataDict.TryGetValue("plant_start_day", out Variant plantDaysGrowingVar) && _currentPlant != null)
|
if (plantDataDict.TryGetValue("plant_start_day", out Variant plantDaysGrowingVar) && _currentPlant != null)
|
||||||
{
|
{
|
||||||
_currentPlant.DayPlanted = plantDaysGrowingVar.AsInt32();
|
_currentPlant.DayPlanted = plantDaysGrowingVar.AsInt32();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get current day count: Load only. Saving the day count is handled on the day and night prefab.
|
||||||
|
Dictionary<string, Variant> dayCountSave = SavegameService.GetSaveData(DAY_COUNTER_SAVE_ID);
|
||||||
|
|
||||||
if (_currentPlant != null)
|
if (dayCountSave.Count > 0)
|
||||||
|
{
|
||||||
|
if (dayCountSave.TryGetValue("payload", out Variant dayCountVar))
|
||||||
{
|
{
|
||||||
//todo: find out how to load the current day from save and provide it to the plant script
|
_currentDay = dayCountVar.AsInt32();
|
||||||
_currentPlant.CurrentDayInCalendar = GD.RandRange(0, 12);
|
if(_currentPlant != null)
|
||||||
GD.Print($"Set current Day in calendar for plant {_currentPlant.Name} to {_currentPlant.CurrentDayInCalendar}");
|
_currentPlant.CurrentDayInCalendar = dayCountVar.AsInt32();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,6 +41,9 @@ public partial class PlantBehaviour2D : Node2D
|
|||||||
set => _state = value;
|
set => _state = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The day count at the day this plant was planted.
|
||||||
|
/// </summary>
|
||||||
public int DayPlanted { get; set; }
|
public int DayPlanted { get; set; }
|
||||||
|
|
||||||
public int CurrentDayInCalendar
|
public int CurrentDayInCalendar
|
||||||
@@ -70,10 +73,10 @@ public partial class PlantBehaviour2D : Node2D
|
|||||||
|
|
||||||
_state = growthFloor switch
|
_state = growthFloor switch
|
||||||
{
|
{
|
||||||
0 => PlantState.Planted,
|
0 => PlantState.None,
|
||||||
1 => PlantState.SmallPlant,
|
1 => PlantState.Planted,
|
||||||
2 => PlantState.BigPlant,
|
2 => PlantState.SmallPlant,
|
||||||
_ => PlantState.Ready
|
_ => PlantState.BigPlant
|
||||||
};
|
};
|
||||||
|
|
||||||
_calledOnReady = true;
|
_calledOnReady = true;
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ public partial class ItemOnGround2D : Node, ISaveable
|
|||||||
private int pickUpCounter = 0;
|
private int pickUpCounter = 0;
|
||||||
|
|
||||||
[Signal] public delegate void SuccessfulPickUpEventHandler();
|
[Signal] public delegate void SuccessfulPickUpEventHandler();
|
||||||
|
|
||||||
|
|
||||||
private Label _itemLabel => GetNode<Label>("ItemLabel");
|
private Label _itemLabel => GetNode<Label>("ItemLabel");
|
||||||
private Label _pickupErrorLabel => GetNode<Label>("PickupErrorLabel");
|
private Label _pickupErrorLabel => GetNode<Label>("PickupErrorLabel");
|
||||||
@@ -92,6 +93,7 @@ public partial class ItemOnGround2D : Node, ISaveable
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// todo: What do we do with instances that are created at runtime?
|
||||||
public void UpdateSaveData()
|
public void UpdateSaveData()
|
||||||
{
|
{
|
||||||
var payloadData = new Dictionary<string, Variant>
|
var payloadData = new Dictionary<string, Variant>
|
||||||
|
|||||||
Reference in New Issue
Block a user