Esempio n. 1
0
        public void Add(ISoilPart part, int proportion)
        {
            if (proportion < 0)
            {
                throw new ArgumentOutOfRangeException("proportion", proportion, "Can not add negative proportion of soil part.");
            }
            if (proportion == 0)
            {
                return;
            }

            if (dict.ContainsKey(part))
            {
                dict[part] += proportion;
            }
            else
            {
                dict.Add(part, proportion);
            }

            if (!inEditing)
            {
                ReduceProportions();
            }
        }
Esempio n. 2
0
        public void Remove(ISoilPart part, int proportion)
        {
            if (proportion < 0)
            {
                throw new ArgumentOutOfRangeException("proportion", proportion, "Can not remove negative proportion of soil part.");
            }
            if (proportion == 0)
            {
                return;
            }

            if (dict.ContainsKey(part))
            {
                dict[part] -= proportion;
                if (dict[part] <= 0)
                {
                    dict.Remove(part);
                }
            }

            if (!inEditing)
            {
                ReduceProportions();
            }
        }
Esempio n. 3
0
        public void Set(ISoilPart part, int proportion)
        {
            if (proportion < 0)
            {
                throw new ArgumentOutOfRangeException("proportion", proportion, "Can not set negative proportion of soil part.");
            }
            if (proportion == 0)
            {
                dict.Remove(part);
            }
            else
            {
                dict[part] = proportion;
            }

            if (!inEditing)
            {
                ReduceProportions();
            }
        }
Esempio n. 4
0
 public int PartsOf(ISoilPart part)
 {
     return(dict.GetValueOrDefault(part));
 }
Esempio n. 5
0
 public int this[ISoilPart part] {
     get { return(PartsOf(part)); }
 }