:feature: implemented saving and loading for ducks, 🔥 removed save implementation from interactionArea
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
using System;
|
||||
using Godot;
|
||||
using Godot.Collections;
|
||||
|
||||
namespace Babushka.scripts.CSharp.Common.Savegame;
|
||||
|
||||
[Tool]
|
||||
public partial class SaveIDProviderTool : Node
|
||||
{
|
||||
[ExportToolButton("Assign IDs")] private Callable assignIDs => Callable.From(AssignIDs);
|
||||
|
||||
private void AssignIDs()
|
||||
{
|
||||
Array<Node> saveables = GetTree().GetNodesInGroup("Saveable");
|
||||
foreach (var node in saveables)
|
||||
{
|
||||
GD.Print($"Checking {node.Name}.");
|
||||
GD.Print($"Node has Meta SaveID: {node.HasMeta("SaveID")} and it's: " + node.GetMeta("SaveID").AsString());
|
||||
if (!node.HasMeta("SaveID") || string.IsNullOrEmpty(node.GetMeta("SaveID").AsString()))
|
||||
{
|
||||
string saveID = Guid.NewGuid().ToString();
|
||||
node.SetMeta("SaveID", saveID);
|
||||
GD.Print($"Setting Save ID for node {node.Name}: " + saveID);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user