Skip to content

Commit

Permalink
instrument inProportionProperty and movingInDirectionProperty, #351 #142
Browse files Browse the repository at this point in the history
  • Loading branch information
zepumph committed May 4, 2021
1 parent f32b476 commit 01e4010
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
6 changes: 5 additions & 1 deletion js/common/model/RAPModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import DerivedProperty from '../../../../axon/js/DerivedProperty.js';
import NumberProperty from '../../../../axon/js/NumberProperty.js';
import Utils from '../../../../dot/js/Utils.js';
import Vector2 from '../../../../dot/js/Vector2.js';
import BooleanIO from '../../../../tandem/js/types/BooleanIO.js';
import NumberIO from '../../../../tandem/js/types/NumberIO.js';
import ratioAndProportion from '../../ratioAndProportion.js';
import rapConstants from '../rapConstants.js';
Expand Down Expand Up @@ -114,7 +115,10 @@ unclampedFitness: ${unclampedFitness}
this.inProportionProperty = new DerivedProperty( [
this.unclampedFitnessProperty,
this.ratio.movingInDirectionProperty
], this.inProportion.bind( this ) );
], this.inProportion.bind( this ), {
tandem: tandem.createTandem( 'inProportionProperty' ),
phetioType: DerivedProperty.DerivedPropertyIO( BooleanIO )
} );

// This must be done here, because of the reentrant nature of how fitness changes when the ratio is locked
this.targetRatioProperty.link( () => {
Expand Down
4 changes: 4 additions & 0 deletions js/common/model/RAPRatio.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import NumberProperty from '../../../../axon/js/NumberProperty.js';
import Property from '../../../../axon/js/Property.js';
import Range from '../../../../dot/js/Range.js';
import Utils from '../../../../dot/js/Utils.js';
import BooleanIO from '../../../../tandem/js/types/BooleanIO.js';
import ratioAndProportion from '../../ratioAndProportion.js';
import rapConstants from '../rapConstants.js';
import RAPRatioTuple from './RAPRatioTuple.js';
Expand Down Expand Up @@ -85,6 +86,9 @@ class RAPRatio {

// Ignore the speed component when the ratio is locked
return bothMoving && movingInSameDirection && ( movingFastEnough || ratioLocked );
}, {
tandem: tandem.createTandem( 'movingInDirectionProperty' ),
phetioType: DerivedProperty.DerivedPropertyIO( BooleanIO )
} );

// @private - To avoid an infinite loop as setting the tupleProperty from inside its lock-ratio-support
Expand Down

0 comments on commit 01e4010

Please sign in to comment.