Skip to content

Commit

Permalink
Fixes to return bodies logic, see phetsims/my-solar-system#112
Browse files Browse the repository at this point in the history
  • Loading branch information
AgustinVallejo committed Mar 15, 2023
1 parent 105a645 commit ed924b2
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions js/model/SolarSystemCommonModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,10 @@ abstract class SolarSystemCommonModel<EngineType extends Engine = Engine> {
const idealBodies = this.availableBodies.filter( body => body.isActiveProperty.value );

// Remove all inactive bodies
this.bodies.filter( body => !body.isActiveProperty.value ).forEach( body => this.bodies.remove( body ) );
this.bodies.filter( body => !body.isActiveProperty.value ).forEach( body => {
this.bodies.remove( body );
body.reset();
} );

// Add in active bodies (in order)
for ( let i = 0; i < idealBodies.length; i++ ) {
Expand All @@ -145,7 +148,7 @@ abstract class SolarSystemCommonModel<EngineType extends Engine = Engine> {
}
} );

this.isAnyBodyEscapedProperty = DerivedProperty.or( this.bodies.map( body => body.escapedProperty ) );
this.isAnyBodyEscapedProperty = DerivedProperty.or( this.availableBodies.map( body => body.escapedProperty ) );

this.availableBodies.forEach( body => {
Multilink.lazyMultilink(
Expand Down

0 comments on commit ed924b2

Please sign in to comment.