protected override bool CreateSingleSubTask(SubTaskType _subTaskType) { int scheduledExchangeAmount = 0; S_Storage_Base targetStorage; if (tasks.Count == 0) { Debug.LogError("S_AI_Worker:CreateSingleSubTask() - Tasks queue is empty"); return(false); } if (currentTask.taskType == TaskType.FILL_SHELF) { switch (_subTaskType) { case SubTaskType.TAKE_PRODUCT: targetStorage = S_Storage_Manager.Instance.GetMostStockedStockBoxByType(currentTask.targetProductType); scheduledExchangeAmount = targetStorage.ScheduleRemoveStock(inventorySize); if (scheduledExchangeAmount == 0) { Debug.Log("S_AI_Worker:CreateSingleSubTask() - Could not create subtask of type=TAKE_PRODUCT. Reason=Target storage out of stock"); return(false); } else { S_AI_SubTask newSubTask = new S_AI_SubTask(_subTaskType, targetStorage); newSubTask.scheduledExchangeAmount = scheduledExchangeAmount; currentTask.subTasks.Enqueue(newSubTask); return(true); } case SubTaskType.GIVE_PRODUCT: targetStorage = S_Storage_Manager.Instance.GetLeastStockedShelfByType(currentTask.targetProductType); scheduledExchangeAmount = targetStorage.ScheduleAddStock(currentTask.subTasks.Peek().scheduledExchangeAmount); if (scheduledExchangeAmount == 0) { Debug.Log("S_AI_Worker:CreateSingleSubTask() - Could not create subtask of type=GIVE_PRODUCT. Reason=Target storage full"); return(false); } else { S_AI_SubTask newSubTask = new S_AI_SubTask(_subTaskType, targetStorage); newSubTask.scheduledExchangeAmount = scheduledExchangeAmount; currentTask.subTasks.Enqueue(newSubTask); return(true); } } } return(false); }
protected virtual bool CreateSingleSubTask(SubTaskType _subTaskType) { Debug.LogError("S_AI_Base:CreateSingleSubTask() - Abstract function must be overridden"); return(false); }
// Constructors public S_AI_SubTask(SubTaskType newSubTaskType, S_Storage_Base newTargetStorage) { subTaskType = newSubTaskType; targetStorage = newTargetStorage; }