예제 #1
0
        public virtual bool RemoveFromFormation(FormationType sourceFormationType, ISimpleStub unitsToRemove)
        {
            if (!HasFormation(sourceFormationType))
            {
                return(false);
            }

            // Make sure there are enough units
            var sourceFormation  = Data[sourceFormationType];
            var allUnitsToRemove = unitsToRemove.ToUnitList();

            foreach (var unit in allUnitsToRemove)
            {
                ushort count;
                if (!sourceFormation.TryGetValue(unit.Type, out count) || count < unit.Count)
                {
                    return(false);
                }
            }

            foreach (var unit in unitsToRemove.SelectMany(formation => formation))
            {
                Data[sourceFormationType].Remove(unit.Key, unit.Value);
            }

            return(true);
        }
예제 #2
0
        public void AddAllToFormation(FormationType formation, ISimpleStub unitsToAdd)
        {
            lock (objLock)
            {
                CheckUpdateMode();

                foreach (var unit in unitsToAdd.ToUnitList())
                {
                    AddUnit(formation, unit.Type, unit.Count);
                }
            }
        }