Esempio n. 1
0
        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);
                    }
                };
            }
        }
Esempio n. 2
0
 private void Callback_SleeperKilled(Unit sleeper, Map theMap)
 {
     SleepingUnitsByID.Remove(sleeper.ID);
 }