// ReSharper disable once CheckNamespace
namespace GodotStateCharts
{
using Godot;
using System;
///
/// Wrapper around the GDScript state chart node. Allows interacting with the state chart.
///
public class StateChart : NodeWrapper
{
///
/// Emitted when the state chart receives an event. This will be
/// emitted no matter which state is currently active and can be
/// useful to trigger additional logic elsewhere in the game
/// without having to create a custom event bus. It is also used
/// by the state chart debugger. Note that this will emit the
/// events in the order in which they are processed, which may
/// be different from the order in which they were received. This is
/// because the state chart will always finish processing one event
/// fully before processing the next. If an event is received
/// while another is still processing, it will be enqueued.
///
public event Action EventReceived
{
add => Wrapped.Connect(SignalName.EventReceived, Callable.From(value));
remove => Wrapped.Disconnect(SignalName.EventReceived, Callable.From(value));
}
protected StateChart(Node wrapped) : base(wrapped)
{
}
///
/// Creates a wrapper object around the given node and verifies that the node
/// is actually a state chart. The wrapper object can then be used to interact
/// with the state chart from C#.
///
/// the node that is the state chart
/// a StateChart wrapper.
/// ArgumentException if the node is not a state chart.
public static StateChart Of(Node stateChart)
{
if (stateChart.GetScript().As