private void CreateRandomEvent(ushort buildingId) { string buildingClass = buildingManager.GetBuildingClassName(buildingId); if (string.IsNullOrEmpty(buildingClass)) { return; } ICityEvent newEvent = eventProvider.GetRandomEvent(buildingClass); if (newEvent == null) { return; } DateTime startTime = upcomingEvents.Count == 0 ? timeInfo.Now : upcomingEvents.Last.Value.EndTime.Add(MinimumIntervalBetweenEvents); startTime = AdjustEventStartTime(startTime, randomize: true); if (startTime < earliestEvent) { return; } earliestEvent = startTime.AddHours(randomizer.GetRandomValue(EventIntervalVariance)); newEvent.Configure(buildingId, buildingManager.GetBuildingName(buildingId), startTime); upcomingEvents.AddLast(newEvent); OnEventsChanged(); Log.Debug(LogCategory.Events, timeInfo.Now, $"New event created for building {newEvent.BuildingId}, starts on {newEvent.StartTime}, ends on {newEvent.EndTime}"); }
private void CreateRandomEvent(ushort buildingId) { string buildingClass = buildingManager.GetBuildingClassName(buildingId); if (string.IsNullOrEmpty(buildingClass)) { return; } ICityEvent newEvent = eventProvider.GetRandomEvent(buildingClass); if (newEvent == null) { return; } DateTime startTime = GetRandomEventStartTime(); if (startTime < earliestEvent) { return; } earliestEvent = startTime.AddHours(simulationManager.GetRandomizer().Int32(EventIntervalVariance)); newEvent.Configure(buildingId, buildingManager.GetBuildingName(buildingId), startTime); upcomingEvents.AddLast(newEvent); OnEventsChanged(); Log.Debug(timeInfo.Now, $"New event created for building {newEvent.BuildingId}, starts on {newEvent.StartTime}, ends on {newEvent.EndTime}"); }