public override void CompTick() { Pawn pawn = this.parent as Pawn; if (pawn.Spawned) { if (addHediffOnce) { pawn.health.AddHediff(HediffDef.Named("AA_Nocturnal")); Hediff hediff = pawn.health.hediffSet.GetFirstHediffOfDef(HediffDef.Named("AA_Nocturnal"), false); hediff.Severity = 1f; addHediffOnce = false; } int currentHour = GenLocalDate.HourInteger(pawn.Map); //float num = this.Map.glowGrid.GameGlowAt(this.Position, false); if ((currentHour >= 19 && currentHour <= 24) || (currentHour >= 0 && currentHour <= 9)) { if (pawn.needs.rest.CurLevelPercentage < 0.8) { pawn.needs.rest.SetInitialLevel(); RestUtility.WakeUp(pawn); } } else if (currentHour >= 10 && currentHour <= 13) { pawn.needs.rest.CurLevel = 0; } } }
private void RareTick() { if (GenDate.DaysPassed > day && GenLocalDate.HourInteger(map) == 0) { OnNextDay(GenDate.DaysPassed); } }
public static IEnumerable <Rule> ExtraRules(Pawn initiator, Pawn recipient) { string initPrefix = "INITIATOR_", reciPrefix = "RECIPIENT_"; foreach (var rule in ExtraRulesForPawn(initPrefix, initiator /*, person.firstSingular*/)) { yield return(rule); } foreach (var rule in ExtraRulesForPawn(reciPrefix, recipient /*, person.secondSingular*/)) { yield return(rule); } //clima yield return(new Rule_String("WEATHER", initiator.Map.weatherManager.CurWeatherPerceived.label)); //hora yield return(new Rule_String("HOUR", GenLocalDate.HourInteger(initiator).ToString())); yield return(new Rule_String("DAYPERIOD", DayPeriod(initiator))); //arte ou planta por perto foreach (var group in subjects) { var thing = GenClosest.ClosestThing_Global(initiator.Position, initiator.Map.listerThings.ThingsInGroup(group), lookRadius); if (thing != null) { yield return(new Rule_String($"NEAREST_{group.ToString().ToLower()}", $"{thing.def.label}")); } } }
public bool CheckLightLevels() { bool bee1nocturnal = innerContainerDrones.FirstOrFallback().TryGetComp <CompBees>().GetNocturnal; bool bee2nocturnal = innerContainerQueens.FirstOrFallback().TryGetComp <CompBees>().GetNocturnal; if (bee1nocturnal || bee2nocturnal || RimBees_Settings.RB_IgnoreNight) { flagLight = true; return(true); } else { int currentHour = GenLocalDate.HourInteger(this.Map); //float num = this.Map.glowGrid.GameGlowAt(this.Position, false); if (currentHour >= 5 && currentHour <= 22) { flagLight = true; return(true); } else { flagLight = false; return(false); } } }
public override float GetPriority(Pawn pawn) { if (pawn.VampComp() is CompVampire v && v.IsVampire && GenLocalDate.HourInteger(pawn) >= 6 && GenLocalDate.HourInteger(pawn) <= 17 && !pawn.PositionHeld.Roofed(pawn.MapHeld)) { return(9.5f); } return(0f); }
public override float TemperatureOffset() { Map map = Find.CurrentMap; if (GenLocalDate.HourInteger(map) >= 11 && GenLocalDate.HourInteger(map) <= 19) { return(GameConditionUtility.LerpInOutValue(this, 10000f, MaxTempOffset)); } else if (GenLocalDate.HourInteger(map) >= 20 || GenLocalDate.HourInteger(map) <= 10) { return(GameConditionUtility.LerpInOutValue(this, 10000f, MinTempOffset)); } return(GameConditionUtility.LerpInOutValue(this, 10000f, MaxTempOffset)); }
public static IEnumerable <Rule> ExtraRules() { Pawn initiator = DialogManager.Initiator; if (initiator == null) { yield break; } //pawn parameters if (PawnCheck()) { Pawn recipient = DialogManager.Recipient; string initPrefix = "INITIATOR_", reciPrefix = "RECIPIENT_"; foreach (var rule in ExtraRulesForPawn(initPrefix, initiator, recipient)) { yield return(rule); } foreach (var rule in ExtraRulesForPawn(reciPrefix, recipient, initiator)) { yield return(rule); } } //climate yield return(new Rule_String("WEATHER", initiator.Map.weatherManager.CurWeatherPerceived.label)); //time yield return(new Rule_String("HOUR", GenLocalDate.HourInteger(initiator).ToString())); yield return(new Rule_String("DAYPERIOD", DayPeriod(initiator))); //temperature yield return(new Rule_String("TEMPERATURE", GenTemperature.GetTemperatureForCell(initiator.Position, initiator.Map).ToString())); //outdoor? yield return(new Rule_String("OUTDOORS", initiator.Position.UsesOutdoorTemperature(initiator.Map).ToStringYesNo())); //nearest things foreach (var group in subjects) { var thing = GenClosest.ClosestThing_Global(initiator.Position, initiator.Map.listerThings.ThingsInGroup(group), lookRadius); if (thing != null) { yield return(new Rule_String($"NEAREST_{group.ToString().ToLower()}", $"{thing.def.label}")); } } }
public override bool CanSpawn(Map affectedMap) { if (Current.Game.Maps.Count == 0) { return(false); } Map map = Current.Game.Maps[0]; if (GenLocalDate.HourInteger(map) >= MinHours && GenLocalDate.HourInteger(map) <= MaxHours) { return(true); } return(false); }
public void Tick() { if (ticksLeftInCycle < 0) { if (Find.VisibleMap is Map m) { int time = GenLocalDate.HourInteger(m); if (time <= 3 || time >= 21) { FullMoonIncident(); } else { ticksLeftInCycle += GenDate.TicksPerHour; } } } ticksLeftInCycle--; }
public void NeedSeedCountDown() { if (ticksToSpawnCultSeed > 0) { ticksToSpawnCultSeed -= 1; } else { if (GenLocalDate.HourInteger(map) > 21 || GenLocalDate.HourInteger(map) < 6) { ticksToSpawnCultSeed = OneDay + Rand.Range(-20000, +20000); IncidentDef seed = seedIncidents.RandomElement <IncidentDef>(); IncidentParms parms = StorytellerUtility.DefaultParmsNow(seed.category, map); seed.Worker.TryExecute(parms); return; } ticksToSpawnCultSeed += GenDate.TicksPerHour; } }
public bool CanSpawnInRequiredTimeRanges() { var curTime = GenLocalDate.HourInteger(this.parent.Map); if (Props.reqTimeRangeToSpawn != null) { foreach (var reqTime in Props.reqTimeRangeToSpawn) { if (curTime >= reqTime.min && curTime <= reqTime.max) { return(true); } } } else { return(true); } return(false); }
private static string DayPeriod(Pawn p) { int hour = GenLocalDate.HourInteger(p); if (hour >= 5 && hour < 12) { return(dayPeriod.morning.ToString()); } if (hour >= 12 && hour < 18) { return(dayPeriod.afternoon.ToString()); } if (hour >= 18 && hour < 24) { return(dayPeriod.evening.ToString()); } else { return(dayPeriod.night.ToString()); } }
protected override bool CanFireNowSub(IncidentParms parms) { Map map = (Map)parms.target; Cthulhu.Utility.DebugReport("Cosmic Horror Raid Report: Tried to start event."); if (!base.CanFireNowSub(parms)) { Cthulhu.Utility.DebugReport("Cosmic Horror Raid Report: Failed due to base CanFireNow process"); return(false); } if (GenDate.DaysPassed < (ModInfo.cosmicHorrorRaidDelay + this.def.earliestDay)) { return(false); } if (map.gameConditionManager.ConditionIsActive(GameConditionDefOf.Eclipse)) { Cthulhu.Utility.DebugReport("Cosmic Horror Raid Report: Firing accepted - Eclipse"); return(true); } WeatherDef weather = map.weatherManager.curWeather; if (weather == WeatherDef.Named("Fog") || weather == WeatherDef.Named("RainyThunderstorm") || weather == WeatherDef.Named("FoggyRain")) { Cthulhu.Utility.DebugReport("Cosmic Horror Raid Report: Firing accepted - " + weather.label); return(true); } if (!(GenLocalDate.HourInteger(map) >= 6 && GenLocalDate.HourInteger(map) <= 17)) { Cthulhu.Utility.DebugReport("Cosmic Horror Raid Report: Firing accepted - Nighttime"); return(true); } return(false); }
public bool AcceptableMapConditionsToStartElection(Map map) { if (!GatheringsUtility.AcceptableGameConditionsToContinueGathering(map) || (!Position.Roofed(map) && !JoyUtility.EnjoyableOutsideNow(map, null))) { return(false); } if (GenLocalDate.HourInteger(map) < 8 || GenLocalDate.HourInteger(map) > 21) { return(false); } List <Lord> lords = map.lordManager.lords; for (int i = 0; i < lords.Count; i++) { if (lords[i].LordJob is LordJob_Joinable_Party || lords[i].LordJob is LordJob_Joinable_MarriageCeremony || lords[i].LordJob is LordJob_Joinable_SetLeadership) { return(false); } } if (map.dangerWatcher.DangerRating != StoryDanger.None) { return(false); } int num2 = Mathf.RoundToInt((float)map.mapPawns.FreeColonistsSpawnedCount * 0.65f); num2 = Mathf.Clamp(num2, 2, 10); int num3 = 0; foreach (Pawn current2 in map.mapPawns.FreeColonistsSpawned) { if (GatheringsUtility.ShouldGuestKeepAttendingGathering(current2)) { num3++; } } return(num3 >= num2); }
// OVERRIDE METHODS // public override void UpdateAllDuties() { int curHour = GenLocalDate.HourInteger(Map); int numActiveGuards = Mathf.RoundToInt(Info.pawnsWithRole[CarnivalRole.Guard].Count / 2f); foreach (var pawn in lord.ownedPawns) { CarnivalRole role = pawn.GetCarnivalRole(); if (role.Is(CarnivalRole.Guard)) { if (numActiveGuards > 0 && pawn.needs.rest.CurCategory == RestCategory.Rested) { DutyUtility.GuardCircuit(pawn); numActiveGuards--; } else { // rest on the off shift if not assigned a position DutyUtility.ForceRest(pawn); } } else if (role.IsAny(CarnivalRole.Entertainer, CarnivalRole.Vendor) && curHour >= 22) { DutyUtility.ForceRest(pawn); } else if (role.Is(CarnivalRole.Worker)) { DutyUtility.MeanderAndHelp(pawn, Info.setupCentre, Info.baseRadius); } else if (!role.Is(CarnivalRole.Carrier)) { DutyUtility.Meander(pawn, Info.setupCentre, Info.baseRadius); } } }
private bool IsDay(Map map) { return(GenLocalDate.HourInteger(map) >= 8 && GenLocalDate.HourInteger(map) <= 20); }
public static bool IsNightNow(this Map map) { return(GenLocalDate.HourInteger(map) >= 20 || GenLocalDate.HourInteger(map) < 6); }
GenLocalDate.HourInteger(map) > 6 && GenLocalDate.HourInteger(map) < 10; public static bool IsEvening(Map map) => GenLocalDate.HourInteger(map) > 18 && GenLocalDate.HourInteger(map) < 22; public static bool IsNight(Map map) => GenLocalDate.HourInteger(map) > 22;
public static bool IsNight(Map map) { return(GenLocalDate.HourInteger(map) > 22); }
public static bool IsEvening(Map map) { return(GenLocalDate.HourInteger(map) > 18 && GenLocalDate.HourInteger(map) < 22); }
public static bool IsMorning(Map map) { return(GenLocalDate.HourInteger(map) > 6 && GenLocalDate.HourInteger(map) < 10); }
public static bool IsDaylight(Map m) => (GenLocalDate.HourInteger(m) >= 6 && GenLocalDate.HourInteger(m) <= 17) && !Find.World.GameConditionManager.ConditionIsActive(GameConditionDefOf.Eclipse);
/// <summary> /// This is used, when the Ticker is set to Normal /// This Tick is done often (60 times per second) /// </summary> public override void Tick() { base.Tick(); // Do nothing further if it isn't initialized yet if (!init) { return; } // Update ticks for timed switching UpdateTimedSwitch(); // If updated, no other update until counter reach value if (ticksNoUpdate > 0) { ticksNoUpdate--; return; } // Search for enemies within reach.. if ((autoSwitchOnEnemyActive) || (autoSwitchOffEnemyActive)) { // Enemy search active >> Search every x Ticks enemySearchCount += 1; if (enemySearchCount >= enemySearchCountMax) { enemySearchCount = 0; bool foundWithAnimals = SearchForEnemy(Map); //bool foundNoAnimals = SearchForEnemyNoAnimals(Map); // Power on when enemy in range! if (autoSwitchOnEnemyActive) { // Switch on undelayed //if (foundNoAnimals && (!flickableComp.SwitchIsOn || ticksSwitchOff >= 0)) if (foundWithAnimals && (!flickableComp.SwitchIsOn || ticksSwitchOff >= 0)) { ResetTimedSwitch(); if (enemyDetectionSwitchViaDesignator) { SetWantSwitchOn(true); } else { flickableComp.SwitchIsOn = true; // No designator usage! SetWantSwitchOn(true); } } // Switch off delayed //if (!foundNoAnimals && flickableComp.SwitchIsOn && (ticksSwitchOff < 0)) if (!foundWithAnimals && flickableComp.SwitchIsOn && (ticksSwitchOff < 0)) { ResetTimedSwitch(); if (enemyDetectionSwitchViaDesignator) { SetTimedSwitch(false, true); } else { SetTimedSwitch(false, true, true); } } } // Power off when enemy in range! if (autoSwitchOffEnemyActive) { // Switch off undelayed if (foundWithAnimals && (flickableComp.SwitchIsOn || ticksSwitchOn >= 0)) { ResetTimedSwitch(); if (enemyDetectionSwitchViaDesignator) { SetWantSwitchOn(false); } else { flickableComp.SwitchIsOn = false; // No designator usage! SetWantSwitchOn(false); } } // Switch on delayed if (!foundWithAnimals && !flickableComp.SwitchIsOn && (ticksSwitchOn < 0)) { ResetTimedSwitch(); if (enemyDetectionSwitchViaDesignator) { SetTimedSwitch(true, false); } else { SetTimedSwitch(true, false, true); } } } } } if ((!autoSwitchOnEnemyActive) && (!autoSwitchOffEnemyActive)) { // Not active >> Reset counter enemySearchCount = 0; } // Search for pawns in the room.. if (autoSwitchOnPawnActive) { // Pawn search active >> Search every x Ticks pawnSearchCount += 1; if (pawnSearchCount >= pawnSearchCountMax) { pawnSearchCount = 0; bool found = SearchForPawnInRoom(Map); // Power is ON >> switch it off, when there is no pawn in the room! // Switch on - undelayed if (found && (!flickableComp.SwitchIsOn || ticksSwitchOff >= 0)) { ResetTimedSwitch(); flickableComp.SwitchIsOn = true; // No designator usage! SetWantSwitchOn(true); } // Switch off - delayed if (!found && flickableComp.SwitchIsOn && (ticksSwitchOff < 0)) { ResetTimedSwitch(); SetTimedSwitch(false, true, true); // No designator usage! } } } else { // Not active >> Reset counter pawnSearchCount = 0; } // Timer switching if (autoSwitchTimerActive) { // Time = Off-Time => Switch OFF if (GenLocalDate.HourInteger(Map) == autoSwitchTimerOffTime && flickableComp.SwitchIsOn) { flickableComp.SwitchIsOn = false; // No designator usage! SetWantSwitchOn(false); } // Time = On-Time => Switch ON if (GenLocalDate.HourInteger(Map) == autoSwitchTimerOnTime && !flickableComp.SwitchIsOn) { flickableComp.SwitchIsOn = true; // No designator usage! SetWantSwitchOn(true); } } }
public static bool TimeToWorship(Map map, int time) { return(GenLocalDate.HourInteger(map) > time - 1 && GenLocalDate.HourInteger(map) < time + 1); }
/// <summary> /// An easy function to check if it is day /// </summary> /// <returns></returns> public static bool IsDayTime(Map map) { return(GenLocalDate.HourInteger(map) >= 5 && GenLocalDate.HourInteger(map) <= 19); }