Skip to content

Inconsistent API between observers and commands for entity-targetting #14272

Closed as duplicate of#19564
@benfrankel

Description

@benfrankel

Global command vs event:

commands.add(command);
commands.trigger(event);

Entity-local command vs event:

commands.spawn(bundle).add(entity_command).set_parent(parent);
{
    let entity = commands.spawn(bundle).id();
    commands.trigger_targets(event, entity);
    commands.entity(entity)
}.set_parent(parent);

Or with a more ergonomic API (#14233):

commands.spawn(bundle).add(entity_command).set_parent(parent);
commands.spawn(bundle).trigger(event).set_parent(parent);

The difference remains that commands statically distinguish Command and EntityCommand, while events only have Event, with observers having to determine at runtime whether their Trigger includes an entity (currently that entails checking trigger.entity() == Entity::PLACEHOLDER, see #14236).

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-ECSEntities, components, systems, and eventsC-UsabilityA targeted quality-of-life change that makes Bevy easier to useD-TrivialNice and easy! A great choice to get started with BevyS-Ready-For-ImplementationThis issue is ready for an implementation PR. Go for it!X-UncontroversialThis work is generally agreed upon

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions