public RadiationSmoke(GameContent gameContent, Atom atom)
        {
            this.gameContent = gameContent;
            this.atom = atom;

            for (int i = 0; i < MaxParticle; i++)
                particlePos[i] = MaxParticlePos / (MaxParticle - 1) * i;
        }
        public Bond(Atom atom, Atom other, Joint shortJoint, Joint midJoint, 
            int numberOfBonds, GameContent gameContent)
        {
            this.numberOfBonds = numberOfBonds;
            this.atom = atom;
            this.other = other;
            this.shortJoint = shortJoint;
            this.midJoint = midJoint;
            this.gameContent = gameContent;

            Vector2 localAnchor;
            if (atom.body == shortJoint.GetBodyA())
            {
                localAnchor = atom.body.GetLocalPoint(shortJoint.GetAnchorA());
                midJoint.SetUserData(this);
            }
            else
                localAnchor = atom.body.GetLocalPoint(shortJoint.GetAnchorB());

            float angle = (float)Math.Atan2(localAnchor.Y, localAnchor.X);
            if (angle < 0) angle = 2 * (float)Math.PI + angle;

            jointAngle = finalJointAngle = angle;
        }
        void GetNearestBody()
        {
            nearestAtom = null; numberOfBonds = 0;

            if (eye >= EyeState.Sleep) return;

            float nearestDist = (bondLength * 1.2f) / gameContent.b2Scale;

            for (Body b = world.GetBodyList(); b != null; b = b.GetNext())
            {
                object userData = b.GetUserData();
                if (userData is Atom && b != body && !bondedAtoms.Contains((Atom)userData)
                    && ((Atom)userData).bondsLeft > 0 && bondsLeft > 0)
                {
                    float d = Vector2.Distance(body.Position, b.Position);
                    if (d < nearestDist)
                    {
                        nearestAtom = (Atom)userData;
                        nearestDist = d;

                        numberOfBonds = Math.Min(bondsLeft, nearestAtom.bondsLeft);
                        numberOfBonds = Math.Min(3, numberOfBonds);
                    }
                }
            }
        }
        void HandleAtom(InputState input)
        {
            Atom mouseOverAtom = null;
            foreach (Atom a in atoms)
            {
                if (mouseAtom == null && !isMenuEntrySelected && a.eye < EyeState.Disappear
                    && a.fixture.TestPoint(mousePos))
                    mouseOverAtom = a;
            }

            // click to add atoms
            if (mouseOverAtom == null && input.IsLeftClicked() && isLAB && !editMode && !isMenuEntrySelected)
                atoms.Add(new Atom((Symbol)(gameContent.random.Next(gameContent.symbolCount - 1) + 1),
                        mousePos * gameContent.scale, gameContent, world));

            if (input.IsLeftClicked())
            {
                if (mouseOverAtom != null)
                {
                    MouseJointDef mjd = new MouseJointDef();
                    mjd.maxForce = 500;
                    //mjd.frequencyHz = 10;
                    //mjd.dampingRatio = .1f;
                    mjd.target = mouseOverAtom.body.Position;
                    mjd.bodyA = mouseGroundBody;
                    mjd.bodyB = mouseOverAtom.body;

                    mouseJoint = (MouseJoint)world.CreateJoint(mjd);
                    mouseAtom = mouseOverAtom;
                    mouseAtom.SetMode(editMode, true);
                }
            }
            else if (mouseJoint != null && mouseAtom != null && (mouseAtom.eye == EyeState.Disappear
                || input.CurrentMouseState[0].LeftButton == ButtonState.Released))
            {
                if (mouseAtom.eye != EyeState.Disappear) // Disappear has priority over LeftButton Released
                {
                    world.DestroyJoint(mouseJoint);
                    mouseAtom.SetMode(editMode, false);
                    mouseAtom.CreateBond();
                }

                mouseJoint = null; mouseAtom = null;
            }

            if (input.IsRightClicked())
            {
                if (mouseOverAtom != null)
                {
                    if (mouseOverAtom.bondedAtoms.Count > 0)
                    {
                        Cue cue = gameContent.soundBank.GetCue("detach"); cue.Play();
                        mouseOverAtom.DestroyBonds();
                    }
                    else if (isLAB && !editMode && mouseOverAtom.bondedAtoms.Count == 0)
                    {
                        mouseOverAtom.Remove(); atoms.Remove(mouseOverAtom);
                    }
                }
            }
        }