Ejemplo n.º 1
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="u"></param>
        public void RemoveUnit(Unit u)
        {
            lock (units)
            {
                lock (allUnits)
                {
                    this.units[u.GetOwner()].Remove(u);
                    this.allUnits.Remove(u);

                    if (unitsChanged != null)
                    {
                        //I'm sorry for this ugly hax - John
                        List<Unit> temp = new List<Unit>();
                        temp.Add(u);
                        unitsChanged(this, new Event<IEnumerable<Unit>>(temp, EventType.REMOVE));
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public void AddUnit(Unit u)
        {
            lock (units)
            {
                lock (allUnits)
                {
                    HashSet<Unit> nits;
                    if (!this.units.TryGetValue(u.GetOwner(), out nits))
                    {
                        nits = new HashSet<Unit>();
                    }

                    nits.Add(u);

                    this.units[u.GetOwner()] = nits;
                    this.allUnits.Add(u);

                    if (unitsChanged != null)
                    {
                        //I'm sorry for this ugly hax - John
                        List<Unit> temp = new List<Unit>();
                        temp.Add(u);
                        unitsChanged(this, new Event<IEnumerable<Unit>>(temp, EventType.ADD));
                    }
                }
            }
        }