Exemple #1
0
        /// <summary>
        /// Set the atom to the most common form of an element
        /// </summary>
        /// <param name="protonCount">atomic number of the element to set</param>
        public void ForceToCommon(int protonCount)
        {
            //temporarily remove ingteractivity to force particles
            bool wasInteractable = interactable;

            interactable = false;

            //add or remove neutrons to match atomic number
            int protonDiff = protonCount - Nucleus.ProtonCount;

            workbench.NewAutoProton(protonDiff);
            Nucleus.TrimProtons(-protonDiff);

            //get the most common stable form of the element
            Element element = Elements.GetElement(protonCount);

            if (element != null)
            {
                //set the min and max isotope mass
                Nucleus.MassMax = element.MaxIsotope;
                Nucleus.MassMin = element.MinIsotope;

                Isotope common = element.Common;
                if (common != null)
                {
                    //add or remove neutrons to match mass
                    int neutronDiff = (common.Mass - protonCount) - Nucleus.NeutronCount;
                    workbench.NewAutoNeutron(neutronDiff);
                    Nucleus.TrimNeutrons(-neutronDiff);
                }
            }

            //add or remove shells to match element period
            while (shells.Count < Elements.GetShells(protonCount))
            {
                AddShell();
            }

            while (shells.Count > Elements.GetShells(protonCount))
            {
                RemoveShell();
            }

            //add or remove electrons to match charge
            int electronDiff = protonCount - ElectronCount;

            workbench.NewAutoElectron(electronDiff);
            OuterShell.TrimElectrons(-electronDiff);

            interactable = wasInteractable; //revert interactable state

            AdjustScale();
        }
Exemple #2
0
        /// <summary>
        /// Remove and Destroy the Outer shell
        /// </summary>
        private void RemoveShell()
        {
            //remove any particles in the outer shell
            Particle[] pA = OuterShell.Particles;
            foreach (Particle particle in pA)
            {
                OuterShell.RemoveParticle(particle);
                AddExcessParticle(particle);
            }

            //destroy the shell object
            Destroy(shells.Pop().gameObject);
            SFX_Shell?.Invoke();

            if (shells.Count == 0)
            {
                return; //don't need to calculate radius of nothing
            }
        }
Exemple #3
0
 /// <summary>
 /// try to Remove a specified electron from the atom
 /// </summary>
 /// <param name="particle">particle to remove</param>
 /// <returns>removal scucess</returns>
 public bool RemoveElectron(Particle particle)
 {
     //start the recursive call to remove from outer shell
     return(OuterShell.RemoveParticle(particle));
 }