public static Compound operator *(Compound compound, float f) { Compound res = new Compound(compound); List <Elements> keys = new List <Elements>(res.m_quantities.Keys); foreach (Elements key in keys) { res.m_quantities[key] *= f; } res.ProcessTotalQuantity(); res.ProcessColor(); return(res); }
public static Compound operator -(Compound a, Compound b) { Compound res = new Compound(a); List <Elements> keys = new List <Elements>(b.m_quantities.Keys); foreach (Elements key in keys) { if (res.m_quantities.ContainsKey(key)) { res.m_quantities[key] = Mathf.Max(res.m_quantities[key] - b.m_quantities[key], 0); } } res.ProcessTotalQuantity(); res.ProcessColor(); return(res); }
public static Compound operator +(Compound a, Compound b) { Compound res = new Compound(a); List <Elements> keys = new List <Elements>(b.m_quantities.Keys); foreach (Elements key in keys) { if (res.m_quantities.ContainsKey(key)) { res.m_quantities[key] += b.m_quantities[key]; } else { res.m_quantities.Add(key, b.m_quantities[key]); } } res.ProcessTotalQuantity(); res.ProcessColor(); return(res); }