//
#pragma warning disable CS0105
using Code.Infrastructure.StateMachine;
using Code.Infrastructure.App.States;
using Code.Example.Platformer;
using Code.Infrastructure.App.States;
#pragma warning restore CS0105
namespace Code.Infrastructure.App
{
public partial class AppStateMachine : AbstractStateMachine
{
public AppStateMachine(Code.Infrastructure.App.AppStateMachineContext context, EventBus.EventBus eventBus) : base(context)
{
var stateBootstrapState = new BootstrapState(StateMachineContext,eventBus);
States.Add(stateBootstrapState.myState, stateBootstrapState);
var statePlatformerState = new PlatformerState(StateMachineContext,eventBus);
States.Add(statePlatformerState.myState, statePlatformerState);
var stateMainMenuState = new MainMenuState(StateMachineContext,eventBus);
States.Add(stateMainMenuState.myState, stateMainMenuState);
}
protected override bool CheckTransitionAllowed(Code.Infrastructure.App.AppStates nextState) => AllowedStates.HasFlag(nextState);
protected override void ResetAllowedTransitions() => AllowedStates = 0;
}
public static class AppStateMachineExtensions
{
public static AbstractStateMachine AllowStateTransition(
this AbstractStateMachine stateMachine, Code.Infrastructure.App.AppStates state)
{
if (stateMachine == null) return null;
stateMachine.AllowedStates |= state;
return stateMachine;
}
}
}