Skip to content

Store action-specific state in ActionState #60

@alice-i-cecile

Description

@alice-i-cecile

Many actions are only meaningful in association with non-enumerable data.

A very useful pattern here is to store information in the enum variant, and then update that appropriately.

We want to be able to express:

#[derive(Actionlike, Clone)]
enum ArpgAction {
    Movement(Direction),
    Ability1,
    Ability2,
    Ability3,
    Ability4,
    Ultimate,
}

input_map.insert(ArpgAction::Movement(Direction::NORTH), KeyCode::Up);

let ArpgAction::Movement(direction) = action_state.get_value::<ArpgAction::Movement>();

Unfortunately, a reasonable API for the last step seems to be completely blocked on rust-lang/rfcs#2593, which, unsurprisingly, is postponed indefinitely 🙃

Metadata

Metadata

Assignees

No one assigned

    Labels

    controversialRequires a heightened standard of reviewenhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions