From 0b3da3464cd8a08ece1ee42aea08c774be60c2df Mon Sep 17 00:00:00 2001 From: Elliott Pierce Date: Sat, 5 Jul 2025 10:24:40 -0400 Subject: [PATCH] fixed merge conflicts hopefully --- crates/bevy_ecs/src/entity/clone_entities.rs | 12 ++++++--- crates/bevy_ecs/src/system/commands/mod.rs | 4 +-- crates/bevy_ecs/src/world/entity_ref.rs | 6 ++--- crates/bevy_remote/src/builtin_methods.rs | 27 ++++++++++---------- 4 files changed, 26 insertions(+), 23 deletions(-) diff --git a/crates/bevy_ecs/src/entity/clone_entities.rs b/crates/bevy_ecs/src/entity/clone_entities.rs index 58c8be8061..7184d5c0d9 100644 --- a/crates/bevy_ecs/src/entity/clone_entities.rs +++ b/crates/bevy_ecs/src/entity/clone_entities.rs @@ -7,12 +7,13 @@ use crate::{ relationship::RelationshipHookMode, world::World, }; -use alloc::{borrow::ToOwned, boxed::Box, collections::VecDeque, vec::Vec}; -use bevy_platform::collections::{HashMap, HashSet}; +use alloc::{boxed::Box, collections::VecDeque, vec::Vec}; +use bevy_platform::collections::{hash_map::Entry, HashMap, HashSet}; use bevy_ptr::{Ptr, PtrMut}; use bevy_utils::prelude::DebugName; use bumpalo::Bump; -use core::any::TypeId; +use core::{any::TypeId, cell::LazyCell, ops::Range}; +use derive_more::From; use super::EntitiesAllocator; @@ -558,7 +559,9 @@ impl EntityCloner { #[cfg(not(feature = "bevy_reflect"))] let app_registry = Option::<()>::None; - let source_archetype = source_entity.archetype(); + let source_archetype = source_entity + .archetype() + .expect("Source entity must exist constructed"); bundle_scratch = BundleScratch::with_capacity(source_archetype.component_count()); let target_archetype = LazyCell::new(|| { @@ -566,6 +569,7 @@ impl EntityCloner { .get_entity(target) .expect("Target entity must exist") .archetype() + .expect("Target entity must exist constructed") }); filter.clone_components(source_archetype, target_archetype, |component| { diff --git a/crates/bevy_ecs/src/system/commands/mod.rs b/crates/bevy_ecs/src/system/commands/mod.rs index fdbb367056..beff239678 100644 --- a/crates/bevy_ecs/src/system/commands/mod.rs +++ b/crates/bevy_ecs/src/system/commands/mod.rs @@ -20,9 +20,9 @@ use crate::{ component::{Component, ComponentId, Mutable}, entity::{ ConstructedEntityDoesNotExistError, Entities, EntitiesAllocator, Entity, - EntityClonerBuilder, EntityDoesNotExistError, + EntityClonerBuilder, EntityDoesNotExistError, OptIn, OptOut, }, - error::{ignore, warn, BevyError, CommandWithEntity, ErrorContext, HandleError}, + error::{warn, BevyError, CommandWithEntity, ErrorContext, HandleError}, event::{BufferedEvent, EntityEvent, Event}, observer::{Observer, TriggerTargets}, resource::Resource, diff --git a/crates/bevy_ecs/src/world/entity_ref.rs b/crates/bevy_ecs/src/world/entity_ref.rs index d5fb773dfb..57148012a0 100644 --- a/crates/bevy_ecs/src/world/entity_ref.rs +++ b/crates/bevy_ecs/src/world/entity_ref.rs @@ -11,7 +11,7 @@ use crate::{ }, entity::{ ConstructionError, ContainsEntity, Entity, EntityCloner, EntityClonerBuilder, - EntityEquivalent, EntityIdLocation, EntityLocation, + EntityEquivalent, EntityIdLocation, EntityLocation, OptIn, OptOut, }, event::EntityEvent, lifecycle::{DESPAWN, REMOVE, REPLACE}, @@ -2888,9 +2888,7 @@ impl<'w> EntityWorldMut<'w> { ) -> Entity { self.assert_not_despawned(); - let entity_clone = self.world.entities.reserve_entity(); - self.world.flush(); - + let entity_clone = self.world.spawn_empty().id(); let mut builder = EntityCloner::build_opt_out(self.world); config(&mut builder); builder.clone_entity(self.entity, entity_clone); diff --git a/crates/bevy_remote/src/builtin_methods.rs b/crates/bevy_remote/src/builtin_methods.rs index 316ab60f03..f2b55f1c35 100644 --- a/crates/bevy_remote/src/builtin_methods.rs +++ b/crates/bevy_remote/src/builtin_methods.rs @@ -843,19 +843,20 @@ pub fn process_remote_query_request(In(params): In>, world: &mut W match &option { ComponentSelector::All => { // Add all reflectable components present on the entity (as Option<&T>) - let all_optionals = - entity_ref - .archetype() - .components() - .filter_map(|component_id| { - let info = world.components().get_info(component_id)?; - let type_id = info.type_id()?; - // Skip required components (already included) - if required.iter().any(|(_, cid)| cid == &component_id) { - return None; - } - Some((type_id, Some(component_id))) - }); + let all_optionals = entity_ref + .archetype() + .map(bevy_ecs::archetype::Archetype::components) + .into_iter() + .flatten() + .filter_map(|component_id| { + let info = world.components().get_info(component_id)?; + let type_id = info.type_id()?; + // Skip required components (already included) + if required.iter().any(|(_, cid)| cid == &component_id) { + return None; + } + Some((type_id, Some(component_id))) + }); components_map.extend(serialize_components( entity_ref, &type_registry,