bevy_input_bindings 0.0.2

High level, flexible and shareable input binding library for the Bevy game engine
Documentation
use bevy::prelude::*;

/// Added to an entity, the `ControlledBy` component will add the `Controlling` component to a
/// controller. This is one way to know which entities should react to:
/// - an action through the `controlling()` method
/// - a value by querying the `Controlling` component.
#[derive(Component, Reflect)]
#[relationship(relationship_target = Controlling)]
pub struct ControlledBy(pub Entity);

impl ControlledBy {
    /// Controller that control this entity
    pub fn controller(&self) -> Entity {
        self.0
    }
}

/// This is the immutable component, added through the `ControlledBy`/`Controlling` relationship
/// that allows to list all the entities a controller controls.
#[derive(Component, Deref, Reflect)]
#[relationship_target(relationship = ControlledBy)]
pub struct Controlling(Vec<Entity>);

impl Controlling {
    pub fn is_empty(&self) -> bool {
        self.0.is_empty()
    }

    /// List of controlled entities
    pub fn controlling<'a>(&'a self) -> &'a Vec<Entity> {
        &self.0
    }
}