@@ -615,18 +615,26 @@ impl SignalBuilder {
615615 Self :: from_system ( move |_: In < ( ) > | entity. get ( ) )
616616 }
617617
618+ /// Creates a [`Source`] signal from an [`Entity`]'s `generations`-th generation ancestor's
619+ /// [`Entity`]. Passing `0` to `generation` will output the [`Entity`] itself.
618620 pub fn from_ancestor ( entity : Entity , generations : usize ) -> Map < Source < Entity > , Entity > {
619621 Self :: from_entity ( entity) . map ( ancestor_map ( generations) )
620622 }
621623
624+ /// Creates a [`Source`] signal from a [`LazyEntity`]'s `generations`-th generation ancestor's
625+ /// [`Entity`]. Passing `0` to `generation` will output the [`LazyEntity`]'s [`Entity`] itself.
622626 pub fn from_ancestor_lazy ( entity : LazyEntity , generations : usize ) -> Map < Source < Entity > , Entity > {
623627 Self :: from_lazy_entity ( entity) . map ( ancestor_map ( generations) )
624628 }
625629
630+ /// Creates a [`Source`] signal from an [`Entity`]'s parent's [`Entity`]. Passing `0` to
631+ /// `generation` will output the [`Entity`] itself.
626632 pub fn from_parent ( entity : Entity ) -> Map < Source < Entity > , Entity > {
627633 Self :: from_ancestor ( entity, 1 )
628634 }
629635
636+ /// Creates a [`Source`] signal from a [`LazyEntity`]'s parent's [`Entity`]. Passing `0` to
637+ /// `generation` will output the [`LazyEntity`]'s [`Entity`] itself.
630638 pub fn from_parent_lazy ( entity : LazyEntity ) -> Map < Source < Entity > , Entity > {
631639 Self :: from_ancestor_lazy ( entity, 1 )
632640 }
@@ -1848,19 +1856,23 @@ impl<T: ?Sized> SignalExt for T where T: Signal {}
18481856
18491857#[ cfg( test) ]
18501858mod tests {
1851- use super :: * ;
18521859 use crate :: {
18531860 JonmoPlugin ,
1854- prelude:: { MutableVec , SignalVecExt } ,
1861+ graph:: { LazySignalHolder , SignalRegistrationCount } ,
1862+ prelude:: { MutableVec , SignalVecExt , clone} ,
1863+ signal:: { SignalBuilder , SignalExt , Upstream } ,
1864+ signal_vec:: VecDiff ,
1865+ utils:: SSs ,
18551866 } ;
1867+ use core:: { convert:: identity, fmt} ;
18561868
18571869 // Import Bevy prelude for MinimalPlugins and other common items
18581870 use bevy:: prelude:: * ;
18591871 use bevy_platform:: sync:: * ;
18601872 use bevy_time:: TimeUpdateStrategy ;
18611873
18621874 // Add Duration
1863- use core:: { convert :: identity , time:: Duration } ;
1875+ use core:: time:: Duration ;
18641876
18651877 // Helper component and resource for testing Add Default
18661878 #[ derive( Component , Clone , Debug , PartialEq , Reflect , Default ) ]
@@ -2624,7 +2636,7 @@ mod tests {
26242636 // --- Test Some case ---
26252637 let source_some = SignalBuilder :: from_system ( |_: In < ( ) > | Some ( 42 ) ) ;
26262638 let signal_some = source_some
2627- . map_some ( |In ( val) : In < i32 > | format ! ( "Got {}" , val ) )
2639+ . map_some ( |In ( val) : In < i32 > | format ! ( "Got {val}" ) )
26282640 . map ( capture_output)
26292641 . register ( app. world_mut ( ) ) ;
26302642 app. update ( ) ;
0 commit comments