From ed924b2ed85659cb00f269e73b8c5d7609b58c70 Mon Sep 17 00:00:00 2001 From: AgustinVallejo Date: Wed, 15 Mar 2023 11:21:04 -0500 Subject: [PATCH] Fixes to return bodies logic, see https://github.com/phetsims/my-solar-system/issues/112 --- js/model/SolarSystemCommonModel.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/js/model/SolarSystemCommonModel.ts b/js/model/SolarSystemCommonModel.ts index 3cdfe5a..8ca740c 100644 --- a/js/model/SolarSystemCommonModel.ts +++ b/js/model/SolarSystemCommonModel.ts @@ -135,7 +135,10 @@ abstract class SolarSystemCommonModel { 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++ ) { @@ -145,7 +148,7 @@ abstract class SolarSystemCommonModel { } } ); - 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(