Files
MovementTests/addons/godot_state_charts/csharp/StateChartSerializer.cs
Minimata b198aba09b
Some checks failed
Create tag and build when new code gets to main / BumpTag (push) Successful in 21s
Create tag and build when new code gets to main / Export (push) Failing after 1m28s
updating state chart addon
2026-01-27 19:13:53 +01:00

33 lines
1.3 KiB
C#

namespace GodotStateCharts;
using Godot;
public class StateChartSerializer
{
private static readonly GodotObject Wrapped = GD.Load("res://addons/godot_state_charts/state_chart_serializer.gd");
/// <summary>
/// Serializes the given state chart and returns a serialized object that
/// can be stored as part of a saved game.
/// </summary>
/// <param name="stateChart">the state chart to serialize</param>
/// <returns>a resource containing the serialized state</returns>
public static SerializedStateChart Serialize(StateChart stateChart)
{
return SerializedStateChart.Of(Wrapped.Call("serialize", stateChart.Wrapped).As<Resource>());
}
/// <summary>
/// Deserializes the given serialized state chart into the given state chart. Returns a set of
/// error messages. If the serialized state chart was no longer compatible with the current state
/// chart, nothing will happen. The operation is successful when the returned array is empty.
/// </summary>
public static string[] Deserialize(SerializedStateChart serializedStateChart, StateChart stateChart)
{
var variant = Wrapped.Call("deserialize", serializedStateChart.Wrapped, stateChart.Wrapped);
return variant.AsStringArray();
}
}