Skip to content

A PreviousState Resource, accessible in OnEnter #21882

@ChristopherBiscardi

Description

@ChristopherBiscardi

What problem does this solve or what need does it fill?

There is State and NextState, but no PreviousState. This means to handle transitions you have to pre-specify all state transition variants at the type level with OnTransition{ exited: AppState::Previous, entered: AppState::Other }.

It would be useful if system in OnEnter could access the state that was recently exited or if OnTransition could support the root AppState instead of a specific variant.

What solution would you like?

Options:

  1. A readable PreviousState resource, similar to State and NextState.
  2. An OnTransition variant that can match any/all variants of a state.

What alternative(s) have you considered?

  • Specifying all transitions at the type level in separate.
  • Making the Resource that holds previous state in userland

Additional context

This feature was asked for by Calin, I am filing it for them after asking about their usecase since they don't have gh access at the moment.

my use-case here specifically is making a Gamestate variant, Refresh, which takes the PreviousState and uses it to determine what should happen (in a system that handles state refreshes).

  • Calin

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-StatesApp-level states machinesC-FeatureA new feature, making something new possibleD-StraightforwardSimple bug fixes and API improvements, docs, test and examplesS-Ready-For-ImplementationThis issue is ready for an implementation PR. Go for it!

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions