示例#1
0
 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;
     }
 }
        private static bool MindStateTick(Pawn_MindState __instance)
        {
            if (Find.TickManager.TicksGame % 123 == 0)
            {
                return(true);
            }

            bool callOrig = __instance.pawn.IsHashIntervalTick(5);

            if (!callOrig && GenLocalDate.DayTick(__instance.pawn) == 0)
            {
                __instance.interactionsToday = 0;
            }

            return(callOrig);
        }
示例#3
0
 static void Postfix(ref Plant __instance)
 {
     if (!__instance.Destroyed && __instance.HitPoints < __instance.MaxHitPoints && !__instance.Dying)
     {
         int d = GenLocalDate.DayTick(__instance.Map) / 2000;
         if (d == 0)
         {
             __instance.HitPoints += 1;
         }
         if (__instance.GrowthRateFactor_Fertility > 1.5f && (d == 10 || d == 20))
         {
             __instance.HitPoints += 1;
         }
         else if (__instance.GrowthRateFactor_Fertility > 1f && d == 15)
         {
             __instance.HitPoints += 1;
         }
     }
 }
 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);
        }