An experimental, status effects-as-entities system for Bevy.
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Suport cloning unregistered components.

+10 -14
+5 -13
src/bundle_inspector.rs
··· 32 32 impl BundleInspector { 33 33 /// Stashes a bundle so it can be inspected. 34 34 /// 35 - /// Should be [cleared](Self::clear) when finished. 35 + /// Calls [`clear`](Self::clear) first to avoid leakage. 36 36 pub fn stash_bundle<B: Bundle>(&mut self, bundle: B) -> &mut Self { 37 37 self.clear(); 38 38 ··· 87 87 /// 88 88 /// # Errors 89 89 /// Will return an error if: 90 - /// - The component has not been registered in `dst_world`. 91 - /// - The component cannot be copied (implements drop). 90 + /// - The component cannot be cloned ([`ComponentCloneBehavior::Ignore`]). 92 91 /// - The stashed bundle doesn't contain the component. 93 92 /// - The destination entity doesn't exist in `dst_world`. 94 93 /// ··· 101 100 type_id: TypeId, 102 101 src_component_id: ComponentId, 103 102 ) -> Result<&Self, MultiWorldCopyError> { 104 - let Some(dst_component_id) = dst_world.components().get_id(type_id) else { 105 - return Err(MultiWorldCopyError::Unregistered(type_id)); 106 - }; 107 - 108 - let component_info = dst_world.components().get_info(dst_component_id).unwrap(); // Already checked that component is registered. 103 + // 104 + let dst_component_id = dst_world.components().get_id(type_id).unwrap(); 105 + let component_info = dst_world.components().get_info(dst_component_id).unwrap(); 109 106 110 107 match component_info.clone_behavior() { 111 108 ComponentCloneBehavior::Default | ComponentCloneBehavior::Custom(_) => {} ··· 163 160 164 161 #[derive(Debug, Eq, PartialEq, Clone)] 165 162 pub enum MultiWorldCopyError { 166 - Unregistered(TypeId), 167 163 Uncloneable(DebugName), 168 164 MissingDstEntity(Entity), 169 165 MissingSrcComponent(DebugName, Entity), ··· 172 168 impl std::fmt::Display for MultiWorldCopyError { 173 169 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { 174 170 match self { 175 - MultiWorldCopyError::Unregistered(type_id) => write!( 176 - f, 177 - "Component with {type_id:?} has not been registered in the destination world, and therefor cannot be cloned." 178 - ), 179 171 MultiWorldCopyError::Uncloneable(name) => write!( 180 172 f, 181 173 "Component {name} cannot be cloned, and therefor cannot be inserted using merge mode.",
+5 -1
src/command.rs
··· 109 109 EffectMode::Insert => { 110 110 world.entity_mut(old_entity).insert(self.bundle); 111 111 } 112 - EffectMode::Merge => self.merge(world, old_entity), 112 + EffectMode::Merge => { 113 + // Ensure that all components are registered in the main world for cloning into. 114 + world.register_bundle::<B>(); 115 + self.merge(world, old_entity) 116 + } 113 117 } 114 118 } 115 119 }