private void SpawnNewPlanes() { PlaneSO[] planesToSpawn = arrivingPlanes.GetArrivals(turnNumber); if (planesToSpawn == null) { return; } foreach (PlaneSO planeSO in planesToSpawn) { Country country = GetCountryFromName(planeSO.countryName); if (country == null) { continue; // This should never happen } if (country.IsHostile) { continue; } WaitSlot waitSlot = country.GetAvailableWaitSlot(); if (waitSlot == null) { Debug.Log("No available waiting slots for plane " + planeSO.name); continue; } Plane newPlane = Instantiate(country.planePrefab); newPlane.transform.SetParent(waitSlot.transform, false); newPlane.planeSO = planeSO; newPlane.waitSlot = waitSlot; newPlane.country = country; waitSlot.isOccupied = true; planes.Add(newPlane); newPlane.Arrive(transitionDuration); //Debug.Log("Plane " + planeSO.name + " has been spawned"); } }