public void MindStateTick() { if (wantsToTradeWithColony) { TradeUtility.CheckInteractWithTradersTeachOpportunity(pawn); } if (meleeThreat != null && !MeleeThreatStillThreat) { meleeThreat = null; } mentalStateHandler.MentalStateHandlerTick(); mentalBreaker.MentalBreakerTick(); inspirationHandler.InspirationHandlerTick(); if (!pawn.GetPosture().Laying()) { applyBedThoughtsTick = 0; } if (pawn.IsHashIntervalTick(100)) { if (pawn.Spawned) { int regionsToScan = (!anyCloseHostilesRecently) ? 18 : 24; anyCloseHostilesRecently = PawnUtility.EnemiesAreNearby(pawn, regionsToScan, passDoors: true); } else { anyCloseHostilesRecently = false; } } if (WillJoinColonyIfRescued && AnythingPreventsJoiningColonyIfRescued) { WillJoinColonyIfRescued = false; } if (pawn.Spawned && pawn.IsWildMan() && !WildManEverReachedOutside && pawn.GetRoom() != null && pawn.GetRoom().TouchesMapEdge) { WildManEverReachedOutside = true; } if (Find.TickManager.TicksGame % 123 == 0 && pawn.Spawned && pawn.RaceProps.IsFlesh && pawn.needs.mood != null) { TerrainDef terrain = pawn.Position.GetTerrain(pawn.Map); if (terrain.traversedThought != null) { pawn.needs.mood.thoughts.memories.TryGainMemoryFast(terrain.traversedThought); } WeatherDef curWeatherLerped = pawn.Map.weatherManager.CurWeatherLerped; if (curWeatherLerped.exposedThought != null && !pawn.Position.Roofed(pawn.Map)) { pawn.needs.mood.thoughts.memories.TryGainMemoryFast(curWeatherLerped.exposedThought); } } if (GenLocalDate.DayTick(pawn) == 0) { interactionsToday = 0; } }
public static bool MindStateTick(Pawn_MindState __instance) { if (__instance.wantsToTradeWithColony) { TradeUtility.CheckInteractWithTradersTeachOpportunity(__instance.pawn); } if (__instance.meleeThreat != null && !__instance.MeleeThreatStillThreat) { __instance.meleeThreat = null; } __instance.mentalStateHandler.MentalStateHandlerTick(); __instance.mentalBreaker.MentalBreakerTick(); __instance.inspirationHandler.InspirationHandlerTick(); if (!__instance.pawn.GetPosture().Laying()) { __instance.applyBedThoughtsTick = 0; } if (__instance.pawn.IsHashIntervalTick(100)) { __instance.anyCloseHostilesRecently = __instance.pawn.Spawned && PawnUtility.EnemiesAreNearby(__instance.pawn, __instance.anyCloseHostilesRecently ? 24 : 18, true); } if (__instance.WillJoinColonyIfRescued && __instance.AnythingPreventsJoiningColonyIfRescued) { __instance.WillJoinColonyIfRescued = false; } if (__instance.pawn.Spawned && __instance.pawn.IsWildMan() && (!__instance.WildManEverReachedOutside && __instance.pawn.GetRoom(RegionType.Set_Passable) != null) && __instance.pawn.GetRoom(RegionType.Set_Passable).TouchesMapEdge) { __instance.WildManEverReachedOutside = true; } if (Find.TickManager.TicksGame % 123 == 0 && __instance.pawn.Spawned && (__instance.pawn.RaceProps.IsFlesh && __instance.pawn.needs.mood != null)) { TerrainDef terrain = __instance.pawn.Position.GetTerrain(__instance.pawn.Map); if (terrain.traversedThought != null) { __instance.pawn.needs.mood.thoughts.memories.TryGainMemoryFast(terrain.traversedThought); } WeatherDef curWeatherLerped = __instance.pawn.Map.weatherManager.CurWeatherLerped; if (curWeatherLerped.exposedThought != null && !__instance.pawn.Position.Roofed(__instance.pawn.Map)) { __instance.pawn.needs.mood.thoughts.memories.TryGainMemoryFast(curWeatherLerped.exposedThought); } } //dirty hack for easy speedup - i'm sure this breaks things like pawn conversation interval. //if (GenLocalDate.DayTick((Thing)__instance.pawn) != 0) // return; __instance.interactionsToday = 0; return(false); }
public void MindStateTick() { if (this.wantsToTradeWithColony) { TradeUtility.CheckInteractWithTradersTeachOpportunity(this.pawn); } if (this.meleeThreat != null && !this.MeleeThreatStillThreat) { this.meleeThreat = null; } this.mentalStateHandler.MentalStateHandlerTick(); this.mentalBreaker.MentalBreakerTick(); this.inspirationHandler.InspirationHandlerTick(); if (this.pawn.CurJob == null || this.pawn.jobs.curDriver.layingDown == LayingDownState.NotLaying) { this.applyBedThoughtsTick = 0; } if (this.pawn.IsHashIntervalTick(100)) { if (this.pawn.Spawned) { int regionsToScan = (!this.anyCloseHostilesRecently) ? 18 : 24; this.anyCloseHostilesRecently = PawnUtility.EnemiesAreNearby(this.pawn, regionsToScan, true); } else { this.anyCloseHostilesRecently = false; } } if (this.willJoinColonyIfRescued && this.pawn.Spawned && this.pawn.IsHashIntervalTick(30)) { if (this.pawn.Faction == Faction.OfPlayer) { this.willJoinColonyIfRescued = false; } else if (this.pawn.CanReachMapEdge()) { foreach (Pawn current in this.pawn.Map.mapPawns.FreeColonistsSpawned) { if (current.IsColonistPlayerControlled) { this.PrisonerRescued(current); break; } } } else { Room room = this.pawn.GetRoom(RegionType.Set_Passable); if (room != null) { List <Thing> containedAndAdjacentThings = room.ContainedAndAdjacentThings; for (int i = 0; i < containedAndAdjacentThings.Count; i++) { Pawn pawn = containedAndAdjacentThings[i] as Pawn; if (pawn != null && pawn.IsColonistPlayerControlled) { this.PrisonerRescued(pawn); break; } } } } } if (this.pawn.Spawned && this.pawn.IsWildMan() && !this.wildManEverReachedOutside && this.pawn.GetRoom(RegionType.Set_Passable) != null && this.pawn.GetRoom(RegionType.Set_Passable).TouchesMapEdge) { this.wildManEverReachedOutside = true; this.pawn.Map.reachability.ClearCache(); } }
public void MindStateTick() { if (this.wantsToTradeWithColony) { TradeUtility.CheckInteractWithTradersTeachOpportunity(this.pawn); } if (this.meleeThreat != null && !this.MeleeThreatStillThreat) { this.meleeThreat = null; } this.mentalStateHandler.MentalStateHandlerTick(); this.mentalBreaker.MentalBreakerTick(); this.inspirationHandler.InspirationHandlerTick(); if (!this.pawn.GetPosture().Laying()) { this.applyBedThoughtsTick = 0; } if (this.pawn.IsHashIntervalTick(100)) { if (this.pawn.Spawned) { int regionsToScan = (!this.anyCloseHostilesRecently) ? 18 : 24; this.anyCloseHostilesRecently = PawnUtility.EnemiesAreNearby(this.pawn, regionsToScan, true); } else { this.anyCloseHostilesRecently = false; } } if (this.WillJoinColonyIfRescued && this.pawn.Spawned && this.pawn.IsHashIntervalTick(30)) { if (this.pawn.Faction == Faction.OfPlayer) { this.WillJoinColonyIfRescued = false; } else if (this.pawn.IsPrisoner && !this.pawn.HostFaction.HostileTo(Faction.OfPlayer)) { this.WillJoinColonyIfRescued = false; } else if (!this.pawn.IsPrisoner && this.pawn.Faction != null && this.pawn.Faction.HostileTo(Faction.OfPlayer) && !this.pawn.Downed) { this.WillJoinColonyIfRescued = false; } else { foreach (Pawn pawn in this.pawn.Map.mapPawns.FreeColonistsSpawned) { if (pawn.IsColonistPlayerControlled && pawn.Position.InHorDistOf(this.pawn.Position, 4f) && GenSight.LineOfSight(this.pawn.Position, pawn.Position, this.pawn.Map, false, null, 0, 0)) { this.JoinColonyBecauseRescuedBy(pawn); break; } } } } if (this.pawn.Spawned && this.pawn.IsWildMan() && !this.WildManEverReachedOutside && this.pawn.GetRoom(RegionType.Set_Passable) != null && this.pawn.GetRoom(RegionType.Set_Passable).TouchesMapEdge) { this.WildManEverReachedOutside = true; } if (Find.TickManager.TicksGame % 123 == 0 && this.pawn.Spawned && this.pawn.RaceProps.IsFlesh && this.pawn.needs.mood != null) { TerrainDef terrain = this.pawn.Position.GetTerrain(this.pawn.Map); if (terrain.traversedThought != null) { this.pawn.needs.mood.thoughts.memories.TryGainMemoryFast(terrain.traversedThought); } WeatherDef curWeatherLerped = this.pawn.Map.weatherManager.CurWeatherLerped; if (curWeatherLerped.exposedThought != null && !this.pawn.Position.Roofed(this.pawn.Map)) { this.pawn.needs.mood.thoughts.memories.TryGainMemoryFast(curWeatherLerped.exposedThought); } } if (GenLocalDate.DayTick(this.pawn) == 0) { this.interactionsToday = 0; } }
static bool Prefix(Pawn_MindState __instance) { if (!__instance.pawn.NonHumanlikeOrWildMan() && (UmbrellaDefMethods.HasUmbrella(__instance.pawn) || (RimbrellasMod.settings.cowboyHatsPreventSoakingWet && UmbrellaDefMethods.HasCowboyHat(__instance.pawn)))) { if (__instance.wantsToTradeWithColony) { TradeUtility.CheckInteractWithTradersTeachOpportunity(__instance.pawn); } if (__instance.meleeThreat != null && !__instance.MeleeThreatStillThreat) { __instance.meleeThreat = null; } __instance.mentalStateHandler.MentalStateHandlerTick(); __instance.mentalBreaker.MentalBreakerTick(); __instance.inspirationHandler.InspirationHandlerTick(); if (!__instance.pawn.GetPosture().Laying()) { __instance.applyBedThoughtsTick = 0; } if (__instance.pawn.IsHashIntervalTick(100)) { if (__instance.pawn.Spawned) { int regionsToScan = __instance.anyCloseHostilesRecently ? 24 : 18; __instance.anyCloseHostilesRecently = PawnUtility.EnemiesAreNearby(__instance.pawn, regionsToScan, passDoors: true); } else { __instance.anyCloseHostilesRecently = false; } } if (__instance.WillJoinColonyIfRescued && __instance.AnythingPreventsJoiningColonyIfRescued) { __instance.WillJoinColonyIfRescued = false; } if (__instance.pawn.Spawned && __instance.pawn.IsWildMan() && !__instance.WildManEverReachedOutside && __instance.pawn.GetRoom() != null && __instance.pawn.GetRoom().TouchesMapEdge) { __instance.WildManEverReachedOutside = true; } if (Find.TickManager.TicksGame % 123 == 0 && __instance.pawn.Spawned && __instance.pawn.RaceProps.IsFlesh && __instance.pawn.needs.mood != null) { __instance.pawn.Drawer.renderer.graphics.ResolveAllGraphics(); TerrainDef terrain = __instance.pawn.Position.GetTerrain(__instance.pawn.Map); if (terrain.traversedThought != null) { __instance.pawn.needs.mood.thoughts.memories.TryGainMemoryFast(terrain.traversedThought); } /*WeatherDef curWeatherLerped = __instance.pawn.Map.weatherManager.CurWeatherLerped; * if (curWeatherLerped.exposedThought != null && !__instance.pawn.Position.Roofed(__instance.pawn.Map)) { * __instance.pawn.needs.mood.thoughts.memories.TryGainMemoryFast(curWeatherLerped.exposedThought); * }*///this code would assign the Soaking Wet thought to a pawn outside in the rain, but we've already checked that the pawn has an umbrella } if (GenLocalDate.DayTick(__instance.pawn) == 0) { __instance.interactionsToday = 0; } return(false); } return(true); }