public void GainFilth(ThingDef filthDef, IEnumerable <string> sources) { if (filthDef.filth.terrainSourced) { lastTerrainFilthDef = filthDef; } Filth filth = null; for (int i = 0; i < carriedFilth.Count; i++) { if (carriedFilth[i].def == filthDef) { filth = carriedFilth[i]; break; } } if (filth != null) { if (filth.CanBeThickened) { filth.ThickenFilth(); filth.AddSources(sources); } } else { Filth filth2 = (Filth)ThingMaker.MakeThing(filthDef); filth2.AddSources(sources); carriedFilth.Add(filth2); } }
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(); } } }
public void Notify_FilthSpawned(Filth f) { if (map.areaManager.Home[f.Position]) { filthInHomeArea.Add(f); } }
public override bool HasJobOnThing(Pawn pawn, Thing t, bool forced = false) { if (pawn.Faction != Faction.OfPlayer) { return(false); } Filth filth = t as Filth; if (filth == null) { return(false); } if (!((Area)filth.Map.areaManager.Home)[filth.Position]) { return(false); } LocalTargetInfo target = t; if (!pawn.CanReserve(target, 1, -1, null, forced)) { return(false); } if (filth.TicksSinceThickened < this.MinTicksSinceThickened) { return(false); } return(true); }
public void Notify_HomeAreaChanged(IntVec3 c) { if (this.map.areaManager.Home[c]) { List <Thing> thingList = c.GetThingList(this.map); for (int i = 0; i < thingList.Count; i++) { Filth filth = thingList[i] as Filth; if (filth != null) { this.filthInHomeArea.Add(filth); } } } else { for (int j = this.filthInHomeArea.Count - 1; j >= 0; j--) { if (this.filthInHomeArea[j].Position == c) { this.filthInHomeArea.RemoveAt(j); } } } }
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(); } } }
private void DropCarriedFilth(Filth f) { if (FilthMaker.TryMakeFilth(pawn.Position, pawn.Map, f.def, f.sources, AdditionalFilthSourceFlags)) { ThinCarriedFilth(f); } }
public void GainFilth(ThingDef filthDef, IEnumerable <string> sources) { Filth filth = null; for (int i = 0; i < this.carriedFilth.Count; i++) { if (this.carriedFilth[i].def == filthDef) { filth = this.carriedFilth[i]; break; } } if (filth != null) { if (filth.CanBeThickened) { filth.ThickenFilth(); filth.AddSources(sources); } } else { Filth filth2 = (Filth)ThingMaker.MakeThing(filthDef, null); filth2.AddSources(sources); this.carriedFilth.Add(filth2); } }
public void GainFilth(ThingDef filthDef, IEnumerable <string> sources) { Filth filth = null; int num = 0; while (num < this.carriedFilth.Count) { if (this.carriedFilth[num].def != filthDef) { num++; continue; } filth = this.carriedFilth[num]; break; } if (filth != null) { if (filth.CanBeThickened) { filth.ThickenFilth(); filth.AddSources(sources); } } else { Filth filth2 = (Filth)ThingMaker.MakeThing(filthDef, null); filth2.AddSources(sources); this.carriedFilth.Add(filth2); } }
public void Notify_FilthSpawned(Filth f) { if (((Area)this.map.areaManager.Home)[f.Position]) { this.filthInHomeArea.Add(f); } }
public override bool HasJobOnThing(Pawn pawn, Thing t, bool forced = false) { bool result; if (pawn.Faction != Faction.OfPlayer) { result = false; } else { Filth filth = t as Filth; if (filth == null) { result = false; } else if (!filth.Map.areaManager.Home[filth.Position]) { result = false; } else { LocalTargetInfo target = t; result = (pawn.CanReserve(target, 1, -1, null, forced) && filth.TicksSinceThickened >= this.MinTicksSinceThickened); } } return(result); }
public void Notify_HomeAreaChanged(IntVec3 c) { if (map.areaManager.Home[c]) { List <Thing> thingList = c.GetThingList(map); for (int i = 0; i < thingList.Count; i++) { Filth filth = thingList[i] as Filth; if (filth != null) { filthInHomeArea.Add(filth); } } } else { for (int num = filthInHomeArea.Count - 1; num >= 0; num--) { if (filthInHomeArea[num].Position == c) { filthInHomeArea.RemoveAt(num); } } } }
private void TryPickupFilth() { TerrainDef terrDef = this.pawn.Map.terrainGrid.TerrainAt(this.pawn.Position); if (terrDef.terrainFilthDef != null) { for (int num = this.carriedFilth.Count - 1; num >= 0; num--) { if (this.carriedFilth[num].def.filth.terrainSourced && this.carriedFilth[num].def != terrDef.terrainFilthDef) { this.ThinCarriedFilth(this.carriedFilth[num]); } } Filth filth = (from f in this.carriedFilth where f.def == terrDef.terrainFilthDef select f).FirstOrDefault(); if (filth == null || filth.thickness < 1) { this.GainFilth(terrDef.terrainFilthDef); } } List <Thing> thingList = this.pawn.Position.GetThingList(this.pawn.Map); for (int num2 = thingList.Count - 1; num2 >= 0; num2--) { Filth filth2 = thingList[num2] as Filth; if (filth2 != null && filth2.CanFilthAttachNow) { this.GainFilth(filth2.def, filth2.sources); filth2.ThinFilth(); } } }
private void ThinCarriedFilth(Filth f) { f.ThinFilth(); if (f.thickness <= 0) { this.carriedFilth.Remove(f); } }
public void Notify_FilthDespawned(Filth f) { for (int i = 0; i < filthInHomeArea.Count; i++) { if (filthInHomeArea[i] == f) { filthInHomeArea.RemoveAt(i); break; } } }
public void Notify_FilthDespawned(Filth f) { for (int i = 0; i < this.filthInHomeArea.Count; i++) { if (this.filthInHomeArea[i] == f) { this.filthInHomeArea.RemoveAt(i); return; } } }
protected override IEnumerable <Toil> MakeNewToils() { Toil initExtractTargetFromQueue = Toils_JobTransforms.ClearDespawnedNullOrForbiddenQueuedTargets(TargetIndex.A); yield return(initExtractTargetFromQueue); yield return(Toils_JobTransforms.SucceedOnNoTargetInQueue(TargetIndex.A)); yield return(Toils_JobTransforms.ExtractNextTargetFromQueue(TargetIndex.A)); yield return(Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.Touch).JumpIfDespawnedOrNullOrForbidden(TargetIndex.A, initExtractTargetFromQueue).JumpIfOutsideHomeArea(TargetIndex.A, initExtractTargetFromQueue)); Toil clean = new Toil(); clean.initAction = delegate { cleaningWorkDone = 0f; totalCleaningWorkDone = 0f; totalCleaningWorkRequired = Filth.def.filth.cleaningWorkToReduceThickness * (float)Filth.thickness; }; clean.tickAction = delegate { Filth filth = Filth; cleaningWorkDone += 1f; totalCleaningWorkDone += 1f; if (cleaningWorkDone > filth.def.filth.cleaningWorkToReduceThickness) { filth.ThinFilth(); cleaningWorkDone = 0f; if (filth.Destroyed) { clean.actor.records.Increment(RecordDefOf.MessesCleaned); ReadyForNextToil(); } } }; clean.defaultCompleteMode = ToilCompleteMode.Never; clean.WithEffect(EffecterDefOf.Clean, TargetIndex.A); clean.WithProgressBar(TargetIndex.A, () => totalCleaningWorkDone / totalCleaningWorkRequired, interpolateBetweenActorAndTarget: true); clean.PlaySustainerOrSound(delegate { ThingDef def = Filth.def; return((!def.filth.cleaningSound.NullOrUndefined()) ? def.filth.cleaningSound : SoundDefOf.Interact_CleanFilth); }); clean.JumpIfDespawnedOrNullOrForbidden(TargetIndex.A, initExtractTargetFromQueue); clean.JumpIfOutsideHomeArea(TargetIndex.A, initExtractTargetFromQueue); yield return(clean); yield return(Toils_Jump.Jump(initExtractTargetFromQueue)); }
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 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 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); }
public override bool HasJobOnThing(Pawn pawn, Thing t) { if (pawn.Faction != Faction.OfColony) { return(false); } RimWorld.Filth filth = t as RimWorld.Filth; if (filth == null) { return(false); } if (!Find.AreaCleaning[filth.Position] || !ReservationUtility.CanReserveAndReach(pawn, t, PathEndMode.ClosestTouch, DangerUtility.NormalMaxDanger(pawn), 1)) { return(false); } return(filth.TicksSinceThickened >= minTicksSinceThickened); }
public void Notify_FilthDespawned(Filth f) { int num = 0; while (true) { if (num >= filthInHomeArea.Count) { return; } if (filthInHomeArea[num] == f) { break; } num++; } filthInHomeArea.RemoveAt(num); }
public static void RemoveAllFilth(IntVec3 c, Map map) { FilthMaker.toBeRemoved.Clear(); List <Thing> thingList = c.GetThingList(map); for (int i = 0; i < thingList.Count; i++) { Filth filth = thingList[i] as Filth; if (filth != null) { FilthMaker.toBeRemoved.Add(filth); } } for (int j = 0; j < FilthMaker.toBeRemoved.Count; j++) { FilthMaker.toBeRemoved[j].Destroy(DestroyMode.Vanish); } FilthMaker.toBeRemoved.Clear(); }
public void Notify_FilthDespawned(Filth f) { int num = 0; while (true) { if (num < this.filthInHomeArea.Count) { if (this.filthInHomeArea[num] != f) { num++; continue; } break; } return; } this.filthInHomeArea.RemoveAt(num); }
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 override bool HasJobOnThing(Pawn pawn, Thing t, bool forced = false) { Filth filth = t as Filth; if (filth == null) { return(false); } if (!filth.Map.areaManager.Home[filth.Position]) { return(false); } if (!pawn.CanReserve(t, 1, -1, null, forced)) { return(false); } if (filth.TicksSinceThickened < MinTicksSinceThickened) { return(false); } return(true); }
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(); if (c.Walkable(map) && (filth == null || filth.CanBeThickened)) { if (filth != null) { filth.ThickenFilth(); filth.AddSources(sources); } else { Filth filth2 = (Filth)ThingMaker.MakeThing(filthDef, null); filth2.AddSources(sources); GenSpawn.Spawn(filth2, c, map); } return(true); } if (shouldPropagate) { List <IntVec3> list = GenAdj.AdjacentCells8WayRandomized(); for (int i = 0; i < 8; i++) { IntVec3 c2 = c + list[i]; if (c2.InBounds(map) && FilthMaker.MakeFilth(c2, map, filthDef, sources, false)) { return(true); } } } if (filth != null) { filth.AddSources(sources); } return(false); }
private void DropCarriedFilth(Filth f) { this.ThinCarriedFilth(f); FilthMaker.MakeFilth(this.pawn.Position, this.pawn.Map, f.def, f.sources); }
private void DoCellSteadyEffects(IntVec3 c) { Room room = c.GetRoom(map, RegionType.Set_All); bool flag = map.roofGrid.Roofed(c); bool flag2 = room?.UsesOutdoorTemperature ?? false; if ((room == null) | flag2) { if (outdoorMeltAmount > 0f) { map.snowGrid.AddDepth(c, 0f - outdoorMeltAmount); } if (!flag && snowRate > 0.001f) { AddFallenSnowAt(c, 0.046f * map.weatherManager.SnowRate); } } if (room != null) { bool protectedByEdifice = ProtectedByEdifice(c, map); TerrainDef terrain = c.GetTerrain(map); List <Thing> thingList = c.GetThingList(map); for (int i = 0; i < thingList.Count; i++) { Thing thing = thingList[i]; Filth filth = thing as Filth; if (filth != null) { if (!flag && thing.def.filth.rainWashes && Rand.Chance(rainRate)) { filth.ThinFilth(); } if (filth.DisappearAfterTicks != 0 && filth.TicksSinceThickened > filth.DisappearAfterTicks) { filth.Destroy(); } } else { TryDoDeteriorate(thing, flag, flag2, protectedByEdifice, terrain); } } if (!flag2) { float temperature = room.Temperature; if (temperature > 0f) { float num = MeltAmountAt(temperature); if (num > 0f) { map.snowGrid.AddDepth(c, 0f - num); } if (room.RegionType.Passable() && temperature > AutoIgnitionTemperatureRange.min) { float value = Rand.Value; if (value < AutoIgnitionTemperatureRange.InverseLerpThroughRange(temperature) * 0.7f && Rand.Chance(FireUtility.ChanceToStartFireIn(c, map))) { FireUtility.TryStartFireIn(c, map, 0.1f); } if (value < 0.33f) { MoteMaker.ThrowHeatGlow(c, map, 2.3f); } } } } } map.gameConditionManager.DoSteadyEffects(c, map); }
internal bool <> m__0(Filth f) { return(f.def == this.terrDef.generatedFilth); }