@@ -267,7 +267,7 @@ impl SimpleEnum {
267267}
268268
269269pub ( crate ) const TEST_COMPONENT_ID_START : usize = 20 ;
270- pub ( crate ) const TEST_ENTITY_ID_START : u32 = 0 ;
270+ pub ( crate ) const TEST_ENTITY_ID_START : u32 = 1 ;
271271
272272pub trait GetTestComponentId {
273273 fn test_component_id ( ) -> ComponentId ;
@@ -306,6 +306,10 @@ macro_rules! impl_test_component_ids {
306306
307307 pub ( crate ) fn init_all_components( world: & mut World , registry: & mut TypeRegistry ) {
308308 $(
309+ // world
310+ // .components()
311+ // .iter_registered()
312+ // .for_each(|c| println!("--> {:?}", c));
309313 world. register_component:: <$comp_type>( ) ;
310314 registry. register:: <$comp_type>( ) ;
311315 let registered_id = world. component_id:: <$comp_type>( ) . unwrap( ) . index( ) ;
@@ -338,8 +342,8 @@ macro_rules! impl_test_component_ids {
338342 } ;
339343}
340344
341- impl_test_component_ids ! (
342- [ TestComponent => 0 ,
345+ impl_test_component_ids ! ( [
346+ TestComponent => 0 ,
343347 CompWithFromWorld => 1 ,
344348 CompWithDefault => 2 ,
345349 CompWithDefaultAndComponentData => 3 ,
@@ -362,6 +366,21 @@ fn init_world<F: FnOnce(&mut World, &mut TypeRegistry)>(world: &mut World, init:
362366 let type_registry = world. get_resource_or_init :: < AppTypeRegistry > ( ) . clone ( ) ;
363367 let mut type_registry_guard = type_registry. 0 . write ( ) ;
364368
369+ // bevy now spawns an ineternal component `bevy_ecs::event::EventWrapperComponent<bevy_ecs::archetype::ArchetypeCreated>`
370+ // when an entity with a component is inserted :shrug:, make that happen early
371+ #[ derive( Component ) ]
372+ pub struct Dummy ;
373+ world. register_component :: < Dummy > ( ) ;
374+ world. spawn ( ( Dummy , ) ) ;
375+
376+ if world. components ( ) . len ( ) > TEST_COMPONENT_ID_START {
377+ panic ! ( "world has more components than the first test component ID requires" )
378+ }
379+
380+ if world. entities ( ) . len ( ) > TEST_ENTITY_ID_START {
381+ panic ! ( "world has more entities than the first test component ID requires" )
382+ }
383+
365384 while world. components ( ) . len ( ) < TEST_COMPONENT_ID_START {
366385 unsafe {
367386 world. register_component_with_descriptor ( ComponentDescriptor :: new_with_layout (
0 commit comments