@@ -186,28 +186,27 @@ pub trait Relationship: Component + Sized {
186
186
}
187
187
}
188
188
let target_entity = world. entity ( entity) . get :: < Self > ( ) . unwrap ( ) . get ( ) ;
189
- if let Ok ( mut target_entity_mut) = world. get_entity_mut ( target_entity) {
190
- if let Some ( mut relationship_target) =
189
+ if let Ok ( mut target_entity_mut) = world. get_entity_mut ( target_entity)
190
+ && let Some ( mut relationship_target) =
191
191
target_entity_mut. get_mut :: < Self :: RelationshipTarget > ( )
192
- {
193
- relationship_target. collection_mut_risky ( ) . remove ( entity) ;
194
- if relationship_target. len ( ) == 0 {
195
- let command = |mut entity : EntityWorldMut | {
196
- // this "remove" operation must check emptiness because in the event that an identical
197
- // relationship is inserted on top, this despawn would result in the removal of that identical
198
- // relationship ... not what we want!
199
- if entity
200
- . get :: < Self :: RelationshipTarget > ( )
201
- . is_some_and ( RelationshipTarget :: is_empty)
202
- {
203
- entity. remove :: < Self :: RelationshipTarget > ( ) ;
204
- }
205
- } ;
206
-
207
- world
208
- . commands ( )
209
- . queue_silenced ( command. with_entity ( target_entity) ) ;
210
- }
192
+ {
193
+ relationship_target. collection_mut_risky ( ) . remove ( entity) ;
194
+ if relationship_target. len ( ) == 0 {
195
+ let command = |mut entity : EntityWorldMut | {
196
+ // this "remove" operation must check emptiness because in the event that an identical
197
+ // relationship is inserted on top, this despawn would result in the removal of that identical
198
+ // relationship ... not what we want!
199
+ if entity
200
+ . get :: < Self :: RelationshipTarget > ( )
201
+ . is_some_and ( RelationshipTarget :: is_empty)
202
+ {
203
+ entity. remove :: < Self :: RelationshipTarget > ( ) ;
204
+ }
205
+ } ;
206
+
207
+ world
208
+ . commands ( )
209
+ . queue_silenced ( command. with_entity ( target_entity) ) ;
211
210
}
212
211
}
213
212
}
0 commit comments