Skip to content

Commit

Permalink
Add check for creator node visibility when emitting an alpha particle…
Browse files Browse the repository at this point in the history
…. See #51.
  • Loading branch information
Luisav1 committed Sep 15, 2022
1 parent ec6b64f commit cc70d20
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
8 changes: 2 additions & 6 deletions js/common/view/BANScreenView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -588,16 +588,12 @@ abstract class BANScreenView<M extends BANModel> extends ScreenView {
}
}

protected removeParticleFromModel( particle: Particle ): void {
this.model.outgoingParticles.includes( particle ) && this.model.outgoingParticles.remove( particle );
this.model.removeParticle( particle );
}

/**
* Remove the given particle from the model and check the particle type's creator node visibility.
*/
protected removeParticleAndSetCreatorNodeVisibility( particle: Particle ): void {
this.removeParticleFromModel( particle );
this.model.outgoingParticles.includes( particle ) && this.model.outgoingParticles.remove( particle );
this.model.removeParticle( particle );

// make the creator node visible when removing the last nucleon from the particle atom
this.setCreatorNodeVisibility( particle.type === ParticleType.PROTON.name.toLowerCase() ?
Expand Down
8 changes: 4 additions & 4 deletions js/decay/view/DecayScreenView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -415,11 +415,11 @@ class DecayScreenView extends BANScreenView<DecayModel> {
this.model.particleAnimations.push( alphaParticleEmissionAnimation );

alphaParticleEmissionAnimation.finishEmitter.addListener( () => {
alphaParticle.protons.forEach( proton => {
this.removeParticleFromModel( proton );
} );
alphaParticle.neutrons.forEach( neutron => {
this.removeParticleFromModel( neutron );
this.removeParticleAndSetCreatorNodeVisibility( neutron );
} );
alphaParticle.protons.forEach( proton => {
this.removeParticleAndSetCreatorNodeVisibility( proton );
} );
alphaParticleNode.dispose();
alphaParticle.dispose();
Expand Down

0 comments on commit cc70d20

Please sign in to comment.