Skip to content

Commit

Permalink
Change DynamicProperty declarations to less restrictive types, see #222
Browse files Browse the repository at this point in the history
  • Loading branch information
samreid committed Mar 6, 2024
1 parent d63a3f0 commit 54621ee
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 12 deletions.
26 changes: 17 additions & 9 deletions js/common-vsm/model/VSMModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ import stopwatchTick_mp3 from '../../../sounds/stopwatchTick_mp3.js';
import soundManager from '../../../../tambo/js/soundManager.js';
import PDLQueryParameters from '../../common/PDLQueryParameters.js';
import PDLPreferences from '../../common/PDLPreferences.js';
import TReadOnlyProperty from '../../../../axon/js/TReadOnlyProperty.js';
import PhetioProperty from '../../../../axon/js/PhetioProperty.js';

const tickSound = new SoundClip( stopwatchTick_mp3, { initialOutputLevel: 1 } );
soundManager.addSoundGenerator( tickSound );
Expand All @@ -56,19 +58,25 @@ export default class VSMModel<T extends VSMField> extends PDLModel<T> {
public readonly measuringTapeBasePositionProperty;
public readonly measuringTapeTipPositionProperty;

public readonly latestLaunchAngleProperty: DynamicProperty<number, number, T>;
public readonly latestLaunchSpeedProperty: DynamicProperty<number, number, T>;
////////////////////////////////////////////////////////////////////////////////////////
// These DynamicProperties select based on the selected VSMField

public readonly latestLaunchAngleProperty: TReadOnlyProperty<number>;
public readonly latestLaunchSpeedProperty: TReadOnlyProperty<number>;

// The angleStabilizerProperty represents the amount of angle stabilization applied to the launcher. The value is between 0 and 1, where 0 means minimum stabilization and 1 means maximum stabilization.
public readonly angleStabilizerProperty: DynamicProperty<number, number, T>;
public readonly standardDeviationAngleProperty: DynamicProperty<number, number, T>;
public readonly angleStabilizerProperty: PhetioProperty<number>;
public readonly standardDeviationAngleProperty: TReadOnlyProperty<number>;

public readonly selectedProjectileNumberProperty: PhetioProperty<number>;
public readonly selectedProjectileProperty: TReadOnlyProperty<Projectile | null>;
public readonly numberOfLandedProjectilesProperty: TReadOnlyProperty<number>;
public readonly totalProjectileCountProperty: TReadOnlyProperty<number>;

public readonly selectedProjectileNumberProperty: DynamicProperty<number, number, T>;
public readonly selectedProjectileProperty: DynamicProperty<Projectile | null, Projectile | null, T>;
public readonly numberOfLandedProjectilesProperty: DynamicProperty<number, number, T>;
public readonly totalProjectileCountProperty: DynamicProperty<number, number, T>;
public readonly launcherProperty: PhetioProperty<Launcher>;

public readonly launcherProperty: DynamicProperty<Launcher, Launcher, T>;
// End of DynamicProperties
////////////////////////////////////////////////////////////////////////////////////////

//REVIEW constructor should be protected
public constructor( fields: T[], providedOptions: VSMModelOptions<T> ) {
Expand Down
4 changes: 2 additions & 2 deletions js/common-vsm/view/CustomLauncherNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ export default class CustomLauncherNode extends LauncherNode {
mysteryOrCustomProperty: TProperty<MysteryOrCustom>,
mysteryLauncherProperty: TProperty<Launcher>,
launcherMechanismProperty: TProperty<LauncherMechanism>,
standardDeviationAngleProperty: TProperty<number>,
latestLaunchSpeedProperty: TProperty<number>,
standardDeviationAngleProperty: TReadOnlyProperty<number>,
latestLaunchSpeedProperty: TReadOnlyProperty<number>,
fieldProperty: TReadOnlyProperty<Field> | null,
providedOptions?: CustomLauncherNodeOptions ) {

Expand Down
2 changes: 1 addition & 1 deletion js/common/view/LauncherNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export default class LauncherNode extends Node {
public constructor( private readonly modelViewTransform: ModelViewTransform2,
private readonly meanLaunchAngleProperty: TProperty<number>,
launcherHeightProperty: TProperty<number>,
mysteryLauncher: TProperty<Launcher>,
mysteryLauncher: TReadOnlyProperty<Launcher>,
fieldProperty: TReadOnlyProperty<Field> | null,
providedOptions?: LauncherNodeOptions ) {

Expand Down

0 comments on commit 54621ee

Please sign in to comment.