public bool AttributeDwellingToDwarf(WorkingSlotIndexComponent workingSlotIndexComponent) { foreach (DwarfsSlots workingsSlot in workingsSlots) { if (workingsSlot.attributedDwarfsNumber >= workingsSlot.maxNumberSlots) { continue; } workingsSlot.attributedDwarfsNumber++; workingSlotIndexComponent.dwarfsSlots = workingsSlot; for (int j = 0; j < workingsSlot.maxNumberSlots; j++) { if (workingsSlot.attributedDwellingsSlotIndexComponent[j] != null) { continue; } workingsSlot.attributedWorkingsSlotIndexComponent[j] = workingSlotIndexComponent; break; } return(true); } return(false); }
void SendDwarfsToWork() { for (int index = 0; index < pathComponents.Length; index++) { PathComponent pathComponent = pathComponents[index]; WorkingSlotIndexComponent workingSlotIndexComponent = workingSlotIndexComponents[index]; Transform transformComponent = dwarfsTransformComponents[index]; InventoryComponent inventoryComponent = inventoryComponents[index]; if (workingSlotIndexComponent.dwarfsSlots == null) { continue; } if (pathComponent.index != 0 && pathComponent.dwarfsSlots[pathComponent.index - 1] != null) { pathComponent.dwarfsSlots[pathComponent.index - 1].dwarfsAlreadyIn--; pathComponent.dwarfsSlots[pathComponent.index - 1].dwarfsInside .Remove(inventoryComponent); } pathComponent.nodes = aStarSystem.GetPath(transformComponent, workingSlotIndexComponent.dwarfsSlots.transform); pathComponent.index = 0; pathComponent.dwarfsSlots = new DwarfsSlots[pathComponent.nodes.Length]; pathComponent.dwarfsSlots[pathComponent.nodes.Length - 1] = workingSlotIndexComponent.dwarfsSlots; } }
private void IncreaseWorkingSlotIndexComponentsSizeAndAttribute(WorkingSlotIndexComponent workingSlotIndexComponent) { WorkingSlotIndexComponent[] tmpWorkingSlotIndexComponents = new WorkingSlotIndexComponent[workingSlotIndexComponents.Length + 1]; for (int i = 0; i < workingSlotIndexComponents.Length; i++) { tmpWorkingSlotIndexComponents[i] = workingSlotIndexComponents[i]; } tmpWorkingSlotIndexComponents[tmpWorkingSlotIndexComponents.Length - 1] = workingSlotIndexComponent; workingSlotIndexComponents = tmpWorkingSlotIndexComponents; }
public bool newDwarf(WorkingSlotIndexComponent workingSlotIndexComponent) { IncreaseWorkingSlotIndexComponentsSizeAndAttribute(workingSlotIndexComponent); return(AttributeDwellingToDwarf(workingSlotIndexComponent)); }