// ReSharper disable once CheckNamespace namespace GodotStateCharts { using Godot; using System; /// /// A wrapper around the state node that allows interacting with it from C#. /// public class StateChartState : NodeWrapper { /// /// Called when the state is entered. /// public event Action StateEntered { add => Wrapped.Connect(SignalName.StateEntered, Callable.From(value)); remove => Wrapped.Disconnect(SignalName.StateEntered, Callable.From(value)); } /// /// Called when the state is exited. /// public event Action StateExited { add => Wrapped.Connect(SignalName.StateExited, Callable.From(value)); remove => Wrapped.Disconnect(SignalName.StateExited, Callable.From(value)); } /// /// Called when the state receives an event. Only called if the state is active. /// public event Action EventReceived { add => Wrapped.Connect(SignalName.EventReceived, Callable.From(value)); remove => Wrapped.Disconnect(SignalName.EventReceived, Callable.From(value)); } /// /// Called when the state is processing. /// public event Action StateProcessing { add => Wrapped.Connect(SignalName.StateProcessing, Callable.From(value)); remove => Wrapped.Disconnect(SignalName.StateProcessing, Callable.From(value)); } /// /// Called when the state is physics processing. /// public event Action StatePhysicsProcessing { add => Wrapped.Connect(SignalName.StatePhysicsProcessing, Callable.From(value)); remove => Wrapped.Disconnect(SignalName.StatePhysicsProcessing, Callable.From(value)); } /// /// Called when the state chart Step function is called. /// public event Action StateStepped { add => Wrapped.Connect(SignalName.StateStepped, Callable.From(value)); remove => Wrapped.Disconnect(SignalName.StateStepped, Callable.From(value)); } /// /// Called when the state is receiving input. /// public event Action StateInput { add => Wrapped.Connect(SignalName.StateInput, Callable.From(value)); remove => Wrapped.Disconnect(SignalName.StateInput, Callable.From(value)); } /// /// Called when the state is receiving unhandled input. /// public event Action StateUnhandledInput { add => Wrapped.Connect(SignalName.StateUnhandledInput, Callable.From(value)); remove => Wrapped.Disconnect(SignalName.StateUnhandledInput, Callable.From(value)); } /// /// Called every frame while a delayed transition is pending for this state. /// Returns the initial delay and the remaining delay of the transition. /// public event Action TransitionPending { add => Wrapped.Connect(SignalName.TransitionPending, Callable.From(value)); remove => Wrapped.Disconnect(SignalName.TransitionPending, Callable.From(value)); } protected StateChartState(Node wrapped) : base(wrapped) {} /// /// Creates a wrapper object around the given node and verifies that the node /// is actually a state. The wrapper object can then be used to interact /// with the state chart from C#. /// /// the node that is the state /// a State wrapper. /// ArgumentException if the node is not a state. public static StateChartState Of(Node state) { if (state.GetScript().As