public void Remove(RtsObject o) { objects.Remove(o); if (typeCounts.ContainsKey(o.GetType())) { int count; typeCounts.TryGetValue(o.GetType(), out count); count--; if (count == 0) { typeCounts.Remove(o.GetType()); } } if (mostPopulousType == o.GetType()) { largestCount = 0; foreach (KeyValuePair <Type, int> pair in typeCounts) { if (pair.Value > largestCount) { mostPopulousType = pair.Key; largestCount = pair.Value; } } } if (objects.Count == 0) { mostPopulousType = null; activeType = null; largestCount = 0; } }
public void Add(RtsObject o) { objects.Add(o); if (objects.Count == 1) { activeType = o.GetType(); } int count; if (!typeCounts.ContainsKey(o.GetType())) { typeCounts.Add(o.GetType(), 1); count = 1; } else { typeCounts[o.GetType()]++; typeCounts.TryGetValue(o.GetType(), out count); } if (count > largestCount) { mostPopulousType = o.GetType(); largestCount = count; } }
public void Remove(RtsObject o) { objects.Remove(o); if (typeCounts.ContainsKey(o.GetType())) { int count; typeCounts.TryGetValue(o.GetType(), out count); count--; if (count == 0) typeCounts.Remove(o.GetType()); } if (mostPopulousType == o.GetType()) { largestCount = 0; foreach (KeyValuePair<Type, int> pair in typeCounts) { if (pair.Value > largestCount) { mostPopulousType = pair.Key; largestCount = pair.Value; } } } if (objects.Count == 0) { mostPopulousType = null; activeType = null; largestCount = 0; } }
public void Add(RtsObject o) { objects.Add(o); if (objects.Count == 1) activeType = o.GetType(); int count; if (!typeCounts.ContainsKey(o.GetType())) { typeCounts.Add(o.GetType(), 1); count = 1; } else { typeCounts[o.GetType()]++; typeCounts.TryGetValue(o.GetType(), out count); } if (count > largestCount) { mostPopulousType = o.GetType(); largestCount = count; } }