✨ Make SaveableVariableNodes and a simple cheat to count up days
This commit is contained in:
@@ -300,6 +300,11 @@ ui_inventory_journal_open_close={
|
|||||||
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":74,"key_label":0,"unicode":106,"location":0,"echo":false,"script":null)
|
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":74,"key_label":0,"unicode":106,"location":0,"echo":false,"script":null)
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
NextDayCheat={
|
||||||
|
"deadzone": 0.2,
|
||||||
|
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":32,"key_label":0,"unicode":32,"location":0,"echo":false,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
[internationalization]
|
[internationalization]
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,11 @@
|
|||||||
[gd_scene load_steps=3 format=3 uid="uid://bopv10dqm1knc"]
|
[gd_scene load_steps=7 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://ca4s0algeij1h" path="res://scripts/CSharp/Common/Savegame/SaveIDProviderTool.cs" id="5_iyo8m"]
|
||||||
|
|
||||||
[node name="BabushkaSceneBootstrap" type="Node2D"]
|
[node name="BabushkaSceneBootstrap" type="Node2D"]
|
||||||
|
|
||||||
@@ -11,3 +15,22 @@
|
|||||||
|
|
||||||
[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="SaveGameCheat" type="Node" parent="SaveSystem"]
|
||||||
|
script = ExtResource("4_ocsjo")
|
||||||
|
|
||||||
|
[node name="SaveIDProvider" type="Node" parent="SaveSystem"]
|
||||||
|
script = ExtResource("5_iyo8m")
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
using Babushka.scripts.CSharp.Low_Code.Variables;
|
||||||
|
using Godot;
|
||||||
|
|
||||||
|
namespace Babushka.scripts.CSharp.Common.DayAndNight;
|
||||||
|
|
||||||
|
public partial class CalendarController : Node
|
||||||
|
{
|
||||||
|
[Export] private SaveableVariableNode _dayCounter;
|
||||||
|
|
||||||
|
public override void _Input(InputEvent @event)
|
||||||
|
{
|
||||||
|
if (@event.IsActionPressed("NextDayCheat"))
|
||||||
|
{
|
||||||
|
int days = _dayCounter.Payload.AsInt32();
|
||||||
|
days++;
|
||||||
|
_dayCounter.Payload = days;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
uid://du5facslfvg77
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
using Babushka.scripts.CSharp.Common.Savegame;
|
||||||
|
using Godot;
|
||||||
|
using Godot.Collections;
|
||||||
|
|
||||||
|
namespace Babushka.scripts.CSharp.Low_Code.Variables;
|
||||||
|
|
||||||
|
public partial class SaveableVariableNode : VariableNode, ISaveable
|
||||||
|
{
|
||||||
|
public override void _Ready()
|
||||||
|
{
|
||||||
|
LoadFromSaveData();
|
||||||
|
ValueChanged += UpdateSaveData;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void _ExitTree()
|
||||||
|
{
|
||||||
|
ValueChanged -= UpdateSaveData;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void UpdateSaveData()
|
||||||
|
{
|
||||||
|
var payloadData = new Dictionary<string, Variant>
|
||||||
|
{
|
||||||
|
{ "payload", Payload },
|
||||||
|
};
|
||||||
|
|
||||||
|
string id = GetMeta("SaveID").AsString();
|
||||||
|
SavegameService.AppendDataToSave( id, payloadData);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void LoadFromSaveData()
|
||||||
|
{
|
||||||
|
string id = GetMeta("SaveID").AsString();
|
||||||
|
Dictionary<string, Variant> save = SavegameService.GetSaveData(id);
|
||||||
|
if (save.Count > 0)
|
||||||
|
{
|
||||||
|
if (Payload.VariantType == Variant.Type.Int)
|
||||||
|
{
|
||||||
|
Payload = save["payload"].AsInt32();
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Payload = save["payload"];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
uid://d27xoo1reo5gu
|
||||||
@@ -7,5 +7,23 @@ namespace Babushka.scripts.CSharp.Low_Code.Variables;
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class VariableNode : Node
|
public partial class VariableNode : Node
|
||||||
{
|
{
|
||||||
[Export] public Variant Payload { get; set; }
|
[Export] public Variant Payload
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _payload;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (_payload.Equals(value))
|
||||||
|
return;
|
||||||
|
|
||||||
|
_payload = value;
|
||||||
|
EmitSignal(SignalName.ValueChanged);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Variant _payload;
|
||||||
|
|
||||||
|
[Signal] public delegate void ValueChangedEventHandler();
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user