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}"); }
/// <summary> /// Determines whether the building with the specified ID is an entertainment target. /// </summary> /// <param name="buildingId">The building ID to check.</param> /// <returns> /// <c>true</c> if the building is an entertainment target; otherwise, <c>false</c>. /// </returns> public bool IsEntertainmentTarget(ushort buildingId) { if (buildingId == 0) { return(true); } // We override the building's active flag (e.g. at night), so a building still can post outgoing offers while inactive. // This is to prevent those offers from being dispatched. if (!buildingManager.BuildingHasFlags(buildingId, Building.Flags.Active)) { return(false); } string className = buildingManager.GetBuildingClassName(buildingId); if (string.IsNullOrEmpty(className)) { return(true); } for (int i = 0; i < BannedEntertainmentBuildings.Length; ++i) { if (className.IndexOf(BannedEntertainmentBuildings[i], 0, StringComparison.OrdinalIgnoreCase) >= 0) { return(false); } } return(true); }
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}"); }
/// <summary> /// Determines whether the building with the specified ID is an entertainment target. /// </summary> /// <param name="buildingId">The building ID to check.</param> /// <returns> /// <c>true</c> if the building is an entertainment target; otherwise, <c>false</c>. /// </returns> public bool IsEntertainmentTarget(ushort buildingId) { if (buildingId == 0) { return(true); } // A building still can post outgoing offers while inactive. // This is to prevent those offers from being dispatched. if (!buildingManager.BuildingHasFlags(buildingId, Building.Flags.Active)) { return(false); } var buildingService = buildingManager.GetBuildingService(buildingId); if (buildingService == ItemClass.Service.VarsitySports) { // Do not visit varsity sport arenas for entertainment when no active events return(false); } string className = buildingManager.GetBuildingClassName(buildingId); if (string.IsNullOrEmpty(className)) { return(true); } for (int i = 0; i < BannedEntertainmentBuildings.Length; ++i) { if (className.IndexOf(BannedEntertainmentBuildings[i], 0, StringComparison.OrdinalIgnoreCase) >= 0) { return(false); } } return(true); }
/// <summary> /// Determines whether the building with the specified ID is an entertainment target. /// </summary> /// <param name="buildingId">The building ID to check.</param> /// <returns> /// <c>true</c> if the building is an entertainment target; otherwise, <c>false</c>. /// </returns> public bool IsEntertainmentTarget(ushort buildingId) { if (buildingId == 0) { return(true); } string className = buildingManager.GetBuildingClassName(buildingId); if (string.IsNullOrEmpty(className)) { return(true); } for (int i = 0; i < BannedEntertainmentBuildings.Length; ++i) { if (className.IndexOf(BannedEntertainmentBuildings[i], 0, StringComparison.OrdinalIgnoreCase) >= 0) { return(false); } } return(true); }