public Group(Map theMap, int turnPriority, bool destroySelfWhenEmpty) { TheMap = theMap; TurnPriority = new Stat <int, Group>(this, turnPriority); UnitsByID = new UlongSet(); AlliesByID = new UlongSet(); EnemiesByID = new UlongSet(); //When another Group becomes an ally, remove them from the enemies list // and vice-versa. AlliesByID.OnElementAdded += (allies, element) => { EnemiesByID.Remove(element); }; EnemiesByID.OnElementAdded += (enemies, element) => { AlliesByID.Remove(element); }; if (destroySelfWhenEmpty) { //When the last unit in this group is removed, destroy the group. UnitsByID.OnElementRemoved += (units, element) => { if (units.Count == 0) { TheMap.Groups.Remove(this); } }; } }
private void Callback_SleeperKilled(Unit sleeper, Map theMap) { SleepingUnitsByID.Remove(sleeper.ID); }