Ejemplo n.º 1
0
        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.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();
                }
            }
        }
Ejemplo n.º 3
0
        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 ThinCarriedFilth(Filth f)
 {
     f.ThinFilth();
     if (f.thickness <= 0)
     {
         this.carriedFilth.Remove(f);
     }
 }
        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));
        }
Ejemplo n.º 6
0
        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);
        }
        private void DoCellSteadyEffects(IntVec3 c)
        {
            Room room  = c.GetRoom(this.map, RegionType.Set_All);
            bool flag  = this.map.roofGrid.Roofed(c);
            bool flag2 = room != null && room.UsesOutdoorTemperature;

            if (room == null || flag2)
            {
                if (this.outdoorMeltAmount > 0f)
                {
                    this.map.snowGrid.AddDepth(c, -this.outdoorMeltAmount);
                }
                if (!flag && this.snowRate > 0.001f)
                {
                    this.AddFallenSnowAt(c, 0.046f * this.map.weatherManager.SnowRate);
                }
            }
            if (room != null)
            {
                bool         protectedByEdifice = SteadyEnvironmentEffects.ProtectedByEdifice(c, this.map);
                TerrainDef   terrain            = c.GetTerrain(this.map);
                List <Thing> thingList          = c.GetThingList(this.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(this.rainRate))
                        {
                            filth.ThinFilth();
                        }
                    }
                    else
                    {
                        this.TryDoDeteriorate(thing, flag, flag2, protectedByEdifice, terrain);
                    }
                }
                if (!flag2)
                {
                    float temperature = room.Temperature;
                    if (temperature > 0f)
                    {
                        float num = this.MeltAmountAt(temperature);
                        if (num > 0f)
                        {
                            this.map.snowGrid.AddDepth(c, -num);
                        }
                        if (room.RegionType.Passable() && temperature > SteadyEnvironmentEffects.AutoIgnitionTemperatureRange.min)
                        {
                            float value = Rand.Value;
                            if (value < SteadyEnvironmentEffects.AutoIgnitionTemperatureRange.InverseLerpThroughRange(temperature) * 0.7f && Rand.Chance(FireUtility.ChanceToStartFireIn(c, this.map)))
                            {
                                FireUtility.TryStartFireIn(c, this.map, 0.1f);
                            }
                            if (value < 0.33f)
                            {
                                MoteMaker.ThrowHeatGlow(c, this.map, 2.3f);
                            }
                        }
                    }
                }
            }
            this.map.gameConditionManager.DoSteadyEffects(c, this.map);
        }