Skip to content

Make Trigger::entity() panic on Entity::PLACEHOLDER and add Trigger::get_entity() #14236

Open
@MiniaczQ

Description

@MiniaczQ

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

Trying to perform commands on trigger entity can lead to errors later than expected (command execution instead of call site).

What solution would you like?

While Entity::PLACEHOLDER works great for the internals, the users should be presented with the standard two methods:

  • entity() - get a valid entity or panic
  • get_entity() - get a valid entity or none

This requires a breaking change on entity() which currently never panics, but can return Entity::PLACEHOLDER.

What alternative(s) have you considered?

Check for placeholder by oneself.

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-ModestA "normal" level of difficulty; suitable for simple features or challenging fixesS-Ready-For-ImplementationThis issue is ready for an implementation PR. Go for it!X-ContentiousThere are nontrivial implications that should be thought through

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions