Skip to content

Commit

Permalink
remove getParticleAtom, fixes #153
Browse files Browse the repository at this point in the history
  • Loading branch information
zepumph committed Aug 21, 2023
1 parent 2ba6101 commit aa017f0
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 26 deletions.
7 changes: 0 additions & 7 deletions js/chart-intro/model/ChartIntroModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,13 +140,6 @@ class ChartIntroModel extends BANModel<ParticleNucleus> {
// count it in a shell position).
this.particleAtom.removeParticleFromShell && this.particleAtom.removeParticleFromShell( particle );
}

/**
* Return the model of the cluster of mini-particles.
*/
public override getParticleAtom(): ParticleAtom {
return this.miniParticleAtom;
}
}

buildANucleus.register( 'ChartIntroModel', ChartIntroModel );
Expand Down
4 changes: 2 additions & 2 deletions js/chart-intro/view/ChartIntroScreenView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ class ChartIntroScreenView extends BANScreenView<ChartIntroModel> {
this.isMiniAtomConnected = false;

// animate mini particle atom
const alphaParticle = super.emitAlphaParticle();
const alphaParticle = super.emitAlphaParticle( this.model.miniParticleAtom );
this.model.miniParticleAtom.reconfigureNucleus();

// animate nucleons in NucleonShellView
Expand All @@ -368,7 +368,7 @@ class ChartIntroScreenView extends BANScreenView<ChartIntroModel> {

// animate mini particleAtom
const nucleonTypeToChange = betaDecayType === DecayType.BETA_MINUS_DECAY ? ParticleType.NEUTRON : ParticleType.PROTON;
const particleToEmit = super.betaDecay( betaDecayType );
const particleToEmit = super.betaDecay( betaDecayType, this.model.miniParticleAtom );
this.createMiniParticleView( particleToEmit );

// animate the shell view
Expand Down
13 changes: 2 additions & 11 deletions js/common/model/BANModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -240,17 +240,8 @@ class BANModel<T extends ParticleAtom> {
particle.animationEndedEmitter.removeAllListeners();
}

/**
* Return the model of the cluster of nucleons, which is the main model in the Decay Screen and the mini nucleus in
* the Chart Screen.
*/
public getParticleAtom(): ParticleAtom {
return this.particleAtom;
}


// 2D array that defines the table structure.
// The rows are the proton number, for example the first row is protonNumber = 0. The numbers in the rows are the neutron number.
// 2D array that defines the table structure.
// The rows are the proton number, for example the first row is protonNumber = 0. The numbers in the rows are the neutron number.
public static readonly POPULATED_CELLS = [
[ 1, 4, 6 ],
[ 0, 1, 2, 3, 4, 5, 6 ],
Expand Down
9 changes: 3 additions & 6 deletions js/common/view/BANScreenView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -583,8 +583,6 @@ abstract class BANScreenView<M extends BANModel<ParticleAtom | ParticleNucleus>>
this.model.removeParticle( particle );
}
else {
// Remove particles flying away from the mini-nucleus. Dispose emitter deals with the view portion.
assert && assert( !this.model.getParticleAtom().containsParticle( particle ), 'Particle is a decaying particle so it should not be a part of the miniParticleAtom.' );
particle.dispose();
}
}
Expand Down Expand Up @@ -759,8 +757,7 @@ abstract class BANScreenView<M extends BANModel<ParticleAtom | ParticleNucleus>>
* Creates an alpha particle by removing the needed nucleons from the nucleus, arranging them, and then animates the
* particle out of view.
*/
protected emitAlphaParticle(): AlphaParticle {
const particleAtom = this.model.getParticleAtom();
protected emitAlphaParticle( particleAtom: ParticleAtom = this.model.particleAtom ): AlphaParticle {
assert && assert( this.model.particleAtom.protonCountProperty.value >= AlphaParticle.NUMBER_OF_ALLOWED_PROTONS &&
this.model.particleAtom.neutronCountProperty.value >= AlphaParticle.NUMBER_OF_ALLOWED_NEUTRONS,
'The particleAtom needs 2 protons and 2 neutrons to emit an alpha particle.' );
Expand Down Expand Up @@ -796,8 +793,8 @@ abstract class BANScreenView<M extends BANModel<ParticleAtom | ParticleNucleus>>
/**
* Changes the nucleon type of a particle in the atom and emits an electron or positron from behind that particle.
*/
protected betaDecay( betaDecayType: DecayType ): Particle {
const particleAtom = this.model.getParticleAtom();
protected betaDecay( betaDecayType: DecayType, particleAtom: ParticleAtom = this.model.particleAtom ): Particle {
console.log( particleAtom );
let particleArray;
let particleToEmit: Particle;
if ( betaDecayType === DecayType.BETA_MINUS_DECAY ) {
Expand Down

0 comments on commit aa017f0

Please sign in to comment.