//! 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); } }