예제 #1
0
        public static bool ShouldGoToWork(this Citizen citizen, uint citizenId)
        {
            if (citizen.ValidWorkBuilding() && (citizen.ShouldBeAtWork(citizenId) || citizen.ShouldBeAtWork(citizenId, TimeSpan.FromHours(6))))
            {
                var currentBuildingInstance = citizen.GetBuildingInstance();
                var workBuildingInstance    = citizen.WorkBuildingInstance();

                if (currentBuildingInstance.HasValue)
                {
                    var travelTime = TravelTime.EstimateTravelTime(currentBuildingInstance.Value, workBuildingInstance.Value);
                    return(citizen.ShouldBeAtWork(citizenId, travelTime));
                }
                else
                {
                    return(citizen.ShouldBeAtWork(citizenId, TimeSpan.FromHours(2)));
                }
            }

            return(false);
        }
예제 #2
0
        public static bool ShouldGoHome(this Citizen citizen)
        {
            if (citizen.ValidHomeBuilding() && citizen.Tired(TimeSpan.FromHours(6)))
            {
                var currentBuildingInstance = citizen.GetBuildingInstance();
                var homeBuildingInstance    = citizen.HomeBuildingInstance();

                if (currentBuildingInstance.HasValue)
                {
                    var travelTime = TravelTime.EstimateTravelTime(currentBuildingInstance.Value, homeBuildingInstance.Value);
                    return(citizen.Tired(travelTime));
                }
                else
                {
                    return(citizen.Tired(TimeSpan.FromHours(2)));
                }
            }

            return(false);
        }