1
1
use crate :: { CoreStage , Plugin , PluginGroup , PluginGroupBuilder , StartupSchedule , StartupStage } ;
2
2
pub use bevy_derive:: AppLabel ;
3
+ use bevy_derive:: { Deref , DerefMut } ;
3
4
use bevy_ecs:: {
4
5
event:: { Event , Events } ,
5
6
prelude:: { FromWorld , IntoExclusiveSystem } ,
@@ -22,6 +23,11 @@ bevy_utils::define_label!(
22
23
AppLabelId ,
23
24
) ;
24
25
26
+ /// The [`Resource`] that stores the [`App`]'s [`TypeRegistry`](bevy_reflect::TypeRegistry).
27
+ #[ cfg( feature = "bevy_reflect" ) ]
28
+ #[ derive( Resource , Clone , Deref , DerefMut , Default ) ]
29
+ pub struct AppTypeRegistry ( pub bevy_reflect:: TypeRegistryArc ) ;
30
+
25
31
#[ allow( clippy:: needless_doctest_main) ]
26
32
/// A container of app logic and data.
27
33
///
@@ -74,7 +80,7 @@ impl Default for App {
74
80
fn default ( ) -> Self {
75
81
let mut app = App :: empty ( ) ;
76
82
#[ cfg( feature = "bevy_reflect" ) ]
77
- app. init_resource :: < bevy_reflect :: TypeRegistryArc > ( ) ;
83
+ app. init_resource :: < AppTypeRegistry > ( ) ;
78
84
79
85
app. add_default_stages ( )
80
86
. add_event :: < AppExit > ( )
@@ -878,7 +884,7 @@ impl App {
878
884
#[ cfg( feature = "bevy_reflect" ) ]
879
885
pub fn register_type < T : bevy_reflect:: GetTypeRegistration > ( & mut self ) -> & mut Self {
880
886
{
881
- let registry = self . world . resource_mut :: < bevy_reflect :: TypeRegistryArc > ( ) ;
887
+ let registry = self . world . resource_mut :: < AppTypeRegistry > ( ) ;
882
888
registry. write ( ) . register :: < T > ( ) ;
883
889
}
884
890
self
@@ -911,7 +917,7 @@ impl App {
911
917
& mut self ,
912
918
) -> & mut Self {
913
919
{
914
- let registry = self . world . resource_mut :: < bevy_reflect :: TypeRegistryArc > ( ) ;
920
+ let registry = self . world . resource_mut :: < AppTypeRegistry > ( ) ;
915
921
registry. write ( ) . register_type_data :: < T , D > ( ) ;
916
922
}
917
923
self
0 commit comments