From 7e26148061a9b9eb0ba75d7240d1f5e5ed7c7e5d Mon Sep 17 00:00:00 2001 From: Marla Schulz Date: Tue, 13 Aug 2024 10:03:22 -0700 Subject: [PATCH] Move setDataPoints override to IOType, see: https://github.com/phetsims/mean-share-and-balance/issues/335 (cherry picked from commit 431ad8b359b09fd8c719b6c77c6f2f8d68ea352e) --- js/balance-point/model/BalancePointModel.ts | 21 +++++++++++++------ .../model/BalancePointSceneModel.ts | 18 ---------------- 2 files changed, 15 insertions(+), 24 deletions(-) diff --git a/js/balance-point/model/BalancePointModel.ts b/js/balance-point/model/BalancePointModel.ts index e16a0d1..0a07260 100644 --- a/js/balance-point/model/BalancePointModel.ts +++ b/js/balance-point/model/BalancePointModel.ts @@ -120,8 +120,19 @@ export default class BalancePointModel extends SoccerModel soccerBall.valueProperty.value ); - }, + implementation: ( model: BalancePointModel ) => + model.selectedSceneModelProperty.value.getSortedStackedObjects().map( soccerBall => soccerBall.valueProperty.value ), documentation: 'Gets the data points for the selected scene model.' } } diff --git a/js/balance-point/model/BalancePointSceneModel.ts b/js/balance-point/model/BalancePointSceneModel.ts index 6a1629a..f9be636 100644 --- a/js/balance-point/model/BalancePointSceneModel.ts +++ b/js/balance-point/model/BalancePointSceneModel.ts @@ -412,24 +412,6 @@ export default class BalancePointSceneModel extends SoccerSceneModel { this.meanPredictionFulcrumValueProperty.reset(); this.beamSupportsPresentProperty.reset(); } - - /** - * Set the data points for the scene model. This is only called by phet-io clients and should not be used by the sim - * itself. - */ - public override setDataPoints( dataPoints: number[] ): void { - super.setDataPoints( dataPoints ); - - // When phet-io clients set the data points statically there should be no animation and therefore no queued kicks. - // We do this work here because soccer-common does not inherently support of numberOfBallsPorperty that drives - // the addition and removal of soccer balls. super.setDataPoints automatically adds balls to the field as desired - // and bypasses targetNumberOfBallsProperty. Ideally we would cancel all listeners to the targetNumberOfBallsProperty - // in this use case, however that is not supported. Therefore, we will zero out the numberOfQueuedKicksProperty - // that is the next link in the chain. We know this is inherently fragile, and should only be used by PhET-iO - // clients. If the listener chain changes, or QueuedKicks behaves differently this will need to be updated. - this.targetNumberOfBallsProperty.value = Math.min( dataPoints.length, this.maxKicksProperty.value ); - this.numberOfQueuedKicksProperty.value = 0; - } } type BalanceBeamEndpointYValuesStateObject = {