@@ -292,16 +292,21 @@ impl Plugin for YoleckPluginBase {
292292 entity_management:: yoleck_process_raw_entries,
293293 ApplyDeferred ,
294294 (
295- entity_management:: yoleck_run_level_loaded_schedule,
295+ entity_management:: yoleck_run_post_load_resolutions_schedule,
296+ entity_management:: yoleck_run_level_loaded_schedule. run_if (
297+ |freshly_loaded_level_entities : Query <
298+ ( ) ,
299+ ( With < YoleckLevelJustLoaded > , Without < YoleckLevelInEditor > ) ,
300+ > | { !freshly_loaded_level_entities. is_empty ( ) } ,
301+ ) ,
296302 entity_management:: yoleck_remove_just_loaded_marker_from_levels,
297303 ApplyDeferred ,
298304 )
299305 . chain ( )
300306 . run_if (
301- |freshly_loaded_level_entities : Query <
302- ( ) ,
303- ( With < YoleckLevelJustLoaded > , Without < YoleckLevelInEditor > ) ,
304- > | { !freshly_loaded_level_entities. is_empty ( ) } ,
307+ |freshly_loaded_level_entities : Query < ( ) , With < YoleckLevelJustLoaded > > | {
308+ !freshly_loaded_level_entities. is_empty ( )
309+ } ,
305310 ) ,
306311 )
307312 . chain ( )
@@ -332,6 +337,7 @@ impl Plugin for YoleckPluginBase {
332337 . before ( YoleckSystems :: ProcessRawEntities ) , ) ,
333338 ) ;
334339 app. add_schedule ( Schedule :: new ( YoleckSchedule :: Populate ) ) ;
340+ app. add_schedule ( Schedule :: new ( YoleckInternalSchedule :: PostLoadResolutions ) ) ;
335341 app. add_schedule ( Schedule :: new ( YoleckSchedule :: LevelLoaded ) ) ;
336342 app. add_schedule ( Schedule :: new ( YoleckSchedule :: OverrideCommonComponents ) ) ;
337343 }
@@ -567,7 +573,7 @@ pub struct YoleckManaged {
567573
568574 lifecycle_status : YoleckEntityLifecycleStatus ,
569575
570- components_data : HashMap < TypeId , BoxedAny > ,
576+ pub ( crate ) components_data : HashMap < TypeId , BoxedAny > ,
571577}
572578
573579/// A marker for entities that belongs to the Yoleck level and should be despawned with it.
@@ -645,6 +651,9 @@ pub struct YoleckPlaytestLevel(pub Option<YoleckRawLevel>);
645651#[ derive( ScheduleLabel , Debug , Clone , PartialEq , Eq , Hash ) ]
646652pub ( crate ) enum YoleckInternalSchedule {
647653 UpdateManagedDataFromComponents ,
654+ /// Before [`LevelLoaded`][YoleckSchedule::LevelLoaded] to resolve things like entity
655+ /// references.
656+ PostLoadResolutions ,
648657}
649658
650659/// Schedules for user code to do the actual entity/level population after Yoleck spawns the level
0 commit comments