public virtual cActor Spawn(cActor SPAWNED) { if (SPAWNED == null) { return(null); } cActor INSTANCE = Instantiate(SPAWNED); SPAWNED.transform.position = transform.position; return(INSTANCE); }
// The Spawner passes a spawn command to actors listed as one of its spawnpoints. // Spawnpoint availability for use is determined by checking if its spawn set availability ticker is down. // From the available spawnpoint sets, the Spawner chooses a random set, and random spawnpoint within the set... // And PASSES a spawn command to that spawnpoint. // Afterwards, the spawn set's availability ticker is set and that set cannot be used until it is down. public virtual cActor Generate(cActor SPAWNED) { if (SPAWNED == null) { return(null); } // Check for available columns. Note that a default list has a count of 1 with null or 0 entry. bool bCOLUMN_AVAILABLE = false; List <int> AVAILABLE_COLUMNS = new List <int>(); for (int i = 0; i < spawnpointSets.Count; i++) { if (spawnSetNextAvailableTick[i] <= 0) { AVAILABLE_COLUMNS.Add(i); bCOLUMN_AVAILABLE = true; } } if (!bCOLUMN_AVAILABLE) { return(null); } // Select a spawnpoint from any of the available columns int SELECTED_COLUMN = AVAILABLE_COLUMNS[UnityEngine.Random.Range(0, AVAILABLE_COLUMNS.Count)]; int SELECTED_WINDOW = UnityEngine.Random.Range(0, spawnpointSets[SELECTED_COLUMN].spawnpoints.Count); cActor CHOSEN_SPAWNPOINT = spawnpointSets[SELECTED_COLUMN].spawnpoints[SELECTED_WINDOW]; if (CHOSEN_SPAWNPOINT == null) { return(null); } // Tell the spawnpoint ot spawn instance of the given actor // Set the column ticker to mark it as unavailable until ticked down cActor INSTANCE = CHOSEN_SPAWNPOINT.Spawn(SPAWNED); spawnSetNextAvailableTick[SELECTED_COLUMN] = spawnSetNextAvailableTimer; return(INSTANCE); }