/// <summary> /// Enqueues a spawned object for the dog to focus on. /// </summary> /// <param name="objectToAdd"> /// The object for focus (i.e. waste or obstacle). /// </param> public void AddObjectToFocusQueue(GameObject objectToAdd) { FocusQueue.Enqueue(objectToAdd); if (!isProcessingObject) { processObjectSignal?.Invoke(); isProcessingObject = true; } }
/// <summary> /// Dequeues the next object in the dog's focus queue, then determines /// whether the dog should avoid or seek the object based on type. /// </summary> private void ProcessObject() { isProcessingObject = true; // Break out of process object loop if the focus queue is empty. if (FocusQueue.Count == 0) { isProcessingObject = false; return; } CurrentObject = FocusQueue.Dequeue(); currentObjectCollider = CurrentObject.GetComponent <BoxCollider>(); if (CurrentObject.transform.CompareTag("Obstacle") || CurrentObject.transform.CompareTag("Pole")) { StartCoroutine(AvoidObstacleRoutine()); } else if (CurrentObject.transform.CompareTag("Waste")) { StartCoroutine(SeekWasteRoutine()); } }