40 lines
1.5 KiB
C#
40 lines
1.5 KiB
C#
|
|
// <auto-generated/>
|
|
#pragma warning disable CS0105
|
|
using Code.Infrastructure.StateMachine;
|
|
|
|
using Code.Infrastructure.Camera.CameraStates;
|
|
|
|
#pragma warning restore CS0105
|
|
namespace Code.Infrastructure.Camera
|
|
{
|
|
|
|
public partial class CameraStateMachine : AbstractStateMachine<Code.Infrastructure.Camera.CameraMode,Code.Infrastructure.Camera.CameraStateMachineContext>
|
|
{
|
|
|
|
public CameraStateMachine(Code.Infrastructure.Camera.CameraStateMachineContext context, EventBus.EventBus eventBus) : base(context)
|
|
{
|
|
|
|
var stateNoneCameraState = new NoneCameraState(StateMachineContext,eventBus);
|
|
States.Add(stateNoneCameraState.myState, stateNoneCameraState);
|
|
|
|
}
|
|
|
|
protected override bool CheckTransitionAllowed(Code.Infrastructure.Camera.CameraMode nextState) => AllowedStates.HasFlag(nextState);
|
|
protected override void ResetAllowedTransitions() => AllowedStates = 0;
|
|
}
|
|
|
|
public static class CameraStateMachineExtensions
|
|
{
|
|
public static AbstractStateMachine<Code.Infrastructure.Camera.CameraMode, Code.Infrastructure.Camera.CameraStateMachineContext> AllowStateTransition(
|
|
this AbstractStateMachine<Code.Infrastructure.Camera.CameraMode, Code.Infrastructure.Camera.CameraStateMachineContext> stateMachine, Code.Infrastructure.Camera.CameraMode state)
|
|
{
|
|
if (stateMachine == null) return null;
|
|
|
|
stateMachine.AllowedStates |= state;
|
|
return stateMachine;
|
|
}
|
|
}
|
|
}
|
|
|