bevyengine / bevy

A refreshingly simple data-driven game engine built in Rust
https://bevyengine.org
Apache License 2.0
35.03k stars 3.43k forks source link

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

Open MiniaczQ opened 2 months ago

MiniaczQ commented 2 months ago

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:

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.

janhohenheim commented 1 month ago

In the vein of https://github.com/bevyengine/bevy/pull/14268, maybe there should only be a get_entity() and no entity()