Beispiel #1
0
        /// <summary>
        /// Determines whether the building with the specified <paramref name="buildingId"/> is noise restricted
        /// (has NIMBY policy that is active on current time).
        /// </summary>
        /// <param name="buildingId">The building ID to check.</param>
        /// <param name="currentBuildingId">The ID of a building where the citizen starts their journey.
        /// Specify 0 if there is no journey in schedule.</param>
        /// <returns>
        ///   <c>true</c> if the building with the specified <paramref name="buildingId"/> has NIMBY policy
        ///   that is active on current time; otherwise, <c>false</c>.
        /// </returns>
        public bool IsNoiseRestricted(ushort buildingId, ushort currentBuildingId = 0)
        {
            if (buildingManager.GetBuildingSubService(buildingId) != ItemClass.SubService.CommercialLeisure)
            {
                return(false);
            }

            float currentHour = timeInfo.CurrentHour;

            if (currentHour >= config.GoToSleepHour || currentHour <= config.WakeUpHour)
            {
                return(buildingManager.IsBuildingNoiseRestricted(buildingId));
            }

            if (currentBuildingId == 0)
            {
                return(false);
            }

            float travelTime = travelBehavior.GetEstimatedTravelTime(currentBuildingId, buildingId);

            if (travelTime == 0)
            {
                return(false);
            }

            float arriveHour = (float)timeInfo.Now.AddHours(travelTime).TimeOfDay.TotalHours;

            if (arriveHour >= config.GoToSleepHour || arriveHour <= config.WakeUpHour)
            {
                return(buildingManager.IsBuildingNoiseRestricted(buildingId));
            }

            return(false);
        }