Skip to content

Commit

Permalink
Fix ci failures
Browse files Browse the repository at this point in the history
  • Loading branch information
Niashi24 committed Sep 11, 2024
1 parent 8364ec0 commit a3dba6c
Showing 1 changed file with 23 additions and 19 deletions.
42 changes: 23 additions & 19 deletions crates/bevy_ecs/src/reflect/entity_commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ pub trait ReflectCommandExt {
/// // or write to the TypeRegistry directly to register all your components
///
/// # use bevy_ecs::prelude::*;
/// # use bevy_ecs::reflect::ReflectCommandExt;
/// # use bevy_ecs::reflect::{ReflectCommandExt, ReflectBundle};
/// # use bevy_reflect::{FromReflect, FromType, Reflect, TypeRegistry};
/// // A resource that can hold any component that implements reflect as a boxed reflect component
/// #[derive(Resource)]
Expand All @@ -53,7 +53,7 @@ pub trait ReflectCommandExt {
/// #[derive(Component, Reflect, Default)]
/// #[reflect(Component)]
/// struct ComponentB(String);
///
///
/// #[derive(Bundle, Reflect, Default)]
/// #[reflect(Bundle)]
/// struct BundleA {
Expand All @@ -72,7 +72,7 @@ pub trait ReflectCommandExt {
/// a: ComponentA(24),
/// b: ComponentB("Twenty-Four".to_string()),
/// });
///
///
/// // You can overwrite the component in the resource with either ComponentA or ComponentB
/// prefab.data = boxed_reflect_component_a;
/// prefab.data = boxed_reflect_component_b;
Expand Down Expand Up @@ -106,7 +106,7 @@ pub trait ReflectCommandExt {
) -> &mut Self;

/// Removes from the entity the component or bundle with the given type name registered in [`AppTypeRegistry`].
///
///
/// If the type is a bundle, it will remove any components in that bundle regardless if the entity
/// contains all the components.
///
Expand All @@ -128,7 +128,7 @@ pub trait ReflectCommandExt {
/// // or write to the TypeRegistry directly to register all your components and bundles
///
/// # use bevy_ecs::prelude::*;
/// # use bevy_ecs::reflect::ReflectCommandExt;
/// # use bevy_ecs::reflect::{ReflectCommandExt, ReflectBundle};
/// # use bevy_reflect::{FromReflect, FromType, Reflect, TypeRegistry};
///
/// // A resource that can hold any component or bundle that implements reflect as a boxed reflect
Expand Down Expand Up @@ -540,11 +540,11 @@ mod tests {
#[test]
fn insert_reflect_bundle_with_registry() {
let mut world = World::new();

let mut type_registry = TypeRegistryResource {
type_registry: TypeRegistry::new(),
};

type_registry.type_registry.register::<BundleA>();
type_registry
.type_registry
Expand All @@ -559,8 +559,9 @@ mod tests {
a: ComponentA(31),
b: ComponentB(20),
}) as Box<dyn PartialReflect>;

commands.entity(entity)

commands
.entity(entity)
.insert_reflect_with_registry::<TypeRegistryResource>(bundle);
system_state.apply(&mut world);

Expand All @@ -583,10 +584,12 @@ mod tests {
let mut system_state: SystemState<Commands> = SystemState::new(&mut world);
let mut commands = system_state.get_mut(&mut world);

let entity = commands.spawn(BundleA {
a: ComponentA(31),
b: ComponentB(20),
}).id();
let entity = commands
.spawn(BundleA {
a: ComponentA(31),
b: ComponentB(20),
})
.id();

let boxed_reflect_bundle_a = Box::new(BundleA {
a: ComponentA(1),
Expand All @@ -606,7 +609,6 @@ mod tests {
fn remove_reflected_bundle_with_registry() {
let mut world = World::new();


let mut type_registry = TypeRegistryResource {
type_registry: TypeRegistry::new(),
};
Expand All @@ -620,10 +622,12 @@ mod tests {
let mut system_state: SystemState<Commands> = SystemState::new(&mut world);
let mut commands = system_state.get_mut(&mut world);

let entity = commands.spawn(BundleA {
a: ComponentA(31),
b: ComponentB(20),
}).id();
let entity = commands
.spawn(BundleA {
a: ComponentA(31),
b: ComponentB(20),
})
.id();

let boxed_reflect_bundle_a = Box::new(BundleA {
a: ComponentA(1),
Expand All @@ -633,7 +637,7 @@ mod tests {
commands
.entity(entity)
.remove_reflect_with_registry::<TypeRegistryResource>(
boxed_reflect_bundle_a.reflect_type_path().to_owned()
boxed_reflect_bundle_a.reflect_type_path().to_owned(),
);
system_state.apply(&mut world);

Expand Down

0 comments on commit a3dba6c

Please sign in to comment.