bevyengine / bevyengine/bevy

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

Open
#14,236 1 comment 0 reactions 0 assignees View on GitHub
A-ECS C-Usability D-Modest S-Ready-For-Implementation X-Contentious
Dominant language
Rust
Stars
48.2k
Forks
4.8k
Avg merge
3d 22h
Merged PRs (30d)
161

Description

## 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.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.