|
|
|
@ -1,12 +1,20 @@
|
|
|
|
using System.Linq;
|
|
|
|
using System.Linq;
|
|
|
|
|
|
|
|
using Babushka.scripts.CSharp.Common.Savegame;
|
|
|
|
using Babushka.scripts.CSharp.Common.Services;
|
|
|
|
using Babushka.scripts.CSharp.Common.Services;
|
|
|
|
|
|
|
|
using Babushka.scripts.CSharp.Low_Code.Variables;
|
|
|
|
using Godot;
|
|
|
|
using Godot;
|
|
|
|
|
|
|
|
using Godot.Collections;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Babushka.scripts.CSharp.Common.CharacterControls;
|
|
|
|
namespace Babushka.scripts.CSharp.Common.CharacterControls;
|
|
|
|
|
|
|
|
|
|
|
|
public partial class InteractionArea2D : Node2D
|
|
|
|
public partial class InteractionArea2D : Node2D, ISaveable
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
[ExportGroup("Persistence")]
|
|
|
|
|
|
|
|
[Export] public string SaveId = "";
|
|
|
|
|
|
|
|
[Export] private VariableNode _sceneID;
|
|
|
|
|
|
|
|
[Export] public VariableResource _sceneKeyProvider;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[ExportGroup("Settings")]
|
|
|
|
[Export] private Area2D _area;
|
|
|
|
[Export] private Area2D _area;
|
|
|
|
[Export] private Label _label;
|
|
|
|
[Export] private Label _label;
|
|
|
|
[Export] private bool _active = true;
|
|
|
|
[Export] private bool _active = true;
|
|
|
|
@ -17,6 +25,7 @@ public partial class InteractionArea2D : Node2D
|
|
|
|
[Export] private int _id = -1; // TODO: remove
|
|
|
|
[Export] private int _id = -1; // TODO: remove
|
|
|
|
|
|
|
|
|
|
|
|
private Material[] _backupMaterials;
|
|
|
|
private Material[] _backupMaterials;
|
|
|
|
|
|
|
|
private int _interactionCounter;
|
|
|
|
|
|
|
|
|
|
|
|
[Signal] public delegate void InteractedToolEventHandler(int id); // TODO: remove
|
|
|
|
[Signal] public delegate void InteractedToolEventHandler(int id); // TODO: remove
|
|
|
|
|
|
|
|
|
|
|
|
@ -106,6 +115,7 @@ public partial class InteractionArea2D : Node2D
|
|
|
|
|
|
|
|
|
|
|
|
EmitSignal(SignalName.InteractedTool, _id);
|
|
|
|
EmitSignal(SignalName.InteractedTool, _id);
|
|
|
|
EmitSignal(SignalName.Interacted);
|
|
|
|
EmitSignal(SignalName.Interacted);
|
|
|
|
|
|
|
|
_interactionCounter++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -120,4 +130,26 @@ public partial class InteractionArea2D : Node2D
|
|
|
|
_active = !_active;
|
|
|
|
_active = !_active;
|
|
|
|
_label.Hide();
|
|
|
|
_label.Hide();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region SAVE AND LOAD
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void UpdateSaveData()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var payloadData = new Dictionary<string, Variant>
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
{ "interaction counter", _interactionCounter }
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SavegameService.AppendDataToSave(_sceneKeyProvider.Payload.AsString(), SaveId + _sceneID.Payload.AsString(), payloadData);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void LoadFromSaveData()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var sceneName = _sceneKeyProvider.Payload.AsString();
|
|
|
|
|
|
|
|
var id = SaveId + _sceneID.Payload.AsString();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Dictionary<string, Variant> save = SavegameService.GetSaveData(sceneName, id);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
}
|
|
|
|
}
|