示例#1
0
        private void FreeUpSomeSlot()
        {
            var availableSlots = DistributionLogic.GetSlotsAvailableToCity(ObjectToDisplay)
                                 .Where(slot => slot.IsOccupied)
                                 .ToList();

            availableSlots.Sort(delegate(IWorkerSlot slotOne, IWorkerSlot slotTwo){
                if (slotOne.IsLocked == slotTwo.IsLocked)
                {
                    return(0);
                }
                else
                {
                    return(slotOne.IsLocked ? 1 : -1);
                }
            });

            var slotToUnassign = availableSlots.FirstOrDefault();

            if (slotToUnassign != null)
            {
                slotToUnassign.IsOccupied = false;
                slotToUnassign.IsLocked   = false;
            }
        }
示例#2
0
        /// <inheritdoc/>
        public void PerformDistribution()
        {
            if (!isActiveAndEnabled)
            {
                return;
            }

            var allSlots = DistributionLogic.GetSlotsAvailableToCity(this);
            var occupiedAndLockedSlots = allSlots.Where(slot => slot.IsOccupied && slot.IsLocked);

            int populationToAssign = Population - occupiedAndLockedSlots.Count();

            populationToAssign = Math.Max(0, populationToAssign);

            var slotsToAssign = allSlots.Where(slot => !slot.IsLocked);

            DistributionLogic.DistributeWorkersIntoSlots(populationToAssign, slotsToAssign, this, YieldFocus);

            Signals.DistributionPerformed.OnNext(this);
        }