Skip all cloning logic for ComponentCloneBehavior::Ignore

This commit is contained in:
eugineerd 2025-07-09 17:05:16 +00:00
parent bf77962511
commit 2667dd1f08

View File

@ -589,13 +589,18 @@ impl EntityCloner {
} }
filter.clone_components(source_archetype, target_archetype, |component| { filter.clone_components(source_archetype, target_archetype, |component| {
let handler = match state.clone_behavior_overrides.get(&component) { let handler = match state.clone_behavior_overrides.get(&component).or_else(|| {
Some(clone_behavior) => clone_behavior.resolve(state.default_clone_fn), world
None => world
.components() .components()
.get_info(component) .get_info(component)
.map(|info| info.clone_behavior().resolve(state.default_clone_fn)) .map(ComponentInfo::clone_behavior)
.unwrap_or(state.default_clone_fn), }) {
Some(behavior) => match behavior {
ComponentCloneBehavior::Default => state.default_clone_fn,
ComponentCloneBehavior::Ignore => return,
ComponentCloneBehavior::Custom(custom) => *custom,
},
None => state.default_clone_fn,
}; };
// SAFETY: This component exists because it is present on the archetype. // SAFETY: This component exists because it is present on the archetype.