Skip to content

Reconfigure a state #577

@Ninho67

Description

@Ninho67

Hi guys and thanks for the good work.

I have a particular case that I am not capable of solving and need your help. I have several state machines defined with Stateless and some of them have inheritance:

  • StateMachineA
  • StateMachineB
  • StateMachineC

Each class has a ConfigureStateMachine() method where I do all the wiring of triggers for each state. Now if I have the following inheritance schema:

A <|- B <|- C

where some triggers defined for B are not valid for C (but the state machines are identical at 95%).

To illustrate:

// StateMachineA
// ...

protected virtual void ConfigureStateMachine()
{
    // Idle
    IdleStateConfiguration = StateMachine.Configure(MachineExecutionState.Idle);
    IdleStateConfiguration.Permit(StateTrigger.Collision, MachineExecutionState.Suspended);

    // ...
}
// StateMachineB
// ...

protected override void ConfigureStateMachine()
{
    // Idle
    // Here I'm only extending the base state machine, OK
    IdleStateConfiguration.Ignore(StateTrigger.Start);

    // ...
}
// StateMachineC
// ...

protected override void ConfigureStateMachine()
{
    // Idle
    // This won't work because because I have conflicting exit transitions
    IdleStateConfiguration
         .Permit(StateTrigger.Start, MachineExecutionState.Suspended);

    // ...
}

I would like to reset all the wirings of a state so that I can redefine it down the inheritance tree.
The only solution I have so far is to drop the inheritance, duplicate B and do the 5% changes that I need to have C. It is no big deal for small state machines but mine is really big.

Any chance we can get this feature in next release ?

Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions