public static Sim CreateServicePerformer(ShowStage ths) { List <Service> services = new List <Service> { Magician.Instance, Singer.Instance, PerformanceArtist.Instance }; int attempts = 0; Sim performer = null; while (performer == null && attempts <= 5) { Service service = RandomUtil.GetRandomObjectFromList(services); if (service != null) { foreach (SimDescription description in service.mPool) { if (!service.IsSimAssignedTask(description) && description.CreatedSim == null) { int lotAttempts = 0; Lot lot = null; while (lot == null && lotAttempts <= 5) { lot = LotManager.SelectRandomLot(null); lotAttempts++; } if (lot != null) { Sim createdSim = service.CreateSim(lot, description); if (createdSim != null) { createdSim.FadeIn(); performer = createdSim; break; } } } } } attempts++; } return(performer); }