@@ -558,6 +558,47 @@ fn visibility_gain() {
558558 assert_eq ! ( components. iter( client_app. world( ) ) . len( ) , 1 ) ;
559559}
560560
561+ #[ test]
562+ fn visibility_gain_late_client ( ) {
563+ let mut server_app = App :: new ( ) ;
564+ let mut client_app = App :: new ( ) ;
565+ for app in [ & mut server_app, & mut client_app] {
566+ app. add_plugins ( (
567+ MinimalPlugins ,
568+ StatesPlugin ,
569+ RepliconPlugins . set ( ServerPlugin :: new ( PostUpdate ) ) ,
570+ ) )
571+ . replicate :: < A > ( )
572+ . add_visibility_filter :: < DeferredVisibility > ( )
573+ . finish ( ) ;
574+ }
575+
576+ server_app. connect_client ( & mut client_app) ;
577+
578+ server_app
579+ . world_mut ( )
580+ . spawn ( ( Replicated , DeferredVisibility , A ) ) ;
581+
582+ server_app. update ( ) ;
583+ server_app. exchange_with_client ( & mut client_app) ;
584+ client_app. update ( ) ;
585+
586+ let mut components = client_app. world_mut ( ) . query :: < & A > ( ) ;
587+ assert_eq ! ( components. iter( client_app. world( ) ) . len( ) , 0 ) ;
588+
589+ let client = * * client_app. world ( ) . resource :: < TestClientEntity > ( ) ;
590+ server_app
591+ . world_mut ( )
592+ . entity_mut ( client)
593+ . insert ( CanSeeDeferred ) ;
594+
595+ server_app. update ( ) ;
596+ server_app. exchange_with_client ( & mut client_app) ;
597+ client_app. update ( ) ;
598+
599+ assert_eq ! ( components. iter( client_app. world( ) ) . len( ) , 1 ) ;
600+ }
601+
561602#[ test]
562603fn visibility_gain_with_signature ( ) {
563604 let mut server_app = App :: new ( ) ;
@@ -616,3 +657,20 @@ impl VisibilityFilter for EntityVisibility {
616657 component. is_some ( )
617658 }
618659}
660+
661+ #[ derive( Component ) ]
662+ #[ component( immutable) ]
663+ struct DeferredVisibility ;
664+
665+ #[ derive( Component ) ]
666+ #[ component( immutable) ]
667+ struct CanSeeDeferred ;
668+
669+ impl VisibilityFilter for DeferredVisibility {
670+ type ClientComponent = CanSeeDeferred ;
671+ type Scope = Entity ;
672+
673+ fn is_visible ( & self , _client : Entity , component : Option < & Self :: ClientComponent > ) -> bool {
674+ component. is_some ( )
675+ }
676+ }
0 commit comments