Files
EGJ25/addons/godot_state_charts/csharp/StateChartSerializer.cs
minimata 9a79715e47
All checks were successful
Create tag and build when new code gets to main / BumpTag (push) Successful in 6s
Create tag and build when new code gets to main / Export (push) Successful in 3m16s
feat: made sure the aspect ration fit a pixel art game and added useful addons
2025-06-27 15:19:12 +02: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();
}
}