/// <summary> /// Finds all as spawn tagged objects and fills the molecule queue of the attached collector with molecules /// for the start. /// </summary> void Start() { collector = GetComponent <CoolingCollectorScript>(); moleculeManager = GameObject.Find("CoolingGameManager").GetComponent <CoolingMoleculeManager>(); // Find all as spawn tagged objects spawnPositions = ExtensionMethods.FindComponentsInChildrenWithTag <Component>(gameObject, "Cooling.Spawn"); if (collector && prefabObject && waypoints.Length > 0) { for (int i = 0; i < 10; i++) { CWater clone = Instantiate(prefabObject); // Wapoint doesnt matter, gets overwritten later, and index 0 is always available clone.waypoint = waypoints[0]; moleculeManager.AddMoleculeToList(clone); clone.gameObject.SetActive(false); collector.moleculeQueue.Enqueue(clone); } } if (spawnPositions.Length > 1) { singlespawn = false; } }
/// <summary> /// Adds a new molecule (CWater instance) to the attached collector molecule queue /// </summary> public void AddMoleculeToQueue() { CWater clone = Instantiate(prefabObject); clone.waypoint = waypoints[0]; moleculeManager.AddMoleculeToList(clone); clone.gameObject.SetActive(false); collector.moleculeQueue.Enqueue(clone); }