private bool ScheduleRelaxing(ref CitizenSchedule schedule, uint citizenId, ref TCitizen citizen) { Citizen.AgeGroup citizenAge = CitizenProxy.GetAge(ref citizen); uint relaxChance = spareTimeBehavior.GetRelaxingChance(citizenAge, schedule.WorkShift, schedule.WorkStatus == WorkStatus.OnVacation); relaxChance = AdjustRelaxChance(relaxChance, ref citizen); if (!Random.ShouldOccur(relaxChance) || WeatherInfo.IsBadWeather) { return(false); } ICityEvent cityEvent = GetUpcomingEventToAttend(citizenId, ref citizen); if (cityEvent != null) { ushort currentBuilding = CitizenProxy.GetCurrentBuilding(ref citizen); DateTime departureTime = cityEvent.StartTime.AddHours(-travelBehavior.GetEstimatedTravelTime(currentBuilding, cityEvent.BuildingId)); schedule.Schedule(ResidentState.Relaxing, departureTime); schedule.EventBuilding = cityEvent.BuildingId; schedule.Hint = ScheduleHint.AttendingEvent; return(true); } schedule.Schedule(ResidentState.Relaxing); schedule.Hint = TimeInfo.IsNightTime && Random.ShouldOccur(NightLeisureChance) ? ScheduleHint.RelaxAtLeisureBuilding : ScheduleHint.None; return(true); }
private bool ShouldReturnFromSchoolOrWork(Citizen.AgeGroup citizenAge) { if (IsWeekend) { return(true); } float currentHour = TimeInfo.CurrentHour; switch (citizenAge) { case Citizen.AgeGroup.Child: case Citizen.AgeGroup.Teen: return(currentHour >= Config.SchoolEnd || currentHour < Config.SchoolBegin - MaxHoursOnTheWay); case Citizen.AgeGroup.Young: case Citizen.AgeGroup.Adult: if (currentHour >= (Config.WorkEnd + Config.MaxOvertime) || currentHour < Config.WorkBegin - MaxHoursOnTheWay) { return(true); } else if (currentHour >= Config.WorkEnd) { return(IsChance(Config.OnTimeQuota)); } break; default: return(true); } return(false); }
private bool CitizenGoesRelaxing(TAI instance, uint citizenId, ref TCitizen citizen) { Citizen.AgeGroup citizenAge = CitizenProxy.GetAge(ref citizen); if (!IsChance(GetGoOutChance(citizenAge))) { return(false); } ushort buildingId = CitizenProxy.GetCurrentBuilding(ref citizen); if (buildingId == 0) { return(false); } if (TimeInfo.IsNightTime) { ushort leisure = MoveToLeisure(instance, citizenId, ref citizen, buildingId); Log.Debug(TimeInfo.Now, $"{GetCitizenDesc(citizenId, ref citizen)} wanna relax at night, trying leisure area '{leisure}'"); return(leisure != 0); } if (CitizenProxy.GetWorkBuilding(ref citizen) != 0 && IsWorkDayMorning(citizenAge)) { return(false); } Log.Debug(TimeInfo.Now, $"{GetCitizenDesc(citizenId, ref citizen)} wanna relax, heading to an entertainment place"); residentAI.FindVisitPlace(instance, citizenId, buildingId, residentAI.GetEntertainmentReason(instance)); return(true); }
private void DoScheduledWork(ref CitizenSchedule schedule, TAI instance, uint citizenId, ref TCitizen citizen) { ushort currentBuilding = CitizenProxy.GetCurrentBuilding(ref citizen); schedule.WorkStatus = WorkStatus.Working; schedule.DepartureToWorkTime = default; if (currentBuilding == schedule.WorkBuilding && schedule.CurrentState != ResidentState.AtSchoolOrWork) { CitizenProxy.SetVisitPlace(ref citizen, citizenId, 0); CitizenProxy.SetLocation(ref citizen, Citizen.Location.Work); } else if (residentAI.StartMoving(instance, citizenId, ref citizen, currentBuilding, schedule.WorkBuilding) && schedule.CurrentState == ResidentState.AtHome) { schedule.DepartureToWorkTime = TimeInfo.Now; } Citizen.AgeGroup citizenAge = CitizenProxy.GetAge(ref citizen); if (workBehavior.ScheduleLunch(ref schedule, citizenAge)) { Log.Debug(TimeInfo.Now, $"{GetCitizenDesc(citizenId, ref citizen)} is going from {currentBuilding} to school/work {schedule.WorkBuilding} and will go to lunch at {schedule.ScheduledStateTime}"); } else { workBehavior.ScheduleReturnFromWork(ref schedule, citizenAge); Log.Debug(TimeInfo.Now, $"{GetCitizenDesc(citizenId, ref citizen)} is going from {currentBuilding} to school/work {schedule.WorkBuilding} and will leave work at {schedule.ScheduledStateTime}"); } }
/// <summary> /// Gets the probability whether a citizen with specified age would go relaxing on current time. /// </summary> /// /// <param name="citizenAge">The age of the citizen to check.</param> /// <param name="workShift">The citizen's assigned work shift (default is <see cref="WorkShift.Unemployed"/>).</param> /// <param name="isOnVacation"><c>true</c> if the citizen is on vacation.</param> /// /// <returns>A percentage value in range of 0..100 that describes the probability whether /// a citizen with specified age would go relaxing on current time.</returns> public uint GetRelaxingChance(Citizen.AgeGroup citizenAge, WorkShift workShift = WorkShift.Unemployed, bool isOnVacation = false) { if (isOnVacation) { return(defaultChances[(int)citizenAge] * 2u); } int age = (int)citizenAge; switch (citizenAge) { case Citizen.AgeGroup.Young: case Citizen.AgeGroup.Adult: switch (workShift) { case WorkShift.Second: return(secondShiftChances[age]); case WorkShift.Night: return(nightShiftChances[age]); default: return(defaultChances[age]); } default: return(defaultChances[age]); } }
/// <summary> /// Determines whether the current time represents a morning hour of a work day /// for a citizen with the provided <paramref name="citizenAge"/>. /// </summary> /// /// <param name="citizenAge">The citizen age to check.</param> /// /// <returns> /// <c>true</c> if the current time represents a morning hour of a work day /// for a citizen with the provided age; otherwise, <c>false</c>. /// </returns> protected bool IsWorkDayMorning(Citizen.AgeGroup citizenAge) { if (!IsWorkDay) { return(false); } float workBeginHour; switch (citizenAge) { case Citizen.AgeGroup.Child: case Citizen.AgeGroup.Teen: workBeginHour = Config.SchoolBegin; break; case Citizen.AgeGroup.Young: case Citizen.AgeGroup.Adult: workBeginHour = Config.WorkBegin; break; default: return(false); } float currentHour = TimeInfo.CurrentHour; return(currentHour >= TimeInfo.SunriseHour && currentHour <= workBeginHour); }
private static bool Prefix(ref Citizen.AgeGroup __result, int age) { if (age < 15) { __result = Citizen.AgeGroup.Child; } else if (age < 45) { __result = Citizen.AgeGroup.Teen; } else if (age < 90) { __result = Citizen.AgeGroup.Young; } else if (age < ModSettings.retirementAge) { __result = Citizen.AgeGroup.Adult; } else { __result = Citizen.AgeGroup.Senior; } // Don't execute original method after this. return(false); }
private bool ScheduleRelaxing(ref CitizenSchedule schedule, uint citizenId, ref TCitizen citizen) { Citizen.AgeGroup citizenAge = CitizenProxy.GetAge(ref citizen); if (!Random.ShouldOccur(spareTimeBehavior.GetGoOutChance(citizenAge)) || IsBadWeather()) { return(false); } ICityEvent cityEvent = GetUpcomingEventToAttend(citizenId, ref citizen); if (cityEvent != null) { ushort currentBuilding = CitizenProxy.GetCurrentBuilding(ref citizen); DateTime departureTime = cityEvent.StartTime.AddHours(-GetEstimatedTravelTime(currentBuilding, cityEvent.BuildingId)); schedule.Schedule(ResidentState.Relaxing, departureTime); schedule.EventBuilding = cityEvent.BuildingId; schedule.Hint = ScheduleHint.AttendingEvent; return(true); } schedule.Schedule(ResidentState.Relaxing, default); schedule.Hint = TimeInfo.IsNightTime ? ScheduleHint.RelaxAtLeisureBuilding : ScheduleHint.None; return(true); }
/// <summary> /// Gets the probability whether a citizen with specified age would go out on current time. /// </summary> /// /// <param name="citizenAge">The age of the citizen to check.</param> /// <param name="workShift">The citizen's assigned work shift (or <see cref="WorkShift.Unemployed"/>).</param> /// <param name="needsShopping"><c>true</c> when the citizen needs to buy something; otherwise, <c>false</c>.</param> /// /// <returns>A percentage value in range of 0..100 that describes the probability whether /// a citizen with specified age would go out on current time.</returns> public uint GetGoOutChance(Citizen.AgeGroup citizenAge, WorkShift workShift, bool needsShopping) { if (needsShopping) { return(shoppingChances[(int)citizenAge]); } int age = (int)citizenAge; switch (citizenAge) { case Citizen.AgeGroup.Young: case Citizen.AgeGroup.Adult: switch (workShift) { case WorkShift.Second: return(secondShiftChances[age]); case WorkShift.Night: return(nightShiftChances[age]); default: return(defaultChances[age]); } default: return(defaultChances[age]); } }
private void FindRandomVisitPlace(TAI instance, uint citizenId, ref TCitizen citizen, int doNothingProbability, ushort currentBuilding) { int targetType = touristAI.GetRandomTargetType(instance, doNothingProbability); if (targetType == 1) { Log.Debug(TimeInfo.Now, $"Tourist {GetCitizenDesc(citizenId, ref citizen)} decides to leave the city"); touristAI.FindVisitPlace(instance, citizenId, currentBuilding, touristAI.GetLeavingReason(instance, citizenId, ref citizen)); return; } Citizen.AgeGroup age = CitizenProxy.GetAge(ref citizen); uint goOutChance = CitizenProxy.HasFlags(ref citizen, Citizen.Flags.NeedGoods) ? spareTimeBehavior.GetShoppingChance(age) : spareTimeBehavior.GetRelaxingChance(age, WorkShift.Unemployed); if (!Random.ShouldOccur(goOutChance) || IsBadWeather()) { FindHotel(instance, citizenId, ref citizen); return; } switch (targetType) { case 2: touristAI.FindVisitPlace(instance, citizenId, currentBuilding, touristAI.GetShoppingReason(instance)); Log.Debug(TimeInfo.Now, $"Tourist {GetCitizenDesc(citizenId, ref citizen)} stays in the city, goes shopping"); break; case 3: Log.Debug(TimeInfo.Now, $"Tourist {GetCitizenDesc(citizenId, ref citizen)} stays in the city, goes relaxing"); touristAI.FindVisitPlace(instance, citizenId, currentBuilding, touristAI.GetEntertainmentReason(instance)); break; } }
/// <summary> /// Checks whether the citizen can stay out, or whether they'd prefer to come home /// </summary> /// <param name="person">The citizen to check</param> /// <returns>Whether the citizen would be able to stay out or not</returns> public static bool CanStayOut(ref Citizen person) { bool canStayOut = false; SimulationManager _simulation = Singleton <SimulationManager> .instance; Citizen.AgeGroup ageGroup = Citizen.GetAgeGroup(person.Age); float currentHour = _simulation.m_currentDayTimeHour; switch (ageGroup) { case Citizen.AgeGroup.Child: case Citizen.AgeGroup.Teen: case Citizen.AgeGroup.Senior: if (currentHour < 16 && currentHour > 7) { canStayOut = true; } break; case Citizen.AgeGroup.Young: case Citizen.AgeGroup.Adult: if ((currentHour < 19 && currentHour > 7) || GoOutAtNight(person.Age) != 0) { canStayOut = true; } break; } return(canStayOut); }
/// <summary>Accepts an event attendee with specified properties.</summary> /// <param name="age">The attendee age.</param> /// <param name="gender">The attendee gender.</param> /// <param name="education">The attendee education.</param> /// <param name="wealth">The attendee wealth.</param> /// <param name="wellbeing">The attendee wellbeing.</param> /// <param name="happiness">The attendee happiness.</param> /// <param name="randomizer">A reference to the game's randomizer.</param> /// <returns> /// <c>true</c> if the event attendee with specified properties is accepted and can attend this city event; /// otherwise, <c>false</c>. /// </returns> public override bool TryAcceptAttendee( Citizen.AgeGroup age, Citizen.Gender gender, Citizen.Education education, Citizen.Wealth wealth, Citizen.Wellbeing wellbeing, Citizen.Happiness happiness, IRandomizer randomizer) { if (attendeesCount > eventTemplate.Capacity) { return(false); } if (eventTemplate.Costs != null && eventTemplate.Costs.Entry > GetCitizenBudgetForEvent(wealth, randomizer)) { return(false); } CityEventAttendees attendees = eventTemplate.Attendees; float randomPercentage = randomizer.GetRandomValue(100u); if (!CheckAge(age, attendees, randomPercentage)) { return(false); } randomPercentage = randomizer.GetRandomValue(100u); if (!CheckGender(gender, attendees, randomPercentage)) { return(false); } randomPercentage = randomizer.GetRandomValue(100u); if (!CheckEducation(education, attendees, randomPercentage)) { return(false); } randomPercentage = randomizer.GetRandomValue(100u); if (!CheckWealth(wealth, attendees, randomPercentage)) { return(false); } randomPercentage = randomizer.GetRandomValue(100u); if (!CheckWellbeing(wellbeing, attendees, randomPercentage)) { return(false); } randomPercentage = randomizer.GetRandomValue(100u); if (!CheckHappiness(happiness, attendees, randomPercentage)) { return(false); } attendeesCount++; return(true); }
private bool RescheduleAtHome(ref CitizenSchedule schedule, uint citizenId, ref TCitizen citizen) { if (schedule.CurrentState != ResidentState.AtHome || TimeInfo.Now < schedule.ScheduledStateTime) { return(false); } if (schedule.ScheduledState != ResidentState.Relaxing && schedule.ScheduledState != ResidentState.Shopping) { return(false); } if (schedule.ScheduledState != ResidentState.Shopping && WeatherInfo.IsBadWeather) { Log.Debug(LogCategory.Schedule, TimeInfo.Now, $"{GetCitizenDesc(citizenId, ref citizen)} re-schedules an activity because of bad weather"); schedule.Schedule(ResidentState.Unknown); return(true); } Citizen.AgeGroup age = CitizenProxy.GetAge(ref citizen); uint goingOutChance = schedule.ScheduledState == ResidentState.Shopping ? spareTimeBehavior.GetShoppingChance(age) : spareTimeBehavior.GetRelaxingChance(age, schedule.WorkShift); if (goingOutChance > 0) { return(false); } Log.Debug(LogCategory.Schedule, TimeInfo.Now, $"{GetCitizenDesc(citizenId, ref citizen)} re-schedules an activity because of time"); schedule.Schedule(ResidentState.Unknown); return(true); }
/// <summary>Accepts an event attendee with specified properties.</summary> /// <param name="age">The attendee age.</param> /// <param name="gender">The attendee gender.</param> /// <param name="education">The attendee education.</param> /// <param name="wealth">The attendee wealth.</param> /// <param name="wellbeing">The attendee wellbeing.</param> /// <param name="happiness">The attendee happiness.</param> /// <param name="randomizer">A reference to the game's randomizer.</param> /// <returns> /// <c>true</c> if the event attendee with specified properties is accepted and can attend /// this city event; otherwise, <c>false</c>. /// </returns> public virtual bool TryAcceptAttendee( Citizen.AgeGroup age, Citizen.Gender gender, Citizen.Education education, Citizen.Wealth wealth, Citizen.Wellbeing wellbeing, Citizen.Happiness happiness, IRandomizer randomizer) => true;
/// <summary>Accepts an event attendee with specified properties.</summary> /// <param name="age">The attendee age.</param> /// <param name="gender">The attendee gender.</param> /// <param name="education">The attendee education.</param> /// <param name="wealth">The attendee wealth.</param> /// <param name="wellbeing">The attendee wellbeing.</param> /// <param name="happiness">The attendee happiness.</param> /// <param name="randomizer">A reference to the game's randomizer.</param> /// <returns> /// <c>true</c> if the event attendee with specified properties is accepted and can attend /// this city event; otherwise, <c>false</c>. /// </returns> public override bool TryAcceptAttendee( Citizen.AgeGroup age, Citizen.Gender gender, Citizen.Education education, Citizen.Wealth wealth, Citizen.Wellbeing wellbeing, Citizen.Happiness happiness, IRandomizer randomizer) => ticketPrice <= GetCitizenBudgetForEvent(wealth, randomizer);
/// <summary>Updates the citizen's work shift parameters in the specified citizen's <paramref name="schedule"/>.</summary> /// <param name="schedule">The citizen's schedule to update the work shift in.</param> /// <param name="citizenAge">The age of the citizen.</param> public void UpdateWorkShift(ref CitizenSchedule schedule, Citizen.AgeGroup citizenAge) { if (schedule.WorkBuilding == 0 || citizenAge == Citizen.AgeGroup.Senior) { schedule.UpdateWorkShift(WorkShift.Unemployed, 0, 0, false); return; } ItemClass.Service buildingSevice = buildingManager.GetBuildingService(schedule.WorkBuilding); ItemClass.SubService buildingSubService = buildingManager.GetBuildingSubService(schedule.WorkBuilding); float workBegin, workEnd; WorkShift workShift = schedule.WorkShift; switch (citizenAge) { case Citizen.AgeGroup.Child: case Citizen.AgeGroup.Teen: workShift = WorkShift.First; workBegin = config.SchoolBegin; workEnd = config.SchoolEnd; break; case Citizen.AgeGroup.Young: case Citizen.AgeGroup.Adult: if (workShift == WorkShift.Unemployed) { workShift = GetWorkShift(GetBuildingWorkShiftCount(buildingSevice, buildingSubService)); } workBegin = config.WorkBegin; workEnd = config.WorkEnd; break; default: return; } switch (workShift) { case WorkShift.First when HasExtendedFirstWorkShift(buildingSevice, buildingSubService): workBegin = Math.Min(config.WakeupHour, EarliestWakeUp); break; case WorkShift.Second: workBegin = workEnd; workEnd = 0; break; case WorkShift.Night: workEnd = workBegin; workBegin = 0; break; } schedule.UpdateWorkShift(workShift, workBegin, workEnd, IsBuildingActiveOnWeekend(buildingSevice, buildingSubService)); }
public override bool CitizenCanGo(uint citizenID, ref Citizen person) { Citizen.AgeGroup _citizenAge = Citizen.GetAgeGroup(person.Age); Citizen.Gender _citizenGender = Citizen.GetGender(citizenID); int percentage = Singleton <SimulationManager> .instance.m_randomizer.Int32(100); return((_citizenGender == Citizen.Gender.Male || (_citizenGender == Citizen.Gender.Female && percentage < 20)) && _citizenAge == Citizen.AgeGroup.Young || _citizenAge == Citizen.AgeGroup.Teen); }
/// <summary>Updates the citizen's work schedule by determining the time for returning from work.</summary> /// <param name="schedule">The citizen's schedule to update.</param> /// <param name="citizenAge">The age of the citizen.</param> public void ScheduleReturnFromWork(ref CitizenSchedule schedule, Citizen.AgeGroup citizenAge) { if (schedule.WorkStatus != WorkStatus.Working) { return; } float departureHour = schedule.WorkShiftEndHour + GetOvertime(citizenAge); schedule.Schedule(ResidentState.Unknown, timeInfo.Now.FutureHour(departureHour)); }
private bool CanAttendEvent(uint citizenId, ref TCitizen citizen, ICityEvent cityEvent) { Citizen.AgeGroup age = CitizenProxy.GetAge(ref citizen); Citizen.Gender gender = CitizenProxy.GetGender(citizenId); Citizen.Education education = CitizenProxy.GetEducationLevel(ref citizen); Citizen.Wealth wealth = CitizenProxy.GetWealthLevel(ref citizen); Citizen.Wellbeing wellbeing = CitizenProxy.GetWellbeingLevel(ref citizen); Citizen.Happiness happiness = CitizenProxy.GetHappinessLevel(ref citizen); return(cityEvent.TryAcceptAttendee(age, gender, education, wealth, wellbeing, happiness, Random)); }
public override bool CitizenCanGo(uint citizenID, ref Citizen person) { Citizen.Education _citizenEducation = person.EducationLevel; Citizen.AgeGroup _citizenAge = Citizen.GetAgeGroup(person.Age); Citizen.Happiness _citizenHappiness = Citizen.GetHappinessLevel(Citizen.GetHappiness(person.m_health, person.m_wellbeing)); Citizen.Wellbeing _citizenWellbeing = Citizen.GetWellbeingLevel(_citizenEducation, person.m_wellbeing); return(_citizenAge >= Citizen.AgeGroup.Teen && _citizenHappiness >= Citizen.Happiness.Good && _citizenWellbeing >= Citizen.Wellbeing.Unhappy); }
/// <summary> /// Check whether the citizen is done with their day at work /// </summary> /// <param name="person">The citizen to check</param> /// <returns>Whether they can leave work</returns> public static bool ShouldReturnFromWork(ref Citizen person) { bool returnFromWork = false; if (!CityEventManager.instance.IsWeekend()) { SimulationManager _simulation = Singleton <SimulationManager> .instance; Citizen.AgeGroup ageGroup = Citizen.GetAgeGroup(person.Age); float currentHour = _simulation.m_currentDayTimeHour; switch (ageGroup) { case Citizen.AgeGroup.Child: case Citizen.AgeGroup.Teen: if (currentHour >= m_endSchoolHour && currentHour < m_maxSchoolHour) { uint leaveOnTimePercent = 80; returnFromWork = _simulation.m_randomizer.UInt32(100) < leaveOnTimePercent; } else if (currentHour > m_maxSchoolHour || currentHour < m_minSchoolHour) { returnFromWork = true; } break; case Citizen.AgeGroup.Young: case Citizen.AgeGroup.Adult: if (currentHour >= m_endWorkHour && currentHour < m_maxWorkHour) { uint leaveOnTimePercent = 50; returnFromWork = _simulation.m_randomizer.UInt32(100) < leaveOnTimePercent; } else if (currentHour > m_maxWorkHour || currentHour < m_minWorkHour) { returnFromWork = true; } break; default: returnFromWork = true; break; } } else { returnFromWork = true; } return(returnFromWork); }
/// <summary>Updates the citizen's work schedule by determining the lunch time.</summary> /// <param name="schedule">The citizen's schedule to update.</param> /// <param name="citizenAge">The citizen's age.</param> /// <returns><c>true</c> if a lunch time was scheduled; otherwise, <c>false</c>.</returns> public bool ScheduleLunch(ref CitizenSchedule schedule, Citizen.AgeGroup citizenAge) { if (timeInfo.Now < lunchBegin && schedule.WorkStatus == WorkStatus.Working && schedule.WorkShift == WorkShift.First && WillGoToLunch(citizenAge)) { schedule.Schedule(ResidentState.Shopping, lunchBegin); return(true); } return(false); }
/// <summary> /// Gets the probability whether a citizen with provided age would go out on current time. /// </summary> /// /// <param name="citizenAge">The citizen age to check.</param> /// /// <returns>A percentage value in range of 0..100 that describes the probability whether /// a citizen with provided age would go out on current time.</returns> protected uint GetGoOutChance(Citizen.AgeGroup citizenAge) { float currentHour = TimeInfo.CurrentHour; uint weekdayModifier; if (Config.IsWeekendEnabled) { weekdayModifier = TimeInfo.Now.IsWeekendTime(GetSpareTimeBeginHour(citizenAge), TimeInfo.SunsetHour) ? 11u : 1u; } else { weekdayModifier = 1u; } bool isDayTime = !TimeInfo.IsNightTime; float timeModifier; if (isDayTime) { timeModifier = 5f; } else { float nightDuration = TimeInfo.NightDuration; float relativeHour = currentHour - TimeInfo.SunsetHour; if (relativeHour < 0) { relativeHour += 24f; } timeModifier = 5f / nightDuration * (nightDuration - relativeHour); } switch (citizenAge) { case Citizen.AgeGroup.Child when isDayTime: case Citizen.AgeGroup.Teen when isDayTime: case Citizen.AgeGroup.Young: case Citizen.AgeGroup.Adult: return((uint)((timeModifier + weekdayModifier) * timeModifier)); case Citizen.AgeGroup.Senior when isDayTime: return(80 + weekdayModifier); default: return(0); } }
public override bool CitizenCanGo(uint citizenID, ref Citizen person) { Citizen.Wealth _citizenWealth = person.WealthLevel; Citizen.Education _citizenEducation = person.EducationLevel; Citizen.AgeGroup _citizenAge = Citizen.GetAgeGroup(person.Age); Citizen.Gender _citizenGender = Citizen.GetGender(citizenID); Citizen.Happiness _citizenHappiness = Citizen.GetHappinessLevel(Citizen.GetHappiness(person.m_health, person.m_wellbeing)); Citizen.Wellbeing _citizenWellbeing = Citizen.GetWellbeingLevel(_citizenEducation, person.m_wellbeing); return(_citizenWealth >= Citizen.Wealth.Medium && _citizenAge == Citizen.AgeGroup.Senior && _citizenHappiness >= Citizen.Happiness.Good && _citizenWellbeing > Citizen.Wellbeing.Unhappy); }
private float GetOvertime(Citizen.AgeGroup citizenAge) { switch (citizenAge) { case Citizen.AgeGroup.Young: case Citizen.AgeGroup.Adult: return(randomizer.ShouldOccur(config.OnTimeQuota) ? 0 : config.MaxOvertime *randomizer.GetRandomValue(100u) / 100f); default: return(0); } }
/// <summary> /// Check whether the citizen wants to go find some entertainment or not /// </summary> /// <param name="person">The citizen to check</param> /// <returns>Whether this citizen would like some entertainment</returns> public static bool ShouldGoFindEntertainment(ref Citizen person) { bool goFindEntertainment = false; SimulationManager _simulation = Singleton <SimulationManager> .instance; Citizen.AgeGroup ageGroup = Citizen.GetAgeGroup(person.Age); float currentHour = _simulation.m_currentDayTimeHour; float minHour = 7f, maxHour = 16f; switch (ageGroup) { case Citizen.AgeGroup.Child: minHour = 7f; maxHour = 16f; break; case Citizen.AgeGroup.Teen: minHour = 10f; maxHour = 20f; break; case Citizen.AgeGroup.Young: case Citizen.AgeGroup.Adult: minHour = 7f; maxHour = 20f; break; case Citizen.AgeGroup.Senior: minHour = 6f; maxHour = 16f; break; } if (currentHour > minHour && currentHour < maxHour) { uint wantEntertainmentPercent = GoOutThroughDay(person.Age); goFindEntertainment = _simulation.m_randomizer.UInt32(100) < wantEntertainmentPercent; } else { uint goingOutAtNightPercent = GoOutAtNight(person.Age); goFindEntertainment = _simulation.m_randomizer.UInt32(100) < goingOutAtNightPercent; } return(goFindEntertainment); }
/// <summary> /// Gets the spare time begin hour for a citizen with provided age. /// </summary> /// /// <param name="citizenAge">The citizen age to check.</param> /// /// <returns>A value representing the hour of the day when the citizen's spare time begins.</returns> protected float GetSpareTimeBeginHour(Citizen.AgeGroup citizenAge) { switch (citizenAge) { case Citizen.AgeGroup.Child: case Citizen.AgeGroup.Teen: return(Config.SchoolEnd); case Citizen.AgeGroup.Young: case Citizen.AgeGroup.Adult: return(Config.WorkEnd); default: return(0); } }
/// <summary> /// Determines whether we can go to lunch /// </summary> /// <returns>Whether it's lunch time</returns> public static bool ShouldGoToLunch(ref Citizen person) { if (Experiments.ExperimentsToggle.SimulateLunchTimeRushHour) { SimulationManager _simulation = Singleton <SimulationManager> .instance; Citizen.AgeGroup ageGroup = Citizen.GetAgeGroup(person.Age); float currentHour = _simulation.m_currentDayTimeHour; if (ageGroup > Citizen.AgeGroup.Child && currentHour > m_lunchBegin && currentHour < m_lunchEnd) { uint lunchChance = _simulation.m_randomizer.UInt32(100u); return(lunchChance < 60u); } } return(false); }
private bool WillGoToLunch(Citizen.AgeGroup citizenAge) { if (!config.IsLunchtimeEnabled) { return(false); } switch (citizenAge) { case Citizen.AgeGroup.Child: case Citizen.AgeGroup.Teen: case Citizen.AgeGroup.Senior: return(false); } return(randomizer.ShouldOccur(config.LunchQuota)); }
public override bool CitizenCanGo(uint citizenID, ref Citizen person) { Citizen.Wealth _citizenWealth = person.WealthLevel; Citizen.Education _citizenEducation = person.EducationLevel; Citizen.Gender _citizenGender = Citizen.GetGender(citizenID); Citizen.Happiness _citizenHappiness = Citizen.GetHappinessLevel(Citizen.GetHappiness(person.m_health, person.m_wellbeing)); Citizen.Wellbeing _citizenWellbeing = Citizen.GetWellbeingLevel(_citizenEducation, person.m_wellbeing); Citizen.AgeGroup _citizenAgeGroup = Citizen.GetAgeGroup(person.Age); int percentage = Singleton <SimulationManager> .instance.m_randomizer.Int32(100); return(_citizenWealth < Citizen.Wealth.High && (_citizenEducation < Citizen.Education.ThreeSchools || _citizenEducation == Citizen.Education.ThreeSchools && percentage < 5) && (_citizenGender == Citizen.Gender.Male || (_citizenGender == Citizen.Gender.Female && percentage < 20)) && _citizenHappiness > Citizen.Happiness.Bad && _citizenWellbeing > Citizen.Wellbeing.Unhappy); }