Esempio n. 1
0
        static void Postfix(Pawn_FilthTracker __instance)
        {
            // A copy of the normal human-like filth generation, only with a much higher chance to generate filth.
            Pawn pawn = AccessTools.Field(typeof(Pawn_FilthTracker), "pawn").GetValue(__instance) as Pawn;

            if (pawn?.story?.traits?.HasTrait(GMT_DefOf.GMT_Slob) ?? false)
            {
                if (Rand.Value < PawnUtility.HumanFilthChancePerCell(pawn.def, pawn.BodySize) * GMT_Slob_Helper.slob_factor)
                {
                    ThingDef filth_Trash;
                    ThingDef lastTerrainFilthDef = AccessTools.Field(typeof(Pawn_FilthTracker), "lastTerrainFilthDef").GetValue(__instance) as ThingDef;
                    if (lastTerrainFilthDef != null && Rand.Chance(0.66f))
                    {
                        filth_Trash = lastTerrainFilthDef;
                    }
                    else
                    {
                        filth_Trash = ThingDefOf.Filth_Trash;
                    }
                    if (FilthMaker.TryMakeFilth(pawn.Position, pawn.Map, filth_Trash, 1, (FilthSourceFlags)AccessTools.Method(typeof(Pawn_FilthTracker), "get_AdditionalFilthSourceFlags").Invoke(__instance, null)))
                    {
                        AccessTools.TypeByName("RimWorld.FilthMonitor").GetMethod("Notify_FilthHumanGenerated").Invoke(null, null);
                    }
                }
            }
        }