bevy/crates/bevy_ecs/src
Georg Friedrich Schuppe 98a08cf495 feat: remove_component for ReflectComponent (#2682)
# Objective

While implementing a plugin for my rollback networking library, I needed to load/save parts of the world. For this, I made a WorldSnapshot that works quite like the current DynamicScene. Using a TypeRegistry to register component types I want to save/load and then using ReflectComponents methods to add or apply components of the given types. 

However, I noticed there is no method to remove components from entities through the ReflectComponent.

## Solution

I added a `remove_component` field to the `ReflectComponent` struct, as well as a `pub fn remove_component(&self, world: &mut World, entity: Entity)` to call that function in `remove_component`. This follows exactly the same pattern all other methods/fields in this struct look like.

This is an example how it could be used (at least how I would use it):
6c003f86f1/src/world_snapshot.rs (L133)
2021-08-18 20:57:58 +00:00
..
entity Inline world get (#2520) 2021-07-27 23:19:26 +00:00
query System Param Lifetime Split (#2605) 2021-08-15 20:51:53 +00:00
schedule Fix some nightly clippy lints (#2522) 2021-07-29 20:52:15 +00:00
storage Refactor ECS to reduce the dependency on a 1-to-1 mapping between components and real rust types (#2490) 2021-07-28 19:29:12 +00:00
system System Param Lifetime Split (#2605) 2021-08-15 20:51:53 +00:00
world Remove empty module (#2558) 2021-07-28 03:10:55 +00:00
archetype.rs small ecs cleanup and remove_bundle drop bugfix (#2172) 2021-05-18 19:25:57 +00:00
bundle.rs Remove with bundle filter (#2623) 2021-08-10 01:55:52 +00:00
change_detection.rs Allow Option<NonSend<T>> and Option<NonSendMut<T>> as SystemParam (#2345) 2021-06-26 19:29:38 +00:00
component.rs Refactor ECS to reduce the dependency on a 1-to-1 mapping between components and real rust types (#2490) 2021-07-28 19:29:12 +00:00
event.rs System Param Lifetime Split (#2605) 2021-08-15 20:51:53 +00:00
lib.rs Remove with bundle filter (#2623) 2021-08-10 01:55:52 +00:00
reflect.rs feat: remove_component for ReflectComponent (#2682) 2021-08-18 20:57:58 +00:00