@@ -393,6 +393,8 @@ impl<P: IntoScriptPluginParams> System for DynamicScriptSystem<P> {
393
393
fn has_deferred ( & self ) -> bool {
394
394
false
395
395
}
396
+
397
+
396
398
397
399
unsafe fn run_unsafe (
398
400
& mut self ,
@@ -411,15 +413,21 @@ impl<P: IntoScriptPluginParams> System for DynamicScriptSystem<P> {
411
413
} ;
412
414
413
415
let mut payload = Vec :: with_capacity ( state. system_params . len ( ) ) ;
414
-
415
- let guard = WorldAccessGuard :: new_non_exclusive (
416
- world,
417
- state. subset . clone ( ) ,
418
- state. type_registry . clone ( ) ,
419
- state. allocator . clone ( ) ,
420
- state. function_registry . clone ( ) ,
421
- state. schedule_registry . clone ( ) ,
422
- ) ;
416
+
417
+ let guard = if self . exclusive {
418
+ // safety: we are an exclusive system, therefore the cell allows us to do this
419
+ let world = unsafe { world. world_mut ( ) } ;
420
+ WorldAccessGuard :: new_exclusive ( world)
421
+ } else {
422
+ WorldAccessGuard :: new_non_exclusive (
423
+ world,
424
+ state. subset . clone ( ) ,
425
+ state. type_registry . clone ( ) ,
426
+ state. allocator . clone ( ) ,
427
+ state. function_registry . clone ( ) ,
428
+ state. schedule_registry . clone ( ) ,
429
+ )
430
+ } ;
423
431
424
432
// TODO: cache references which don't change once we have benchmarks
425
433
for param in & mut state. system_params {
@@ -615,6 +623,20 @@ impl<P: IntoScriptPluginParams> System for DynamicScriptSystem<P> {
615
623
fn default_system_sets ( & self ) -> Vec < bevy:: ecs:: schedule:: InternedSystemSet > {
616
624
vec ! [ ScriptSystemSet :: new( self . name. clone( ) ) . intern( ) ]
617
625
}
626
+
627
+ fn type_id ( & self ) -> TypeId {
628
+ TypeId :: of :: < Self > ( )
629
+ }
630
+
631
+
632
+ fn validate_param ( & mut self , world : & World ) -> bool {
633
+ let world_cell = world. as_unsafe_world_cell_readonly ( ) ;
634
+ self . update_archetype_component_access ( world_cell) ;
635
+ // SAFETY:
636
+ // - We have exclusive access to the entire world.
637
+ // - `update_archetype_component_access` has been called.
638
+ unsafe { self . validate_param_unsafe ( world_cell) }
639
+ }
618
640
}
619
641
620
642
0 commit comments