From aa017f0e4c811d7c833cad85eb58a368e090c494 Mon Sep 17 00:00:00 2001 From: Michael Kauzmann Date: Mon, 21 Aug 2023 15:58:11 -0600 Subject: [PATCH] remove getParticleAtom, fixes https://github.com/phetsims/build-a-nucleus/issues/153 --- js/chart-intro/model/ChartIntroModel.ts | 7 ------- js/chart-intro/view/ChartIntroScreenView.ts | 4 ++-- js/common/model/BANModel.ts | 13 ++----------- js/common/view/BANScreenView.ts | 9 +++------ 4 files changed, 7 insertions(+), 26 deletions(-) diff --git a/js/chart-intro/model/ChartIntroModel.ts b/js/chart-intro/model/ChartIntroModel.ts index 5803986..a645c4f 100644 --- a/js/chart-intro/model/ChartIntroModel.ts +++ b/js/chart-intro/model/ChartIntroModel.ts @@ -140,13 +140,6 @@ class ChartIntroModel extends BANModel { // 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 ); diff --git a/js/chart-intro/view/ChartIntroScreenView.ts b/js/chart-intro/view/ChartIntroScreenView.ts index f9237f7..da56b68 100644 --- a/js/chart-intro/view/ChartIntroScreenView.ts +++ b/js/chart-intro/view/ChartIntroScreenView.ts @@ -348,7 +348,7 @@ class ChartIntroScreenView extends BANScreenView { 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 @@ -368,7 +368,7 @@ class ChartIntroScreenView extends BANScreenView { // 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 diff --git a/js/common/model/BANModel.ts b/js/common/model/BANModel.ts index e451869..5cf01dd 100644 --- a/js/common/model/BANModel.ts +++ b/js/common/model/BANModel.ts @@ -240,17 +240,8 @@ class BANModel { 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 ], diff --git a/js/common/view/BANScreenView.ts b/js/common/view/BANScreenView.ts index fc3da37..8abfdc4 100644 --- a/js/common/view/BANScreenView.ts +++ b/js/common/view/BANScreenView.ts @@ -583,8 +583,6 @@ abstract class BANScreenView> 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(); } } @@ -759,8 +757,7 @@ abstract class BANScreenView> * 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.' ); @@ -796,8 +793,8 @@ abstract class BANScreenView> /** * 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 ) {