private bool IsBuildingNoiseRestricted(ushort targetBuilding, ushort currentBuilding) { if (BuildingMgr.GetBuildingSubService(targetBuilding) != ItemClass.SubService.CommercialLeisure) { return(false); } float currentHour = TimeInfo.CurrentHour; if (currentHour >= Config.GoToSleepUpHour || currentHour <= Config.WakeupHour) { return(BuildingMgr.IsBuildingNoiseRestricted(targetBuilding)); } float travelTime = GetEstimatedTravelTime(currentBuilding, targetBuilding); if (travelTime == 0) { return(false); } float arriveHour = (float)TimeInfo.Now.AddHours(travelTime).TimeOfDay.TotalHours; if (arriveHour >= Config.GoToSleepUpHour || arriveHour <= Config.WakeupHour) { return(BuildingMgr.IsBuildingNoiseRestricted(targetBuilding)); } return(false); }
private bool IsBuildingNoiseRestricted(ushort building) { float arriveHour = (float)TimeInfo.Now.AddHours(MaxHoursOnTheWay).TimeOfDay.TotalHours; return((arriveHour >= TimeInfo.SunsetHour || TimeInfo.CurrentHour >= TimeInfo.SunsetHour || arriveHour <= TimeInfo.SunriseHour || TimeInfo.CurrentHour <= TimeInfo.SunriseHour) && BuildingMgr.IsBuildingNoiseRestricted(building)); }
private bool CitizenReturnsHomeFromVisit(TAI instance, uint citizenId, ref TCitizen citizen, bool isVirtual) { ushort homeBuilding = CitizenProxy.GetHomeBuilding(ref citizen); if (homeBuilding == 0 || CitizenProxy.GetVehicle(ref citizen) != 0) { return(false); } ushort visitBuilding = CitizenProxy.GetVisitBuilding(ref citizen); switch (EventMgr.GetEventState(visitBuilding, TimeInfo.Now.AddHours(MaxHoursOnTheWay))) { case CityEventState.Upcoming: case CityEventState.Ongoing: return(false); case CityEventState.Finished: Log.Debug(TimeInfo.Now, $"{GetCitizenDesc(citizenId, ref citizen, isVirtual)} returning from an event at {visitBuilding} back home to {homeBuilding}"); ReturnFromVisit(instance, citizenId, ref citizen, homeBuilding, Citizen.Location.Home, isVirtual); return(true); } ItemClass.SubService visitedSubService = BuildingMgr.GetBuildingSubService(visitBuilding); if (Random.ShouldOccur(ReturnFromVisitChance) || (visitedSubService == ItemClass.SubService.CommercialLeisure && TimeInfo.IsNightTime && BuildingMgr.IsBuildingNoiseRestricted(visitBuilding))) { Log.Debug(TimeInfo.Now, $"{GetCitizenDesc(citizenId, ref citizen, isVirtual)} returning from visit back home"); ReturnFromVisit(instance, citizenId, ref citizen, homeBuilding, Citizen.Location.Home, isVirtual); return(true); } return(false); }