@@ -20,16 +20,16 @@ use bevy::prelude::{Entity, Commands};
20
20
use smallvec:: SmallVec ;
21
21
22
22
use crate :: {
23
- Dangling , UnusedTarget , ForkTargetStorage , OperationRequest , Input , ManageInput ,
24
- ForkUnzip , AddOperation , OutputChain , FunnelInputStorage , OperationResult ,
25
- SingleTargetStorage , OrBroken , OperationReachability ,
26
- OperationError , InspectInput ,
23
+ UnusedTarget , ForkTargetStorage , OperationRequest , Input , ManageInput ,
24
+ ForkUnzip , AddOperation , FunnelInputStorage , OperationResult ,
25
+ SingleTargetStorage , OrBroken , OperationReachability , Output ,
26
+ OperationError , InspectInput , Chain ,
27
27
} ;
28
28
29
29
/// A trait for response types that can be unzipped
30
30
pub trait Unzippable {
31
31
type Unzipped ;
32
- fn unzip_chain ( source : Entity , commands : & mut Commands ) -> Self :: Unzipped ;
32
+ fn unzip_chain ( scope : Entity , source : Entity , commands : & mut Commands ) -> Self :: Unzipped ;
33
33
34
34
fn make_targets ( commands : & mut Commands ) -> SmallVec < [ Entity ; 8 ] > ;
35
35
@@ -62,11 +62,11 @@ pub enum JoinStatus {
62
62
pub type JoinStatusResult = Result < JoinStatus , OperationError > ;
63
63
64
64
impl < A : ' static + Send + Sync > Unzippable for ( A , ) {
65
- type Unzipped = Dangling < A > ;
66
- fn unzip_chain ( source : Entity , commands : & mut Commands ) -> Self :: Unzipped {
65
+ type Unzipped = Output < A > ;
66
+ fn unzip_chain ( scope : Entity , source : Entity , commands : & mut Commands ) -> Self :: Unzipped {
67
67
let targets = Self :: make_targets ( commands) ;
68
68
69
- let result = Dangling :: new ( source , targets[ 0 ] ) ;
69
+ let result = Output :: new ( scope , targets[ 0 ] ) ;
70
70
71
71
commands. add ( AddOperation :: new (
72
72
source,
@@ -130,7 +130,7 @@ impl<A: 'static + Send + Sync> Unzippable for (A,) {
130
130
OperationRequest { source, world, roster } : OperationRequest ,
131
131
) -> OperationResult {
132
132
let inputs = world. get :: < FunnelInputStorage > ( source) . or_broken ( ) ?;
133
- let target = world. get :: < SingleTargetStorage > ( source) . or_broken ( ) ?. 0 ;
133
+ let target = world. get :: < SingleTargetStorage > ( source) . or_broken ( ) ?. get ( ) ;
134
134
135
135
let input_0 = * inputs. 0 . get ( 0 ) . or_broken ( ) ?;
136
136
@@ -146,13 +146,13 @@ impl<A: 'static + Send + Sync> Unzippable for (A,) {
146
146
}
147
147
148
148
impl < A : ' static + Send + Sync , B : ' static + Send + Sync > Unzippable for ( A , B ) {
149
- type Unzipped = ( Dangling < A > , Dangling < B > ) ;
150
- fn unzip_chain ( source : Entity , commands : & mut Commands ) -> Self :: Unzipped {
149
+ type Unzipped = ( Output < A > , Output < B > ) ;
150
+ fn unzip_chain ( scope : Entity , source : Entity , commands : & mut Commands ) -> Self :: Unzipped {
151
151
let targets = Self :: make_targets ( commands) ;
152
152
153
153
let result = (
154
- Dangling :: new ( source , targets[ 0 ] ) ,
155
- Dangling :: new ( source , targets[ 1 ] ) ,
154
+ Output :: new ( scope , targets[ 0 ] ) ,
155
+ Output :: new ( scope , targets[ 1 ] ) ,
156
156
) ;
157
157
158
158
commands. add ( AddOperation :: new (
@@ -216,6 +216,7 @@ impl<A: 'static + Send + Sync, B: 'static + Send + Sync> Unzippable for (A, B) {
216
216
}
217
217
}
218
218
219
+ let world = reachability. world ( ) ;
219
220
if !world. get_entity ( input_1) . or_broken ( ) ?. buffer_ready :: < B > ( session) ? {
220
221
status = JoinStatus :: Pending ;
221
222
if !reachability. check_upstream ( input_1) ? {
@@ -235,7 +236,7 @@ impl<A: 'static + Send + Sync, B: 'static + Send + Sync> Unzippable for (A, B) {
235
236
OperationRequest { source, world, roster } : OperationRequest ,
236
237
) -> OperationResult {
237
238
let inputs = world. get :: < FunnelInputStorage > ( source) . or_broken ( ) ?;
238
- let target = world. get :: < SingleTargetStorage > ( source) . or_broken ( ) ?. 0 ;
239
+ let target = world. get :: < SingleTargetStorage > ( source) . or_broken ( ) ?. get ( ) ;
239
240
240
241
let input_0 = * inputs. 0 . get ( 0 ) . or_broken ( ) ?;
241
242
let input_1 = * inputs. 0 . get ( 1 ) . or_broken ( ) ?;
@@ -262,14 +263,14 @@ where
262
263
B : ' static + Send + Sync ,
263
264
C : ' static + Send + Sync ,
264
265
{
265
- type Unzipped = ( Dangling < A > , Dangling < B > , Dangling < C > ) ;
266
- fn unzip_chain ( source : Entity , commands : & mut Commands ) -> Self :: Unzipped {
266
+ type Unzipped = ( Output < A > , Output < B > , Output < C > ) ;
267
+ fn unzip_chain ( scope : Entity , source : Entity , commands : & mut Commands ) -> Self :: Unzipped {
267
268
let targets = Self :: make_targets ( commands) ;
268
269
269
270
let result = (
270
- Dangling :: new ( source , targets[ 0 ] ) ,
271
- Dangling :: new ( source , targets[ 1 ] ) ,
272
- Dangling :: new ( source , targets[ 2 ] ) ,
271
+ Output :: new ( scope , targets[ 0 ] ) ,
272
+ Output :: new ( scope , targets[ 1 ] ) ,
273
+ Output :: new ( scope , targets[ 2 ] ) ,
273
274
) ;
274
275
275
276
commands. add ( AddOperation :: new (
@@ -320,36 +321,35 @@ where
320
321
}
321
322
322
323
fn join_status (
323
- mut reachability : OperationReachability ,
324
+ mut r : OperationReachability ,
324
325
) -> JoinStatusResult {
325
- let source = reachability. source ( ) ;
326
- let session = reachability. session ( ) ;
327
- let world = reachability. world ( ) ;
328
- let inputs = world. get :: < FunnelInputStorage > ( source) . or_broken ( ) ?;
326
+ let source = r. source ( ) ;
327
+ let session = r. session ( ) ;
328
+ let inputs = r. world ( ) . get :: < FunnelInputStorage > ( source) . or_broken ( ) ?;
329
329
let mut unreachable: Vec < Entity > = Vec :: new ( ) ;
330
330
let mut status = JoinStatus :: Ready ;
331
331
332
332
let input_0 = * inputs. 0 . get ( 0 ) . or_broken ( ) ?;
333
333
let input_1 = * inputs. 0 . get ( 1 ) . or_broken ( ) ?;
334
334
let input_2 = * inputs. 0 . get ( 2 ) . or_broken ( ) ?;
335
335
336
- if !world. get_entity ( input_0) . or_broken ( ) ?. buffer_ready :: < A > ( session) ? {
336
+ if !r . world ( ) . get_entity ( input_0) . or_broken ( ) ?. buffer_ready :: < A > ( session) ? {
337
337
status = JoinStatus :: Pending ;
338
- if !reachability . check_upstream ( input_0) ? {
338
+ if !r . check_upstream ( input_0) ? {
339
339
unreachable. push ( input_0) ;
340
340
}
341
341
}
342
342
343
- if !world. get_entity ( input_1) . or_broken ( ) ?. buffer_ready :: < B > ( session) ? {
343
+ if !r . world ( ) . get_entity ( input_1) . or_broken ( ) ?. buffer_ready :: < B > ( session) ? {
344
344
status = JoinStatus :: Pending ;
345
- if !reachability . check_upstream ( input_1) ? {
345
+ if !r . check_upstream ( input_1) ? {
346
346
unreachable. push ( input_1) ;
347
347
}
348
348
}
349
349
350
- if !world. get_entity ( input_2) . or_broken ( ) ?. buffer_ready :: < C > ( session) ? {
350
+ if !r . world ( ) . get_entity ( input_2) . or_broken ( ) ?. buffer_ready :: < C > ( session) ? {
351
351
status = JoinStatus :: Pending ;
352
- if !reachability . check_upstream ( input_2) ? {
352
+ if !r . check_upstream ( input_2) ? {
353
353
unreachable. push ( input_2) ;
354
354
}
355
355
}
@@ -366,7 +366,7 @@ where
366
366
OperationRequest { source, world, roster } : OperationRequest ,
367
367
) -> OperationResult {
368
368
let inputs = world. get :: < FunnelInputStorage > ( source) . or_broken ( ) ?;
369
- let target = world. get :: < SingleTargetStorage > ( source) . or_broken ( ) ?. 0 ;
369
+ let target = world. get :: < SingleTargetStorage > ( source) . or_broken ( ) ?. get ( ) ;
370
370
371
371
let input_0 = * inputs. 0 . get ( 0 ) . or_broken ( ) ?;
372
372
let input_1 = * inputs. 0 . get ( 1 ) . or_broken ( ) ?;
@@ -397,21 +397,21 @@ where
397
397
/// tuple.
398
398
pub trait UnzipBuilder < Z > {
399
399
type Output ;
400
- fn unzip_build ( self , source : Entity , commands : & mut Commands ) -> Self :: Output ;
400
+ fn unzip_build ( self , scope : Entity , source : Entity , commands : & mut Commands ) -> Self :: Output ;
401
401
}
402
402
403
403
impl < A , Fa , Ua , B , Fb , Ub > UnzipBuilder < ( A , B ) > for ( Fa , Fb )
404
404
where
405
405
A : ' static + Send + Sync ,
406
406
B : ' static + Send + Sync ,
407
- Fa : FnOnce ( OutputChain < A > ) -> Ua ,
408
- Fb : FnOnce ( OutputChain < B > ) -> Ub ,
407
+ Fa : FnOnce ( Chain < A > ) -> Ua ,
408
+ Fb : FnOnce ( Chain < B > ) -> Ub ,
409
409
{
410
410
type Output = ( Ua , Ub ) ;
411
- fn unzip_build ( self , source : Entity , commands : & mut Commands ) -> Self :: Output {
412
- let dangling = <( A , B ) >:: unzip_chain ( source, commands) ;
413
- let u_a = ( self . 0 ) ( dangling . 0 . resume ( commands) ) ;
414
- let u_b = ( self . 1 ) ( dangling . 1 . resume ( commands) ) ;
411
+ fn unzip_build ( self , scope : Entity , source : Entity , commands : & mut Commands ) -> Self :: Output {
412
+ let outputs = <( A , B ) >:: unzip_chain ( scope , source, commands) ;
413
+ let u_a = ( self . 0 ) ( outputs . 0 . chain ( commands) ) ;
414
+ let u_b = ( self . 1 ) ( outputs . 1 . chain ( commands) ) ;
415
415
( u_a, u_b)
416
416
}
417
417
}
@@ -421,16 +421,16 @@ where
421
421
A : ' static + Send + Sync ,
422
422
B : ' static + Send + Sync ,
423
423
C : ' static + Send + Sync ,
424
- Fa : FnOnce ( OutputChain < A > ) -> Ua ,
425
- Fb : FnOnce ( OutputChain < B > ) -> Ub ,
426
- Fc : FnOnce ( OutputChain < C > ) -> Uc ,
424
+ Fa : FnOnce ( Chain < A > ) -> Ua ,
425
+ Fb : FnOnce ( Chain < B > ) -> Ub ,
426
+ Fc : FnOnce ( Chain < C > ) -> Uc ,
427
427
{
428
428
type Output = ( Ua , Ub , Uc ) ;
429
- fn unzip_build ( self , source : Entity , commands : & mut Commands ) -> Self :: Output {
430
- let dangling = <( A , B , C ) >:: unzip_chain ( source, commands) ;
431
- let u_a = ( self . 0 ) ( dangling . 0 . resume ( commands) ) ;
432
- let u_b = ( self . 1 ) ( dangling . 1 . resume ( commands) ) ;
433
- let u_c = ( self . 2 ) ( dangling . 2 . resume ( commands) ) ;
429
+ fn unzip_build ( self , scope : Entity , source : Entity , commands : & mut Commands ) -> Self :: Output {
430
+ let outputs = <( A , B , C ) >:: unzip_chain ( scope , source, commands) ;
431
+ let u_a = ( self . 0 ) ( outputs . 0 . chain ( commands) ) ;
432
+ let u_b = ( self . 1 ) ( outputs . 1 . chain ( commands) ) ;
433
+ let u_c = ( self . 2 ) ( outputs . 2 . chain ( commands) ) ;
434
434
( u_a, u_b, u_c)
435
435
}
436
436
}
0 commit comments