|
|
|
|
@ -12,6 +12,7 @@ public partial class FieldActivator : Node, ISaveable
|
|
|
|
|
{
|
|
|
|
|
[Export] private FieldBehaviour2D _field;
|
|
|
|
|
[Export] private InteractionArea2D _activatorArea;
|
|
|
|
|
[Export] private Node _saveIdHolder;
|
|
|
|
|
|
|
|
|
|
private bool _used = false;
|
|
|
|
|
private bool _rakeInHand;
|
|
|
|
|
@ -47,6 +48,7 @@ public partial class FieldActivator : Node, ISaveable
|
|
|
|
|
/// <param name="activated"></param>
|
|
|
|
|
public void RakeActivated(bool activated)
|
|
|
|
|
{
|
|
|
|
|
GD.Print($"Rake was {activated}. Process mode: {ProcessMode}.");
|
|
|
|
|
if (_used || ProcessMode == ProcessModeEnum.Disabled)
|
|
|
|
|
return;
|
|
|
|
|
_rakeInHand = activated;
|
|
|
|
|
@ -55,6 +57,7 @@ public partial class FieldActivator : Node, ISaveable
|
|
|
|
|
|
|
|
|
|
private void ToggleInteractionArea()
|
|
|
|
|
{
|
|
|
|
|
GD.Print($"Toggle interaction area. Used: {_used}, rake in hand: {_rakeInHand}");
|
|
|
|
|
_activatorArea.IsActive = !_used && _rakeInHand;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -65,13 +68,18 @@ public partial class FieldActivator : Node, ISaveable
|
|
|
|
|
{ "field_activator_used", _used }
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
string id = GetMeta("SaveID").AsString();
|
|
|
|
|
// Building a unique id from the top node's save id and a qualifier to make it new.
|
|
|
|
|
string parent_id = _saveIdHolder.GetMeta("SaveID").AsString();
|
|
|
|
|
string id = $"{parent_id}_field_activator";
|
|
|
|
|
SavegameService.AppendDataToSave( id, payloadData);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void LoadFromSaveData()
|
|
|
|
|
{
|
|
|
|
|
string id = GetMeta("SaveID").AsString();
|
|
|
|
|
GD.Print("Loading field activator save data");
|
|
|
|
|
|
|
|
|
|
string parent_id = _saveIdHolder.GetMeta("SaveID").AsString();
|
|
|
|
|
string id = $"{parent_id}_field_activator";
|
|
|
|
|
|
|
|
|
|
Dictionary<string, Variant> save = SavegameService.GetSaveData(id);
|
|
|
|
|
if (save.Count > 0)
|
|
|
|
|
@ -80,6 +88,11 @@ public partial class FieldActivator : Node, ISaveable
|
|
|
|
|
{
|
|
|
|
|
_used = usedVar.AsBool();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
_used = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
GD.Print($"Field activator used state: {_used}");
|
|
|
|
|
}
|
|
|
|
|
}
|