private void StartNextTask() { _currentTask = _tasks.Dequeue(); _movable.SetDestination(_currentTask.target.transform.position); _inRange = false; Debug.Log("StartNextTask " + _currentTask.target); }
private void PerformWork() { if (_currentTask == null) { return; } if (_currentTask.target == null) { _movable.Stop(); _animator.SetBool(Working, false); _currentTask = null; Debug.Log("PerformWork Target is null"); return; } switch (_currentTask.taskType) { case WorkerUnitTask.TaskType.Construct: PerformBuild(); break; case WorkerUnitTask.TaskType.Repair: PerformRepair(); break; default: throw new ArgumentOutOfRangeException(); } }
private static void DestroyTask(WorkerUnitTask t) { if (t.target.State == BuildingInfo.BuildingState.Ghost) { Destroy(t.target.gameObject); } }
public void ClearTasks() { Debug.Log("Clear tasks"); foreach (var t in _tasks) { DestroyTask(t); } _tasks.Clear(); if (_currentTask != null) { DestroyTask(_currentTask); } _currentTask = null; }
void Update() { if (_currentTask != null && _currentTask.IsComplete()) { Debug.Log("Task done"); _animator.SetBool(Working, false); _currentTask = null; } if (_currentTask == null && _tasks.Any()) { Debug.Log("Start new task"); StartNextTask(); } PerformWork(); }
public void ReplaceQueueWithTask(WorkerUnitTask task) { ClearTasks(); AddTask(task); }
public void AddTask(WorkerUnitTask task) { _tasks.Enqueue(task); Debug.Log($"Task added {GetInstanceID()} {task} {_tasks.Count}"); }