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; } }
/// <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); }