private void TryPickupFilth() { TerrainDef terrDef = pawn.Map.terrainGrid.TerrainAt(pawn.Position); if (terrDef.generatedFilth != null) { for (int num = carriedFilth.Count - 1; num >= 0; num--) { if (carriedFilth[num].def.filth.terrainSourced && carriedFilth[num].def != terrDef.generatedFilth) { ThinCarriedFilth(carriedFilth[num]); } } Filth filth = (from f in carriedFilth where f.def == terrDef.generatedFilth select f).FirstOrDefault(); if (filth == null || filth.thickness < 1) { GainFilth(terrDef.generatedFilth); FilthMonitor.Notify_FilthAccumulated(); } } List <Thing> thingList = pawn.Position.GetThingList(pawn.Map); for (int num2 = thingList.Count - 1; num2 >= 0; num2--) { Filth filth2 = thingList[num2] as Filth; if (filth2 != null && filth2.CanFilthAttachNow) { GainFilth(filth2.def, filth2.sources); filth2.ThinFilth(); } } }
private void TryPickupFilth() { TerrainDef terrDef = this.pawn.Map.terrainGrid.TerrainAt(this.pawn.Position); if (terrDef.generatedFilth != null) { for (int i = this.carriedFilth.Count - 1; i >= 0; i--) { if (this.carriedFilth[i].def.filth.terrainSourced && this.carriedFilth[i].def != terrDef.generatedFilth) { this.ThinCarriedFilth(this.carriedFilth[i]); } } Filth filth = (from f in this.carriedFilth where f.def == terrDef.generatedFilth select f).FirstOrDefault <Filth>(); if (filth == null || filth.thickness < 1) { this.GainFilth(terrDef.generatedFilth); FilthMonitor.Notify_FilthAccumulated(); } } List <Thing> thingList = this.pawn.Position.GetThingList(this.pawn.Map); for (int j = thingList.Count - 1; j >= 0; j--) { Filth filth2 = thingList[j] as Filth; if (filth2 != null && filth2.CanFilthAttachNow) { this.GainFilth(filth2.def, filth2.sources); filth2.ThinFilth(); } } }
public void Notify_EnteredNewCell() { if (Rand.Value < 0.05f) { this.TryDropFilth(); } if (Rand.Value < 0.1f) { this.TryPickupFilth(); } if (!this.pawn.RaceProps.Humanlike) { if (Rand.Value < PawnUtility.AnimalFilthChancePerCell(this.pawn.def, this.pawn.BodySize) && this.pawn.Position.GetTerrain(this.pawn.Map).acceptTerrainSourceFilth) { FilthMaker.MakeFilth(this.pawn.Position, this.pawn.Map, ThingDefOf.Filth_AnimalFilth, 1); FilthMonitor.Notify_FilthAnimalGenerated(); } } else if (Rand.Value < PawnUtility.HumanFilthChancePerCell(this.pawn.def, this.pawn.BodySize) && this.pawn.Position.GetTerrain(this.pawn.Map).acceptTerrainSourceFilth) { ThingDef filth_Trash; if (this.lastTerrainFilthDef != null && Rand.Chance(0.66f)) { filth_Trash = this.lastTerrainFilthDef; } else { filth_Trash = ThingDefOf.Filth_Trash; } FilthMaker.MakeFilth(this.pawn.Position, this.pawn.Map, filth_Trash, 1); FilthMonitor.Notify_FilthHumanGenerated(); } }
private void TryDropFilth() { if (carriedFilth.Count != 0) { for (int num = carriedFilth.Count - 1; num >= 0; num--) { Filth filth = carriedFilth[num]; if (filth.CanDropAt(pawn.Position, pawn.Map)) { DropCarriedFilth(carriedFilth[num]); FilthMonitor.Notify_FilthDropped(); } } } }
private void TryDropFilth() { if (this.carriedFilth.Count != 0) { for (int i = this.carriedFilth.Count - 1; i >= 0; i--) { Filth filth = this.carriedFilth[i]; if (filth.CanDropAt(this.pawn.Position, this.pawn.Map)) { this.DropCarriedFilth(this.carriedFilth[i]); FilthMonitor.Notify_FilthDropped(); } } } }
private static bool MakeFilth(IntVec3 c, Map map, ThingDef filthDef, IEnumerable <string> sources, bool shouldPropagate) { Filth filth = (Filth)(from t in c.GetThingList(map) where t.def == filthDef select t).FirstOrDefault <Thing>(); bool result; if (!c.Walkable(map) || (filth != null && !filth.CanBeThickened)) { if (shouldPropagate) { List <IntVec3> list = GenAdj.AdjacentCells8WayRandomized(); for (int i = 0; i < 8; i++) { IntVec3 c2 = c + list[i]; if (c2.InBounds(map)) { if (FilthMaker.MakeFilth(c2, map, filthDef, sources, false)) { return(true); } } } } if (filth != null) { filth.AddSources(sources); } result = false; } else { if (filth != null) { filth.ThickenFilth(); filth.AddSources(sources); } else { Filth filth2 = (Filth)ThingMaker.MakeThing(filthDef, null); filth2.AddSources(sources); GenSpawn.Spawn(filth2, c, map, WipeMode.Vanish); } FilthMonitor.Notify_FilthSpawned(); result = true; } return(result); }
private static bool TryMakeFilth(IntVec3 c, Map map, ThingDef filthDef, IEnumerable <string> sources, bool shouldPropagate, FilthSourceFlags additionalFlags = FilthSourceFlags.None) { Filth filth = (Filth)(from t in c.GetThingList(map) where t.def == filthDef select t).FirstOrDefault(); if (!c.Walkable(map) || (filth != null && !filth.CanBeThickened)) { if (shouldPropagate) { List <IntVec3> list = GenAdj.AdjacentCells8WayRandomized(); for (int i = 0; i < 8; i++) { IntVec3 c2 = c + list[i]; if (c2.InBounds(map) && TryMakeFilth(c2, map, filthDef, sources, shouldPropagate: false)) { return(true); } } } filth?.AddSources(sources); return(false); } if (filth != null) { filth.ThickenFilth(); filth.AddSources(sources); } else { if (!CanMakeFilth(c, map, filthDef, additionalFlags)) { return(false); } Filth obj = (Filth)ThingMaker.MakeThing(filthDef); obj.AddSources(sources); GenSpawn.Spawn(obj, c, map); } FilthMonitor.Notify_FilthSpawned(); return(true); }
public void Notify_EnteredNewCell() { if (Rand.Value < 0.05f) { TryDropFilth(); } if (Rand.Value < 0.1f) { TryPickupFilth(); } if (!pawn.RaceProps.Humanlike) { if (Rand.Value < PawnUtility.AnimalFilthChancePerCell(pawn.def, pawn.BodySize) && FilthMaker.TryMakeFilth(pawn.Position, pawn.Map, ThingDefOf.Filth_AnimalFilth, 1, AdditionalFilthSourceFlags)) { FilthMonitor.Notify_FilthAnimalGenerated(); } } else if (Rand.Value < PawnUtility.HumanFilthChancePerCell(pawn.def, pawn.BodySize) && FilthMaker.TryMakeFilth(filthDef: (lastTerrainFilthDef == null || !Rand.Chance(0.66f)) ? ThingDefOf.Filth_Trash : lastTerrainFilthDef, c: pawn.Position, map: pawn.Map, count: 1, additionalFlags: AdditionalFilthSourceFlags)) { FilthMonitor.Notify_FilthHumanGenerated(); } }