Support skipping Relationship on_replace hooks (#18378)
# Objective Fixes #18357 ## Solution Generalize `RelationshipInsertHookMode` to `RelationshipHookMode`, wire it up to on_replace execution, and use it in the `Relationship::on_replace` hook.
This commit is contained in:
parent
ac53e4c482
commit
6d6054116a
@ -18,7 +18,7 @@ use crate::{
|
|||||||
observer::Observers,
|
observer::Observers,
|
||||||
prelude::World,
|
prelude::World,
|
||||||
query::DebugCheckedUnwrap,
|
query::DebugCheckedUnwrap,
|
||||||
relationship::RelationshipInsertHookMode,
|
relationship::RelationshipHookMode,
|
||||||
storage::{SparseSetIndex, SparseSets, Storages, Table, TableRow},
|
storage::{SparseSetIndex, SparseSets, Storages, Table, TableRow},
|
||||||
world::{unsafe_world_cell::UnsafeWorldCell, EntityWorldMut, ON_ADD, ON_INSERT, ON_REPLACE},
|
world::{unsafe_world_cell::UnsafeWorldCell, EntityWorldMut, ON_ADD, ON_INSERT, ON_REPLACE},
|
||||||
};
|
};
|
||||||
@ -1104,7 +1104,7 @@ impl<'w> BundleInserter<'w> {
|
|||||||
bundle: T,
|
bundle: T,
|
||||||
insert_mode: InsertMode,
|
insert_mode: InsertMode,
|
||||||
caller: MaybeLocation,
|
caller: MaybeLocation,
|
||||||
relationship_insert_hook_mode: RelationshipInsertHookMode,
|
relationship_hook_mode: RelationshipHookMode,
|
||||||
) -> (EntityLocation, T::Effect) {
|
) -> (EntityLocation, T::Effect) {
|
||||||
let bundle_info = self.bundle_info.as_ref();
|
let bundle_info = self.bundle_info.as_ref();
|
||||||
let archetype_after_insert = self.archetype_after_insert.as_ref();
|
let archetype_after_insert = self.archetype_after_insert.as_ref();
|
||||||
@ -1130,6 +1130,7 @@ impl<'w> BundleInserter<'w> {
|
|||||||
entity,
|
entity,
|
||||||
archetype_after_insert.iter_existing(),
|
archetype_after_insert.iter_existing(),
|
||||||
caller,
|
caller,
|
||||||
|
relationship_hook_mode,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1317,7 +1318,7 @@ impl<'w> BundleInserter<'w> {
|
|||||||
entity,
|
entity,
|
||||||
archetype_after_insert.iter_inserted(),
|
archetype_after_insert.iter_inserted(),
|
||||||
caller,
|
caller,
|
||||||
relationship_insert_hook_mode,
|
relationship_hook_mode,
|
||||||
);
|
);
|
||||||
if new_archetype.has_insert_observer() {
|
if new_archetype.has_insert_observer() {
|
||||||
deferred_world.trigger_observers(
|
deferred_world.trigger_observers(
|
||||||
@ -1336,7 +1337,7 @@ impl<'w> BundleInserter<'w> {
|
|||||||
entity,
|
entity,
|
||||||
archetype_after_insert.iter_added(),
|
archetype_after_insert.iter_added(),
|
||||||
caller,
|
caller,
|
||||||
relationship_insert_hook_mode,
|
relationship_hook_mode,
|
||||||
);
|
);
|
||||||
if new_archetype.has_insert_observer() {
|
if new_archetype.has_insert_observer() {
|
||||||
deferred_world.trigger_observers(
|
deferred_world.trigger_observers(
|
||||||
@ -1484,7 +1485,7 @@ impl<'w> BundleSpawner<'w> {
|
|||||||
entity,
|
entity,
|
||||||
bundle_info.iter_contributed_components(),
|
bundle_info.iter_contributed_components(),
|
||||||
caller,
|
caller,
|
||||||
RelationshipInsertHookMode::Run,
|
RelationshipHookMode::Run,
|
||||||
);
|
);
|
||||||
if archetype.has_insert_observer() {
|
if archetype.has_insert_observer() {
|
||||||
deferred_world.trigger_observers(
|
deferred_world.trigger_observers(
|
||||||
|
@ -6,7 +6,7 @@ use crate::{
|
|||||||
change_detection::{MaybeLocation, MAX_CHANGE_AGE},
|
change_detection::{MaybeLocation, MAX_CHANGE_AGE},
|
||||||
entity::{ComponentCloneCtx, Entity, SourceComponent},
|
entity::{ComponentCloneCtx, Entity, SourceComponent},
|
||||||
query::DebugCheckedUnwrap,
|
query::DebugCheckedUnwrap,
|
||||||
relationship::RelationshipInsertHookMode,
|
relationship::RelationshipHookMode,
|
||||||
resource::Resource,
|
resource::Resource,
|
||||||
storage::{SparseSetIndex, SparseSets, Table, TableRow},
|
storage::{SparseSetIndex, SparseSets, Table, TableRow},
|
||||||
system::{Commands, Local, SystemParam},
|
system::{Commands, Local, SystemParam},
|
||||||
@ -584,7 +584,7 @@ pub struct HookContext {
|
|||||||
/// The caller location is `Some` if the `track_caller` feature is enabled.
|
/// The caller location is `Some` if the `track_caller` feature is enabled.
|
||||||
pub caller: MaybeLocation,
|
pub caller: MaybeLocation,
|
||||||
/// Configures how relationship hooks will run
|
/// Configures how relationship hooks will run
|
||||||
pub relationship_insert_hook_mode: RelationshipInsertHookMode,
|
pub relationship_hook_mode: RelationshipHookMode,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// [`World`]-mutating functions that run as part of lifecycle events of a [`Component`].
|
/// [`World`]-mutating functions that run as part of lifecycle events of a [`Component`].
|
||||||
|
@ -10,7 +10,7 @@ use alloc::boxed::Box;
|
|||||||
use crate::component::{ComponentCloneBehavior, ComponentCloneFn};
|
use crate::component::{ComponentCloneBehavior, ComponentCloneFn};
|
||||||
use crate::entity::hash_map::EntityHashMap;
|
use crate::entity::hash_map::EntityHashMap;
|
||||||
use crate::entity::{Entities, EntityMapper};
|
use crate::entity::{Entities, EntityMapper};
|
||||||
use crate::relationship::RelationshipInsertHookMode;
|
use crate::relationship::RelationshipHookMode;
|
||||||
use crate::system::Commands;
|
use crate::system::Commands;
|
||||||
use crate::{
|
use crate::{
|
||||||
bundle::Bundle,
|
bundle::Bundle,
|
||||||
@ -415,7 +415,7 @@ impl<'a> BundleScratch<'a> {
|
|||||||
self,
|
self,
|
||||||
world: &mut World,
|
world: &mut World,
|
||||||
entity: Entity,
|
entity: Entity,
|
||||||
relationship_hook_insert_mode: RelationshipInsertHookMode,
|
relationship_hook_insert_mode: RelationshipHookMode,
|
||||||
) {
|
) {
|
||||||
// SAFETY:
|
// SAFETY:
|
||||||
// - All `component_ids` are from the same world as `target` entity
|
// - All `component_ids` are from the same world as `target` entity
|
||||||
@ -453,7 +453,7 @@ impl EntityCloner {
|
|||||||
world: &mut World,
|
world: &mut World,
|
||||||
source: Entity,
|
source: Entity,
|
||||||
mapper: &mut dyn EntityMapper,
|
mapper: &mut dyn EntityMapper,
|
||||||
relationship_hook_insert_mode: RelationshipInsertHookMode,
|
relationship_hook_insert_mode: RelationshipHookMode,
|
||||||
) -> Entity {
|
) -> Entity {
|
||||||
let target = mapper.get_mapped(source);
|
let target = mapper.get_mapped(source);
|
||||||
// PERF: reusing allocated space across clones would be more efficient. Consider an allocation model similar to `Commands`.
|
// PERF: reusing allocated space across clones would be more efficient. Consider an allocation model similar to `Commands`.
|
||||||
@ -581,16 +581,15 @@ impl EntityCloner {
|
|||||||
mapper: &mut dyn EntityMapper,
|
mapper: &mut dyn EntityMapper,
|
||||||
) -> Entity {
|
) -> Entity {
|
||||||
// All relationships on the root should have their hooks run
|
// All relationships on the root should have their hooks run
|
||||||
let target =
|
let target = self.clone_entity_internal(world, source, mapper, RelationshipHookMode::Run);
|
||||||
self.clone_entity_internal(world, source, mapper, RelationshipInsertHookMode::Run);
|
|
||||||
let child_hook_insert_mode = if self.linked_cloning {
|
let child_hook_insert_mode = if self.linked_cloning {
|
||||||
// When spawning "linked relationships", we want to ignore hooks for relationships we are spawning, while
|
// When spawning "linked relationships", we want to ignore hooks for relationships we are spawning, while
|
||||||
// still registering with original relationship targets that are "not linked" to the current recursive spawn.
|
// still registering with original relationship targets that are "not linked" to the current recursive spawn.
|
||||||
RelationshipInsertHookMode::RunIfNotLinked
|
RelationshipHookMode::RunIfNotLinked
|
||||||
} else {
|
} else {
|
||||||
// If we are not cloning "linked relationships" recursively, then we want any cloned relationship components to
|
// If we are not cloning "linked relationships" recursively, then we want any cloned relationship components to
|
||||||
// register themselves with their original relationship target.
|
// register themselves with their original relationship target.
|
||||||
RelationshipInsertHookMode::Run
|
RelationshipHookMode::Run
|
||||||
};
|
};
|
||||||
loop {
|
loop {
|
||||||
let queued = self.clone_queue.pop_front();
|
let queued = self.clone_queue.pop_front();
|
||||||
|
@ -331,7 +331,7 @@ mod tests {
|
|||||||
use crate::{
|
use crate::{
|
||||||
entity::Entity,
|
entity::Entity,
|
||||||
hierarchy::{ChildOf, Children},
|
hierarchy::{ChildOf, Children},
|
||||||
relationship::RelationshipTarget,
|
relationship::{RelationshipHookMode, RelationshipTarget},
|
||||||
spawn::{Spawn, SpawnRelated},
|
spawn::{Spawn, SpawnRelated},
|
||||||
world::World,
|
world::World,
|
||||||
};
|
};
|
||||||
@ -492,4 +492,21 @@ mod tests {
|
|||||||
let id = world.spawn(Children::spawn((Spawn(()), Spawn(())))).id();
|
let id = world.spawn(Children::spawn((Spawn(()), Spawn(())))).id();
|
||||||
assert_eq!(world.entity(id).get::<Children>().unwrap().len(), 2,);
|
assert_eq!(world.entity(id).get::<Children>().unwrap().len(), 2,);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn child_replace_hook_skip() {
|
||||||
|
let mut world = World::new();
|
||||||
|
let parent = world.spawn_empty().id();
|
||||||
|
let other = world.spawn_empty().id();
|
||||||
|
let child = world.spawn(ChildOf { parent }).id();
|
||||||
|
world.entity_mut(child).insert_with_relationship_hook_mode(
|
||||||
|
ChildOf { parent: other },
|
||||||
|
RelationshipHookMode::Skip,
|
||||||
|
);
|
||||||
|
assert_eq!(
|
||||||
|
&**world.entity(parent).get::<Children>().unwrap(),
|
||||||
|
&[child],
|
||||||
|
"Children should still have the old value, as on_insert/on_replace didn't run"
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@ use crate::{
|
|||||||
bundle::BundleFromComponents,
|
bundle::BundleFromComponents,
|
||||||
entity::EntityMapper,
|
entity::EntityMapper,
|
||||||
prelude::Bundle,
|
prelude::Bundle,
|
||||||
relationship::RelationshipInsertHookMode,
|
relationship::RelationshipHookMode,
|
||||||
world::{EntityMut, EntityWorldMut},
|
world::{EntityMut, EntityWorldMut},
|
||||||
};
|
};
|
||||||
use bevy_reflect::{
|
use bevy_reflect::{
|
||||||
@ -42,7 +42,7 @@ pub struct ReflectBundleFns {
|
|||||||
&dyn PartialReflect,
|
&dyn PartialReflect,
|
||||||
&TypeRegistry,
|
&TypeRegistry,
|
||||||
&mut dyn EntityMapper,
|
&mut dyn EntityMapper,
|
||||||
RelationshipInsertHookMode,
|
RelationshipHookMode,
|
||||||
),
|
),
|
||||||
/// Function pointer implementing [`ReflectBundle::remove`].
|
/// Function pointer implementing [`ReflectBundle::remove`].
|
||||||
pub remove: fn(&mut EntityWorldMut),
|
pub remove: fn(&mut EntityWorldMut),
|
||||||
@ -93,15 +93,9 @@ impl ReflectBundle {
|
|||||||
bundle: &dyn PartialReflect,
|
bundle: &dyn PartialReflect,
|
||||||
registry: &TypeRegistry,
|
registry: &TypeRegistry,
|
||||||
mapper: &mut dyn EntityMapper,
|
mapper: &mut dyn EntityMapper,
|
||||||
relationship_insert_hook_mode: RelationshipInsertHookMode,
|
relationship_hook_mode: RelationshipHookMode,
|
||||||
) {
|
) {
|
||||||
(self.0.apply_or_insert_mapped)(
|
(self.0.apply_or_insert_mapped)(entity, bundle, registry, mapper, relationship_hook_mode);
|
||||||
entity,
|
|
||||||
bundle,
|
|
||||||
registry,
|
|
||||||
mapper,
|
|
||||||
relationship_insert_hook_mode,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Removes this [`Bundle`] type from the entity. Does nothing if it doesn't exist.
|
/// Removes this [`Bundle`] type from the entity. Does nothing if it doesn't exist.
|
||||||
@ -183,8 +177,11 @@ impl<B: Bundle + Reflect + TypePath + BundleFromComponents> FromType<B> for Refl
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
apply_or_insert_mapped:
|
apply_or_insert_mapped: |entity,
|
||||||
|entity, reflected_bundle, registry, mapper, relationship_insert_hook_mode| {
|
reflected_bundle,
|
||||||
|
registry,
|
||||||
|
mapper,
|
||||||
|
relationship_hook_mode| {
|
||||||
if let Some(reflect_component) =
|
if let Some(reflect_component) =
|
||||||
registry.get_type_data::<ReflectComponent>(TypeId::of::<B>())
|
registry.get_type_data::<ReflectComponent>(TypeId::of::<B>())
|
||||||
{
|
{
|
||||||
@ -193,7 +190,7 @@ impl<B: Bundle + Reflect + TypePath + BundleFromComponents> FromType<B> for Refl
|
|||||||
reflected_bundle,
|
reflected_bundle,
|
||||||
registry,
|
registry,
|
||||||
mapper,
|
mapper,
|
||||||
relationship_insert_hook_mode,
|
relationship_hook_mode,
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
match reflected_bundle.reflect_ref() {
|
match reflected_bundle.reflect_ref() {
|
||||||
@ -203,7 +200,7 @@ impl<B: Bundle + Reflect + TypePath + BundleFromComponents> FromType<B> for Refl
|
|||||||
field,
|
field,
|
||||||
registry,
|
registry,
|
||||||
mapper,
|
mapper,
|
||||||
relationship_insert_hook_mode,
|
relationship_hook_mode,
|
||||||
);
|
);
|
||||||
}),
|
}),
|
||||||
ReflectRef::Tuple(bundle) => bundle.iter_fields().for_each(|field| {
|
ReflectRef::Tuple(bundle) => bundle.iter_fields().for_each(|field| {
|
||||||
@ -212,7 +209,7 @@ impl<B: Bundle + Reflect + TypePath + BundleFromComponents> FromType<B> for Refl
|
|||||||
field,
|
field,
|
||||||
registry,
|
registry,
|
||||||
mapper,
|
mapper,
|
||||||
relationship_insert_hook_mode,
|
relationship_hook_mode,
|
||||||
);
|
);
|
||||||
}),
|
}),
|
||||||
_ => panic!(
|
_ => panic!(
|
||||||
@ -259,7 +256,7 @@ fn apply_or_insert_field_mapped(
|
|||||||
field: &dyn PartialReflect,
|
field: &dyn PartialReflect,
|
||||||
registry: &TypeRegistry,
|
registry: &TypeRegistry,
|
||||||
mapper: &mut dyn EntityMapper,
|
mapper: &mut dyn EntityMapper,
|
||||||
relationship_insert_hook_mode: RelationshipInsertHookMode,
|
relationship_hook_mode: RelationshipHookMode,
|
||||||
) {
|
) {
|
||||||
let Some(type_id) = field.try_as_reflect().map(Any::type_id) else {
|
let Some(type_id) = field.try_as_reflect().map(Any::type_id) else {
|
||||||
panic!(
|
panic!(
|
||||||
@ -274,7 +271,7 @@ fn apply_or_insert_field_mapped(
|
|||||||
field,
|
field,
|
||||||
registry,
|
registry,
|
||||||
mapper,
|
mapper,
|
||||||
relationship_insert_hook_mode,
|
relationship_hook_mode,
|
||||||
);
|
);
|
||||||
} else if let Some(reflect_bundle) = registry.get_type_data::<ReflectBundle>(type_id) {
|
} else if let Some(reflect_bundle) = registry.get_type_data::<ReflectBundle>(type_id) {
|
||||||
reflect_bundle.apply_or_insert_mapped(
|
reflect_bundle.apply_or_insert_mapped(
|
||||||
@ -282,7 +279,7 @@ fn apply_or_insert_field_mapped(
|
|||||||
field,
|
field,
|
||||||
registry,
|
registry,
|
||||||
mapper,
|
mapper,
|
||||||
relationship_insert_hook_mode,
|
relationship_hook_mode,
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
let is_component = entity.world().components().get_id(type_id).is_some();
|
let is_component = entity.world().components().get_id(type_id).is_some();
|
||||||
|
@ -63,7 +63,7 @@ use crate::{
|
|||||||
component::{ComponentId, ComponentMutability},
|
component::{ComponentId, ComponentMutability},
|
||||||
entity::{Entity, EntityMapper},
|
entity::{Entity, EntityMapper},
|
||||||
prelude::Component,
|
prelude::Component,
|
||||||
relationship::RelationshipInsertHookMode,
|
relationship::RelationshipHookMode,
|
||||||
world::{
|
world::{
|
||||||
unsafe_world_cell::UnsafeEntityCell, EntityMut, EntityWorldMut, FilteredEntityMut,
|
unsafe_world_cell::UnsafeEntityCell, EntityMut, EntityWorldMut, FilteredEntityMut,
|
||||||
FilteredEntityRef, World,
|
FilteredEntityRef, World,
|
||||||
@ -111,7 +111,7 @@ pub struct ReflectComponentFns {
|
|||||||
&dyn PartialReflect,
|
&dyn PartialReflect,
|
||||||
&TypeRegistry,
|
&TypeRegistry,
|
||||||
&mut dyn EntityMapper,
|
&mut dyn EntityMapper,
|
||||||
RelationshipInsertHookMode,
|
RelationshipHookMode,
|
||||||
),
|
),
|
||||||
/// Function pointer implementing [`ReflectComponent::remove()`].
|
/// Function pointer implementing [`ReflectComponent::remove()`].
|
||||||
pub remove: fn(&mut EntityWorldMut),
|
pub remove: fn(&mut EntityWorldMut),
|
||||||
@ -180,15 +180,9 @@ impl ReflectComponent {
|
|||||||
component: &dyn PartialReflect,
|
component: &dyn PartialReflect,
|
||||||
registry: &TypeRegistry,
|
registry: &TypeRegistry,
|
||||||
map: &mut dyn EntityMapper,
|
map: &mut dyn EntityMapper,
|
||||||
relationship_insert_hook_mode: RelationshipInsertHookMode,
|
relationship_hook_mode: RelationshipHookMode,
|
||||||
) {
|
) {
|
||||||
(self.0.apply_or_insert_mapped)(
|
(self.0.apply_or_insert_mapped)(entity, component, registry, map, relationship_hook_mode);
|
||||||
entity,
|
|
||||||
component,
|
|
||||||
registry,
|
|
||||||
map,
|
|
||||||
relationship_insert_hook_mode,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Removes this [`Component`] type from the entity. Does nothing if it doesn't exist.
|
/// Removes this [`Component`] type from the entity. Does nothing if it doesn't exist.
|
||||||
@ -333,38 +327,31 @@ impl<C: Component + Reflect + TypePath> FromType<C> for ReflectComponent {
|
|||||||
let mut component = unsafe { entity.get_mut_assume_mutable::<C>() }.unwrap();
|
let mut component = unsafe { entity.get_mut_assume_mutable::<C>() }.unwrap();
|
||||||
component.apply(reflected_component);
|
component.apply(reflected_component);
|
||||||
},
|
},
|
||||||
apply_or_insert_mapped:
|
apply_or_insert_mapped: |entity,
|
||||||
|entity, reflected_component, registry, mapper, relationship_insert_hook_mode| {
|
reflected_component,
|
||||||
|
registry,
|
||||||
|
mapper,
|
||||||
|
relationship_hook_mode| {
|
||||||
let map_fn = map_function(mapper);
|
let map_fn = map_function(mapper);
|
||||||
if C::Mutability::MUTABLE {
|
if C::Mutability::MUTABLE {
|
||||||
// SAFETY: guard ensures `C` is a mutable component
|
// SAFETY: guard ensures `C` is a mutable component
|
||||||
if let Some(mut component) = unsafe { entity.get_mut_assume_mutable::<C>() }
|
if let Some(mut component) = unsafe { entity.get_mut_assume_mutable::<C>() } {
|
||||||
{
|
|
||||||
component.apply(reflected_component.as_partial_reflect());
|
component.apply(reflected_component.as_partial_reflect());
|
||||||
C::visit_entities_mut(&mut component, map_fn);
|
C::visit_entities_mut(&mut component, map_fn);
|
||||||
} else {
|
} else {
|
||||||
let mut component = entity.world_scope(|world| {
|
let mut component = entity.world_scope(|world| {
|
||||||
from_reflect_with_fallback::<C>(
|
from_reflect_with_fallback::<C>(reflected_component, world, registry)
|
||||||
reflected_component,
|
|
||||||
world,
|
|
||||||
registry,
|
|
||||||
)
|
|
||||||
});
|
});
|
||||||
C::visit_entities_mut(&mut component, map_fn);
|
C::visit_entities_mut(&mut component, map_fn);
|
||||||
entity.insert_with_relationship_insert_hook_mode(
|
entity
|
||||||
component,
|
.insert_with_relationship_hook_mode(component, relationship_hook_mode);
|
||||||
relationship_insert_hook_mode,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
let mut component = entity.world_scope(|world| {
|
let mut component = entity.world_scope(|world| {
|
||||||
from_reflect_with_fallback::<C>(reflected_component, world, registry)
|
from_reflect_with_fallback::<C>(reflected_component, world, registry)
|
||||||
});
|
});
|
||||||
C::visit_entities_mut(&mut component, map_fn);
|
C::visit_entities_mut(&mut component, map_fn);
|
||||||
entity.insert_with_relationship_insert_hook_mode(
|
entity.insert_with_relationship_hook_mode(component, relationship_hook_mode);
|
||||||
component,
|
|
||||||
relationship_insert_hook_mode,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
remove: |entity| {
|
remove: |entity| {
|
||||||
|
@ -90,14 +90,14 @@ pub trait Relationship: Component + Sized {
|
|||||||
HookContext {
|
HookContext {
|
||||||
entity,
|
entity,
|
||||||
caller,
|
caller,
|
||||||
relationship_insert_hook_mode,
|
relationship_hook_mode,
|
||||||
..
|
..
|
||||||
}: HookContext,
|
}: HookContext,
|
||||||
) {
|
) {
|
||||||
match relationship_insert_hook_mode {
|
match relationship_hook_mode {
|
||||||
RelationshipInsertHookMode::Run => {}
|
RelationshipHookMode::Run => {}
|
||||||
RelationshipInsertHookMode::Skip => return,
|
RelationshipHookMode::Skip => return,
|
||||||
RelationshipInsertHookMode::RunIfNotLinked => {
|
RelationshipHookMode::RunIfNotLinked => {
|
||||||
if <Self::RelationshipTarget as RelationshipTarget>::LINKED_SPAWN {
|
if <Self::RelationshipTarget as RelationshipTarget>::LINKED_SPAWN {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -137,7 +137,23 @@ pub trait Relationship: Component + Sized {
|
|||||||
|
|
||||||
/// The `on_replace` component hook that maintains the [`Relationship`] / [`RelationshipTarget`] connection.
|
/// The `on_replace` component hook that maintains the [`Relationship`] / [`RelationshipTarget`] connection.
|
||||||
// note: think of this as "on_drop"
|
// note: think of this as "on_drop"
|
||||||
fn on_replace(mut world: DeferredWorld, HookContext { entity, .. }: HookContext) {
|
fn on_replace(
|
||||||
|
mut world: DeferredWorld,
|
||||||
|
HookContext {
|
||||||
|
entity,
|
||||||
|
relationship_hook_mode,
|
||||||
|
..
|
||||||
|
}: HookContext,
|
||||||
|
) {
|
||||||
|
match relationship_hook_mode {
|
||||||
|
RelationshipHookMode::Run => {}
|
||||||
|
RelationshipHookMode::Skip => return,
|
||||||
|
RelationshipHookMode::RunIfNotLinked => {
|
||||||
|
if <Self::RelationshipTarget as RelationshipTarget>::LINKED_SPAWN {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
let target_entity = world.entity(entity).get::<Self>().unwrap().get();
|
let target_entity = world.entity(entity).get::<Self>().unwrap().get();
|
||||||
if let Ok(mut target_entity_mut) = world.get_entity_mut(target_entity) {
|
if let Ok(mut target_entity_mut) = world.get_entity_mut(target_entity) {
|
||||||
if let Some(mut relationship_target) =
|
if let Some(mut relationship_target) =
|
||||||
@ -305,14 +321,14 @@ pub fn clone_relationship_target<T: RelationshipTarget>(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Configures the conditions under which the Relationship insert hook will be run.
|
/// Configures the conditions under which the Relationship insert/replace hooks will be run.
|
||||||
#[derive(Copy, Clone, Debug)]
|
#[derive(Copy, Clone, Debug)]
|
||||||
pub enum RelationshipInsertHookMode {
|
pub enum RelationshipHookMode {
|
||||||
/// Relationship insert hooks will always run
|
/// Relationship insert/replace hooks will always run
|
||||||
Run,
|
Run,
|
||||||
/// Relationship insert hooks will run if [`RelationshipTarget::LINKED_SPAWN`] is false
|
/// Relationship insert/replace hooks will run if [`RelationshipTarget::LINKED_SPAWN`] is false
|
||||||
RunIfNotLinked,
|
RunIfNotLinked,
|
||||||
/// Relationship insert hooks will always be skipped
|
/// Relationship insert/replace hooks will always be skipped
|
||||||
Skip,
|
Skip,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ use crate::{
|
|||||||
entity::{Entity, EntityClonerBuilder},
|
entity::{Entity, EntityClonerBuilder},
|
||||||
error::Result,
|
error::Result,
|
||||||
event::Event,
|
event::Event,
|
||||||
relationship::RelationshipInsertHookMode,
|
relationship::RelationshipHookMode,
|
||||||
system::{command::HandleError, Command, IntoObserverSystem},
|
system::{command::HandleError, Command, IntoObserverSystem},
|
||||||
world::{error::EntityMutableFetchError, EntityWorldMut, FromWorld, World},
|
world::{error::EntityMutableFetchError, EntityWorldMut, FromWorld, World},
|
||||||
};
|
};
|
||||||
@ -157,7 +157,7 @@ where
|
|||||||
pub fn insert(bundle: impl Bundle, mode: InsertMode) -> impl EntityCommand {
|
pub fn insert(bundle: impl Bundle, mode: InsertMode) -> impl EntityCommand {
|
||||||
let caller = MaybeLocation::caller();
|
let caller = MaybeLocation::caller();
|
||||||
move |mut entity: EntityWorldMut| {
|
move |mut entity: EntityWorldMut| {
|
||||||
entity.insert_with_caller(bundle, mode, caller, RelationshipInsertHookMode::Run);
|
entity.insert_with_caller(bundle, mode, caller, RelationshipHookMode::Run);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -184,7 +184,7 @@ pub unsafe fn insert_by_id<T: Send + 'static>(
|
|||||||
ptr,
|
ptr,
|
||||||
mode,
|
mode,
|
||||||
caller,
|
caller,
|
||||||
RelationshipInsertHookMode::Run,
|
RelationshipHookMode::Run,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -197,7 +197,7 @@ pub fn insert_from_world<T: Component + FromWorld>(mode: InsertMode) -> impl Ent
|
|||||||
let caller = MaybeLocation::caller();
|
let caller = MaybeLocation::caller();
|
||||||
move |mut entity: EntityWorldMut| {
|
move |mut entity: EntityWorldMut| {
|
||||||
let value = entity.world_scope(|world| T::from_world(world));
|
let value = entity.world_scope(|world| T::from_world(world));
|
||||||
entity.insert_with_caller(value, mode, caller, RelationshipInsertHookMode::Run);
|
entity.insert_with_caller(value, mode, caller, RelationshipHookMode::Run);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ use crate::{
|
|||||||
observer::{Observers, TriggerTargets},
|
observer::{Observers, TriggerTargets},
|
||||||
prelude::{Component, QueryState},
|
prelude::{Component, QueryState},
|
||||||
query::{QueryData, QueryFilter},
|
query::{QueryData, QueryFilter},
|
||||||
relationship::RelationshipInsertHookMode,
|
relationship::RelationshipHookMode,
|
||||||
resource::Resource,
|
resource::Resource,
|
||||||
system::{Commands, Query},
|
system::{Commands, Query},
|
||||||
traversal::Traversal,
|
traversal::Traversal,
|
||||||
@ -121,6 +121,7 @@ impl<'w> DeferredWorld<'w> {
|
|||||||
entity,
|
entity,
|
||||||
[component_id].into_iter(),
|
[component_id].into_iter(),
|
||||||
MaybeLocation::caller(),
|
MaybeLocation::caller(),
|
||||||
|
RelationshipHookMode::Run,
|
||||||
);
|
);
|
||||||
if archetype.has_replace_observer() {
|
if archetype.has_replace_observer() {
|
||||||
self.trigger_observers(
|
self.trigger_observers(
|
||||||
@ -160,7 +161,7 @@ impl<'w> DeferredWorld<'w> {
|
|||||||
entity,
|
entity,
|
||||||
[component_id].into_iter(),
|
[component_id].into_iter(),
|
||||||
MaybeLocation::caller(),
|
MaybeLocation::caller(),
|
||||||
RelationshipInsertHookMode::Run,
|
RelationshipHookMode::Run,
|
||||||
);
|
);
|
||||||
if archetype.has_insert_observer() {
|
if archetype.has_insert_observer() {
|
||||||
self.trigger_observers(
|
self.trigger_observers(
|
||||||
@ -564,7 +565,7 @@ impl<'w> DeferredWorld<'w> {
|
|||||||
entity,
|
entity,
|
||||||
component_id,
|
component_id,
|
||||||
caller,
|
caller,
|
||||||
relationship_insert_hook_mode: RelationshipInsertHookMode::Run,
|
relationship_hook_mode: RelationshipHookMode::Run,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -583,7 +584,7 @@ impl<'w> DeferredWorld<'w> {
|
|||||||
entity: Entity,
|
entity: Entity,
|
||||||
targets: impl Iterator<Item = ComponentId>,
|
targets: impl Iterator<Item = ComponentId>,
|
||||||
caller: MaybeLocation,
|
caller: MaybeLocation,
|
||||||
relationship_insert_hook_mode: RelationshipInsertHookMode,
|
relationship_hook_mode: RelationshipHookMode,
|
||||||
) {
|
) {
|
||||||
if archetype.has_insert_hook() {
|
if archetype.has_insert_hook() {
|
||||||
for component_id in targets {
|
for component_id in targets {
|
||||||
@ -596,7 +597,7 @@ impl<'w> DeferredWorld<'w> {
|
|||||||
entity,
|
entity,
|
||||||
component_id,
|
component_id,
|
||||||
caller,
|
caller,
|
||||||
relationship_insert_hook_mode,
|
relationship_hook_mode,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -615,6 +616,7 @@ impl<'w> DeferredWorld<'w> {
|
|||||||
entity: Entity,
|
entity: Entity,
|
||||||
targets: impl Iterator<Item = ComponentId>,
|
targets: impl Iterator<Item = ComponentId>,
|
||||||
caller: MaybeLocation,
|
caller: MaybeLocation,
|
||||||
|
relationship_hook_mode: RelationshipHookMode,
|
||||||
) {
|
) {
|
||||||
if archetype.has_replace_hook() {
|
if archetype.has_replace_hook() {
|
||||||
for component_id in targets {
|
for component_id in targets {
|
||||||
@ -627,7 +629,7 @@ impl<'w> DeferredWorld<'w> {
|
|||||||
entity,
|
entity,
|
||||||
component_id,
|
component_id,
|
||||||
caller,
|
caller,
|
||||||
relationship_insert_hook_mode: RelationshipInsertHookMode::Run,
|
relationship_hook_mode,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -658,7 +660,7 @@ impl<'w> DeferredWorld<'w> {
|
|||||||
entity,
|
entity,
|
||||||
component_id,
|
component_id,
|
||||||
caller,
|
caller,
|
||||||
relationship_insert_hook_mode: RelationshipInsertHookMode::Run,
|
relationship_hook_mode: RelationshipHookMode::Run,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -689,7 +691,7 @@ impl<'w> DeferredWorld<'w> {
|
|||||||
entity,
|
entity,
|
||||||
component_id,
|
component_id,
|
||||||
caller,
|
caller,
|
||||||
relationship_insert_hook_mode: RelationshipInsertHookMode::Run,
|
relationship_hook_mode: RelationshipHookMode::Run,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@ use crate::{
|
|||||||
event::Event,
|
event::Event,
|
||||||
observer::Observer,
|
observer::Observer,
|
||||||
query::{Access, ReadOnlyQueryData},
|
query::{Access, ReadOnlyQueryData},
|
||||||
relationship::RelationshipInsertHookMode,
|
relationship::RelationshipHookMode,
|
||||||
removal_detection::RemovedComponentEvents,
|
removal_detection::RemovedComponentEvents,
|
||||||
resource::Resource,
|
resource::Resource,
|
||||||
storage::Storages,
|
storage::Storages,
|
||||||
@ -1534,13 +1534,13 @@ impl<'w> EntityWorldMut<'w> {
|
|||||||
bundle,
|
bundle,
|
||||||
InsertMode::Replace,
|
InsertMode::Replace,
|
||||||
MaybeLocation::caller(),
|
MaybeLocation::caller(),
|
||||||
RelationshipInsertHookMode::Run,
|
RelationshipHookMode::Run,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Adds a [`Bundle`] of components to the entity.
|
/// Adds a [`Bundle`] of components to the entity.
|
||||||
/// [`Relationship`](crate::relationship::Relationship) components in the bundle will follow the configuration
|
/// [`Relationship`](crate::relationship::Relationship) components in the bundle will follow the configuration
|
||||||
/// in `relationship_insert_hook_mode`.
|
/// in `relationship_hook_mode`.
|
||||||
///
|
///
|
||||||
/// This will overwrite any previous value(s) of the same component type.
|
/// This will overwrite any previous value(s) of the same component type.
|
||||||
///
|
///
|
||||||
@ -1553,16 +1553,16 @@ impl<'w> EntityWorldMut<'w> {
|
|||||||
///
|
///
|
||||||
/// If the entity has been despawned while this `EntityWorldMut` is still alive.
|
/// If the entity has been despawned while this `EntityWorldMut` is still alive.
|
||||||
#[track_caller]
|
#[track_caller]
|
||||||
pub fn insert_with_relationship_insert_hook_mode<T: Bundle>(
|
pub fn insert_with_relationship_hook_mode<T: Bundle>(
|
||||||
&mut self,
|
&mut self,
|
||||||
bundle: T,
|
bundle: T,
|
||||||
relationship_insert_hook_mode: RelationshipInsertHookMode,
|
relationship_hook_mode: RelationshipHookMode,
|
||||||
) -> &mut Self {
|
) -> &mut Self {
|
||||||
self.insert_with_caller(
|
self.insert_with_caller(
|
||||||
bundle,
|
bundle,
|
||||||
InsertMode::Replace,
|
InsertMode::Replace,
|
||||||
MaybeLocation::caller(),
|
MaybeLocation::caller(),
|
||||||
relationship_insert_hook_mode,
|
relationship_hook_mode,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1580,7 +1580,7 @@ impl<'w> EntityWorldMut<'w> {
|
|||||||
bundle,
|
bundle,
|
||||||
InsertMode::Keep,
|
InsertMode::Keep,
|
||||||
MaybeLocation::caller(),
|
MaybeLocation::caller(),
|
||||||
RelationshipInsertHookMode::Run,
|
RelationshipHookMode::Run,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1592,7 +1592,7 @@ impl<'w> EntityWorldMut<'w> {
|
|||||||
bundle: T,
|
bundle: T,
|
||||||
mode: InsertMode,
|
mode: InsertMode,
|
||||||
caller: MaybeLocation,
|
caller: MaybeLocation,
|
||||||
relationship_insert_hook_mode: RelationshipInsertHookMode,
|
relationship_hook_mode: RelationshipHookMode,
|
||||||
) -> &mut Self {
|
) -> &mut Self {
|
||||||
self.assert_not_despawned();
|
self.assert_not_despawned();
|
||||||
let change_tick = self.world.change_tick();
|
let change_tick = self.world.change_tick();
|
||||||
@ -1606,7 +1606,7 @@ impl<'w> EntityWorldMut<'w> {
|
|||||||
bundle,
|
bundle,
|
||||||
mode,
|
mode,
|
||||||
caller,
|
caller,
|
||||||
relationship_insert_hook_mode,
|
relationship_hook_mode,
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
self.location = location;
|
self.location = location;
|
||||||
@ -1641,7 +1641,7 @@ impl<'w> EntityWorldMut<'w> {
|
|||||||
component,
|
component,
|
||||||
InsertMode::Replace,
|
InsertMode::Replace,
|
||||||
MaybeLocation::caller(),
|
MaybeLocation::caller(),
|
||||||
RelationshipInsertHookMode::Run,
|
RelationshipHookMode::Run,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1656,7 +1656,7 @@ impl<'w> EntityWorldMut<'w> {
|
|||||||
component: OwningPtr<'_>,
|
component: OwningPtr<'_>,
|
||||||
mode: InsertMode,
|
mode: InsertMode,
|
||||||
caller: MaybeLocation,
|
caller: MaybeLocation,
|
||||||
relationship_hook_insert_mode: RelationshipInsertHookMode,
|
relationship_hook_insert_mode: RelationshipHookMode,
|
||||||
) -> &mut Self {
|
) -> &mut Self {
|
||||||
self.assert_not_despawned();
|
self.assert_not_despawned();
|
||||||
let change_tick = self.world.change_tick();
|
let change_tick = self.world.change_tick();
|
||||||
@ -1711,11 +1711,7 @@ impl<'w> EntityWorldMut<'w> {
|
|||||||
component_ids: &[ComponentId],
|
component_ids: &[ComponentId],
|
||||||
iter_components: I,
|
iter_components: I,
|
||||||
) -> &mut Self {
|
) -> &mut Self {
|
||||||
self.insert_by_ids_internal(
|
self.insert_by_ids_internal(component_ids, iter_components, RelationshipHookMode::Run)
|
||||||
component_ids,
|
|
||||||
iter_components,
|
|
||||||
RelationshipInsertHookMode::Run,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[track_caller]
|
#[track_caller]
|
||||||
@ -1723,7 +1719,7 @@ impl<'w> EntityWorldMut<'w> {
|
|||||||
&mut self,
|
&mut self,
|
||||||
component_ids: &[ComponentId],
|
component_ids: &[ComponentId],
|
||||||
iter_components: I,
|
iter_components: I,
|
||||||
relationship_hook_insert_mode: RelationshipInsertHookMode,
|
relationship_hook_insert_mode: RelationshipHookMode,
|
||||||
) -> &mut Self {
|
) -> &mut Self {
|
||||||
self.assert_not_despawned();
|
self.assert_not_despawned();
|
||||||
let change_tick = self.world.change_tick();
|
let change_tick = self.world.change_tick();
|
||||||
@ -2310,6 +2306,7 @@ impl<'w> EntityWorldMut<'w> {
|
|||||||
self.entity,
|
self.entity,
|
||||||
archetype.components(),
|
archetype.components(),
|
||||||
caller,
|
caller,
|
||||||
|
RelationshipHookMode::Run,
|
||||||
);
|
);
|
||||||
if archetype.has_remove_observer() {
|
if archetype.has_remove_observer() {
|
||||||
deferred_world.trigger_observers(
|
deferred_world.trigger_observers(
|
||||||
@ -2762,7 +2759,13 @@ unsafe fn trigger_on_replace_and_on_remove_hooks_and_observers(
|
|||||||
caller,
|
caller,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
deferred_world.trigger_on_replace(archetype, entity, bundle_components_in_archetype(), caller);
|
deferred_world.trigger_on_replace(
|
||||||
|
archetype,
|
||||||
|
entity,
|
||||||
|
bundle_components_in_archetype(),
|
||||||
|
caller,
|
||||||
|
RelationshipHookMode::Run,
|
||||||
|
);
|
||||||
if archetype.has_remove_observer() {
|
if archetype.has_remove_observer() {
|
||||||
deferred_world.trigger_observers(
|
deferred_world.trigger_observers(
|
||||||
ON_REMOVE,
|
ON_REMOVE,
|
||||||
@ -4251,7 +4254,7 @@ unsafe fn insert_dynamic_bundle<
|
|||||||
storage_types: S,
|
storage_types: S,
|
||||||
mode: InsertMode,
|
mode: InsertMode,
|
||||||
caller: MaybeLocation,
|
caller: MaybeLocation,
|
||||||
relationship_hook_insert_mode: RelationshipInsertHookMode,
|
relationship_hook_insert_mode: RelationshipHookMode,
|
||||||
) -> EntityLocation {
|
) -> EntityLocation {
|
||||||
struct DynamicInsertBundle<'a, I: Iterator<Item = (StorageType, OwningPtr<'a>)>> {
|
struct DynamicInsertBundle<'a, I: Iterator<Item = (StorageType, OwningPtr<'a>)>> {
|
||||||
components: I,
|
components: I,
|
||||||
|
@ -53,7 +53,7 @@ use crate::{
|
|||||||
event::{Event, EventId, Events, SendBatchIds},
|
event::{Event, EventId, Events, SendBatchIds},
|
||||||
observer::Observers,
|
observer::Observers,
|
||||||
query::{DebugCheckedUnwrap, QueryData, QueryFilter, QueryState},
|
query::{DebugCheckedUnwrap, QueryData, QueryFilter, QueryState},
|
||||||
relationship::RelationshipInsertHookMode,
|
relationship::RelationshipHookMode,
|
||||||
removal_detection::RemovedComponentEvents,
|
removal_detection::RemovedComponentEvents,
|
||||||
resource::Resource,
|
resource::Resource,
|
||||||
schedule::{Schedule, ScheduleLabel, Schedules},
|
schedule::{Schedule, ScheduleLabel, Schedules},
|
||||||
@ -2305,7 +2305,7 @@ impl World {
|
|||||||
bundle,
|
bundle,
|
||||||
InsertMode::Replace,
|
InsertMode::Replace,
|
||||||
caller,
|
caller,
|
||||||
RelationshipInsertHookMode::Run,
|
RelationshipHookMode::Run,
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -2327,7 +2327,7 @@ impl World {
|
|||||||
bundle,
|
bundle,
|
||||||
InsertMode::Replace,
|
InsertMode::Replace,
|
||||||
caller,
|
caller,
|
||||||
RelationshipInsertHookMode::Run,
|
RelationshipHookMode::Run,
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
spawn_or_insert =
|
spawn_or_insert =
|
||||||
@ -2465,7 +2465,7 @@ impl World {
|
|||||||
first_bundle,
|
first_bundle,
|
||||||
insert_mode,
|
insert_mode,
|
||||||
caller,
|
caller,
|
||||||
RelationshipInsertHookMode::Run,
|
RelationshipHookMode::Run,
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -2493,7 +2493,7 @@ impl World {
|
|||||||
bundle,
|
bundle,
|
||||||
insert_mode,
|
insert_mode,
|
||||||
caller,
|
caller,
|
||||||
RelationshipInsertHookMode::Run,
|
RelationshipHookMode::Run,
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
@ -2615,7 +2615,7 @@ impl World {
|
|||||||
first_bundle,
|
first_bundle,
|
||||||
insert_mode,
|
insert_mode,
|
||||||
caller,
|
caller,
|
||||||
RelationshipInsertHookMode::Run,
|
RelationshipHookMode::Run,
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
break Some(cache);
|
break Some(cache);
|
||||||
@ -2652,7 +2652,7 @@ impl World {
|
|||||||
bundle,
|
bundle,
|
||||||
insert_mode,
|
insert_mode,
|
||||||
caller,
|
caller,
|
||||||
RelationshipInsertHookMode::Run,
|
RelationshipHookMode::Run,
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
|
@ -12,7 +12,7 @@ use crate::reflect_utils::clone_reflect_value;
|
|||||||
#[cfg(feature = "serialize")]
|
#[cfg(feature = "serialize")]
|
||||||
use crate::serde::SceneSerializer;
|
use crate::serde::SceneSerializer;
|
||||||
use bevy_ecs::component::ComponentCloneBehavior;
|
use bevy_ecs::component::ComponentCloneBehavior;
|
||||||
use bevy_ecs::relationship::RelationshipInsertHookMode;
|
use bevy_ecs::relationship::RelationshipHookMode;
|
||||||
#[cfg(feature = "serialize")]
|
#[cfg(feature = "serialize")]
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
|
|
||||||
@ -122,7 +122,7 @@ impl DynamicScene {
|
|||||||
component.as_partial_reflect(),
|
component.as_partial_reflect(),
|
||||||
&type_registry,
|
&type_registry,
|
||||||
mapper,
|
mapper,
|
||||||
RelationshipInsertHookMode::Skip,
|
RelationshipHookMode::Skip,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@ use bevy_ecs::{
|
|||||||
entity::{hash_map::EntityHashMap, Entity, SceneEntityMapper},
|
entity::{hash_map::EntityHashMap, Entity, SceneEntityMapper},
|
||||||
entity_disabling::DefaultQueryFilters,
|
entity_disabling::DefaultQueryFilters,
|
||||||
reflect::{AppTypeRegistry, ReflectComponent, ReflectResource},
|
reflect::{AppTypeRegistry, ReflectComponent, ReflectResource},
|
||||||
relationship::RelationshipInsertHookMode,
|
relationship::RelationshipHookMode,
|
||||||
world::World,
|
world::World,
|
||||||
};
|
};
|
||||||
use bevy_reflect::TypePath;
|
use bevy_reflect::TypePath;
|
||||||
@ -159,7 +159,7 @@ impl Scene {
|
|||||||
component.as_partial_reflect(),
|
component.as_partial_reflect(),
|
||||||
&type_registry,
|
&type_registry,
|
||||||
mapper,
|
mapper,
|
||||||
RelationshipInsertHookMode::Skip,
|
RelationshipHookMode::Skip,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user