bevy/examples/animation
Eagster 064e5e48b4
Remove entity placeholder from observers (#19440)
# Objective

`Entity::PLACEHOLDER` acts as a magic number that will *probably* never
really exist, but it certainly could. And, `Entity` has a niche, so the
only reason to use `PLACEHOLDER` is as an alternative to `MaybeUninit`
that trades safety risks for logic risks.

As a result, bevy has generally advised against using `PLACEHOLDER`, but
we still use if for a lot internally. This pr starts removing internal
uses of it, starting from observers.

## Solution

Change all trigger target related types from `Entity` to
`Option<Entity>`

Small migration guide to come.

## Testing

CI

## Future Work

This turned a lot of code from 

```rust
trigger.target()
```

to 

```rust
trigger.target().unwrap()
```

The extra panic is no worse than before; it's just earlier than
panicking after passing the placeholder to something else.

But this is kinda annoying. 

I would like to add a `TriggerMode` or something to `Event` that would
restrict what kinds of targets can be used for that event. Many events
like `Removed` etc, are always triggered with a target. We can make
those have a way to assume Some, etc. But I wanted to save that for a
future pr.
2025-06-09 19:37:56 +00:00
..
animated_mesh_control.rs Revert "Replace Ambient Lights with Environment Map Lights (#17482)" (#18167) 2025-03-05 23:08:46 +00:00
animated_mesh_events.rs Remove entity placeholder from observers (#19440) 2025-06-09 19:37:56 +00:00
animated_mesh.rs Remove entity placeholder from observers (#19440) 2025-06-09 19:37:56 +00:00
animated_transform.rs Revert "Replace Ambient Lights with Environment Map Lights (#17482)" (#18167) 2025-03-05 23:08:46 +00:00
animated_ui.rs Relationships (non-fragmenting, one-to-many) (#17398) 2025-01-18 22:20:30 +00:00
animation_events.rs Split Camera.hdr out into a new component (#18873) 2025-05-26 19:24:45 +00:00
animation_graph.rs separate border colors (#18682) 2025-05-26 16:57:13 +00:00
animation_masks.rs separate border colors (#18682) 2025-05-26 16:57:13 +00:00
color_animation.rs Improve Bevy's double-precision story for third-party crates (#19194) 2025-06-08 02:02:47 +00:00
custom_skinned_mesh.rs Revert "Replace Ambient Lights with Environment Map Lights (#17482)" (#18167) 2025-03-05 23:08:46 +00:00
eased_motion.rs AnimatedField and Rework Evaluators (#16484) 2024-11-27 22:19:55 +00:00
easing_functions.rs Add ways to configure EasingFunction::Steps via new StepConfig (#17752) 2025-02-11 22:19:01 +00:00
gltf_skinned_mesh.rs Switch ChildOf back to tuple struct (#18672) 2025-04-02 00:10:10 +00:00
morph_targets.rs Revert "Replace Ambient Lights with Environment Map Lights (#17482)" (#18167) 2025-03-05 23:08:46 +00:00