//!	Inserts a solid into the glassware
    //	The solid only comes from spatulas
    public void InsertSolid(float volumeFromTool, float solidMass, Compound reagentFromTool)
    {
        //currentVolume += volumeFromTool;
        //totalMass += solidMass;

        content  = (Compound)reagentFromTool.Clone(volumeFromTool);
        hasSolid = true;
        RefreshContents();
    }
    //! Pours a liquid into the glassware
    //	The liquid might come from pipettes or wash bottles (H2O)
    public void PourLiquid(float volumeFromTool, float liquidMass, Compound reagentFromTool)
    {
        Compound liquidCompound = (Compound)reagentFromTool.Clone(volumeFromTool);

        content   = liquidCompound;
        hasLiquid = true;
        hasSolid  = false;

        RefreshContents();
    }
    //! Returns a new instance of the mixture, based on the volume wanted
    //  The portion of each component of the mixture is set based on the ratio of (originalComponentVolume / originalTotalVolume) * volume
    public Mixture Clone(float volume)
    {
        Mixture mix = new Mixture();

        mix.product       = (Compound)product.Clone((this.product.Volume / this.Volume) * volume);
        mix.leftovers [0] = (Compound)this.leftovers [0].Clone((this.leftovers [0].Volume / this.Volume) * volume);
        mix.leftovers [1] = (Compound)this.leftovers [1].Clone((this.leftovers [1].Volume / this.Volume) * volume);

        return(mix);
    }
    /// <summary>
    /// The method is called to load a new phase
    /// </summary>
    /// <param name="glasswareStart">Glassware start.</param>
    private void NewPhase(bool glasswareStart)
    {
        //Check how to start the phase
        actualStep = 0;
        if (glasswareStart)
        {
            GameObject bequer = Instantiate((GameObject.Find("GameController").GetComponent <GameController> ().gameStates [2] as GetGlasswareState).glasswareList [0].gameObject) as GameObject;
            if ((GameObject.Find("GameController").GetComponent <GameController> ().gameStates [1] as WorkBench).TryPutIntoPosition(bequer))
            {
                Compound compound = new Compound();
                compound = CompoundFactory.GetInstance().GetCompound(phaseDefinitions ["compoundFormula"]);

                /*
                 * Changes on properties according to float.Parse(phaseDefinitions["molarity"])
                 */
                compound.PH       = 7.0f;
                compound.Molarity = 1.0f;

                bequer.GetComponent <Glassware> ().IncomingReagent(compound.Clone(float.Parse(phaseDefinitions ["volume"])) as Compound, float.Parse(phaseDefinitions ["volume"]));
                GameObject.Find("InventoryManager").GetComponent <InventoryManager>().AddProductToInventory(bequer.gameObject);
            }
        }
        else
        {
            // Cupboard test

            /*
             * Pote de reagente
             */
        }

        //Add steps to Experiment Menu on Tablet

        /*GameObject.Find ("Tablet").GetComponentInChildren<NotesState> ().LoadNotes ();
         * GameObject.Find ("Experiments Menu").GetComponent<ExperimentMenu> ().RefreshScroll (1); //TODO: RETHINK ABOUT ALL THIS STEP-PHASE CONSISTENCY ON JOURNAL*/
        NewStep();
    }
    //! Treatment of cases for when something is being put into the glassware
    public bool IncomingReagent(Compound incomingCompound, float volumeFromTool)
    {
//		Debug.Log (incomingCompound.Formula + " incoming!");
        if (content != null)           //Case not empty
        {
            if (content is Mixture)    // Case: there's Mixture
            {
                if (incomingCompound.Formula == "H2O")
                {
                    (content as Mixture).Dilute(incomingCompound);
                }
                else
                {
                    //ERROR MESSAGE
                    return(false);
                }
            }
            else                                                // Case: Not Mixture
            {
                if (incomingCompound.Formula == "H2O")          // SubCase: Water is coming
                {
                    if ((content as Compound).Formula == "H2O") // There's water already
                    {
                        AddSameReagent(volumeFromTool, (Compound)incomingCompound.Clone(volumeFromTool));
                    }
                    else                                // There's a reagent
                    {
                        (content as Compound).Dilute((Compound)incomingCompound.Clone(volumeFromTool));
                        hasSolid  = false;
                        hasLiquid = true;
                    }
                }
                else                                                               // SubCase: A reagent is coming
                {
                    if (incomingCompound.Formula == (content as Compound).Formula) // There's the same reagent inside
                    {
                        AddSameReagent(volumeFromTool, (Compound)incomingCompound.Clone(volumeFromTool));
                    }
                    else
                    {
                        if ((content as Compound).Formula == "H2O")                          //There's water
                        {
                            Compound aux = new Compound(incomingCompound);
                            aux.Dilute(content as Compound);
                            content   = aux;
                            hasSolid  = false;
                            hasLiquid = true;
                        }
                        else                           //A mixure has to be created
                        {
                            Debug.Log("r1 = " + (content as Compound).Formula + "   r2 = " + incomingCompound.Formula);
                            Mixture mix = new Mixture(content as Compound, incomingCompound);
                            content = mix;
                        }
                    }
                }
            }
            this.RefreshContents();
            return(true);
        }
        else
        {
            if (!incomingCompound.IsSolid)
            {
                this.PourLiquid(volumeFromTool, volumeFromTool * incomingCompound.Density, incomingCompound);
            }
            else
            {
                this.InsertSolid(volumeFromTool, volumeFromTool * incomingCompound.Density, incomingCompound);
            }
            return(true);
        }
    }