示例#1
0
        private void StartRandomFire()
        {
            IntVec3 c = (from x in GenRadial.RadialCellsAround(base.Position, 25f, true)
                         where x.InBounds(base.Map)
                         select x).RandomElement <IntVec3>();

            FireUtility.TryStartFireIn(c, base.Map, Rand.Range(0.1f, 0.925f));
        }
示例#2
0
        private void StartRandomFire()
        {
            IntVec3 c = (from x in GenRadial.RadialCellsAround(base.Position, 25f, true)
                         where x.InBounds(base.Map)
                         select x).RandomElementByWeight((IntVec3 x) => Bombardment.DistanceChanceFactor.Evaluate(x.DistanceTo(base.Position)));

            FireUtility.TryStartFireIn(c, base.Map, Rand.Range(0.1f, 0.925f));
        }
示例#3
0
        protected override bool TryCastShot()
        {
            Thing thing      = base.currentTarget.Thing;
            Pawn  casterPawn = base.CasterPawn;

            FireUtility.TryStartFireIn(thing.OccupiedRect().ClosestCellTo(casterPawn.Position), casterPawn.Map, 0.3f);
            casterPawn.Drawer.Notify_MeleeAttackOn(thing);
            return(true);
        }
示例#4
0
        public static bool TryStartFireIn(IntVec3 c, Map map, float fireSize)
        {
            float num = FireUtility.ChanceToStartFireIn(c, map);

            if (num <= 0.0)
            {
                return(false);
            }
            Fire fire = (Fire)ThingMaker.MakeThing(ThingDefOf.Fire, null);

            fire.fireSize = fireSize;
            GenSpawn.Spawn(fire, c, map, Rot4.North, false);
            return(true);
        }
示例#5
0
        private static bool TryStartFireNear(Building b)
        {
            ShortCircuitUtility.tmpCells.Clear();
            int      num       = GenRadial.NumCellsInRadius(3f);
            CellRect startRect = b.OccupiedRect();

            for (int i = 0; i < num; i++)
            {
                IntVec3 intVec = b.Position + GenRadial.RadialPattern[i];
                if (GenSight.LineOfSight(b.Position, intVec, b.Map, startRect, CellRect.SingleCell(intVec), null) && FireUtility.ChanceToStartFireIn(intVec, b.Map) > 0f)
                {
                    ShortCircuitUtility.tmpCells.Add(intVec);
                }
            }
            return(ShortCircuitUtility.tmpCells.Any <IntVec3>() && FireUtility.TryStartFireIn(ShortCircuitUtility.tmpCells.RandomElement <IntVec3>(), b.Map, Rand.Range(0.1f, 1.75f)));
        }
示例#6
0
 protected override void Impact(Thing hitThing)
 {
     base.Impact(hitThing);
     if (hitThing != null)
     {
         hitThing.TryIgnite(0.3f);
         GenSpawn.Spawn(ThingDef.Named("Puddle_Fuel"), base.Position);
         FireUtility.TryStartFireIn(base.Position, 0.2f);
     }
     else
     {
         GenSpawn.Spawn(ThingDef.Named("FlareDeployed"), this.Position);
     }
     MoteMaker.ThrowFlash(base.Position, "ShotFlash", 6f);
     MoteMaker.TryThrowMicroSparks(base.Position.ToVector3Shifted());
 }
示例#7
0
        protected void TrySpread()
        {
            //This method is optimized as it is a performance bottleneck (as are the sparks it spawns)

            IntVec3 targLoc = Position;
            bool    adjacent;

            if (Rand.Chance(0.8f))
            {
                targLoc  = Position + GenRadial.ManualRadialPattern[Rand.RangeInclusive(1, 8)];         //Spark adjacent
                adjacent = true;
            }
            else
            {
                targLoc  = Position + GenRadial.ManualRadialPattern[Rand.RangeInclusive(10, 20)];               //Spark distant
                adjacent = false;
            }

            if (!targLoc.InBounds(Map))
            {
                return;
            }

            if (Rand.Chance(FireUtility.ChanceToStartFireIn(targLoc, Map)))
            {
                if (!adjacent)
                {
                    var startRect = CellRect.SingleCell(Position);
                    var endRect   = CellRect.SingleCell(targLoc);

                    // don't create a spark if we'll hit a wall in our way
                    if (!GenSight.LineOfSight(Position, targLoc, Map, startRect, endRect))
                    {
                        return;
                    }

                    var sp = (Spark)GenSpawn.Spawn(ThingDefOf.Spark, Position, Map);
                    sp.Launch(this, targLoc, targLoc, ProjectileHitFlags.All);
                }
                else
                {
                    //When adjacent, skip sparks and just magically spawn fires
                    FireUtility.TryStartFireIn(targLoc, Map, Fire.MinFireSize);
                }
            }
        }
        public static bool TryStartFireIn(IntVec3 c, Map map, float fireSize)
        {
            float num = FireUtility.ChanceToStartFireIn(c, map);
            bool  result;

            if (num <= 0f)
            {
                result = false;
            }
            else
            {
                Fire fire = (Fire)ThingMaker.MakeThing(ThingDefOf.Fire, null);
                fire.fireSize = fireSize;
                GenSpawn.Spawn(fire, c, map, Rot4.North, WipeMode.Vanish, false);
                result = true;
            }
            return(result);
        }
示例#9
0
        protected void TrySpread()
        {
            IntVec3 intVec = base.Position;
            bool    flag;

            if (Rand.Chance(0.8f))
            {
                intVec = base.Position + GenRadial.ManualRadialPattern[Rand.RangeInclusive(1, 8)];
                flag   = true;
            }
            else
            {
                intVec = base.Position + GenRadial.ManualRadialPattern[Rand.RangeInclusive(10, 20)];
                flag   = false;
            }
            if (!intVec.InBounds(base.Map))
            {
                return;
            }
            if (Rand.Chance(FireUtility.ChanceToStartFireIn(intVec, base.Map)))
            {
                if (!flag)
                {
                    CellRect startRect = CellRect.SingleCell(base.Position);
                    CellRect endRect   = CellRect.SingleCell(intVec);
                    if (!GenSight.LineOfSight(base.Position, intVec, base.Map, startRect, endRect, null))
                    {
                        return;
                    }
                    Spark spark = (Spark)GenSpawn.Spawn(ThingDefOf.Spark, base.Position, base.Map);
                    spark.Launch(this, intVec, null);
                }
                else
                {
                    FireUtility.TryStartFireIn(intVec, base.Map, 0.1f);
                }
            }
        }
示例#10
0
        private void StartRandomFireAndDoFlameDamage()
        {
            IntVec3 c = (from x in GenRadial.RadialCellsAround(base.Position, 15f, useCenter: true)
                         where x.InBounds(base.Map)
                         select x).RandomElementByWeight((IntVec3 x) => 1f - Mathf.Min(x.DistanceTo(base.Position) / 15f, 1f) + 0.05f);

            FireUtility.TryStartFireIn(c, base.Map, Rand.Range(0.1f, 0.925f));
            tmpThings.Clear();
            tmpThings.AddRange(c.GetThingList(base.Map));
            for (int i = 0; i < tmpThings.Count; i++)
            {
                int  num  = (tmpThings[i] is Corpse) ? CorpseFlameDamageAmountRange.RandomInRange : FlameDamageAmountRange.RandomInRange;
                Pawn pawn = tmpThings[i] as Pawn;
                BattleLogEntry_DamageTaken battleLogEntry_DamageTaken = null;
                if (pawn != null)
                {
                    battleLogEntry_DamageTaken = new BattleLogEntry_DamageTaken(pawn, RulePackDefOf.DamageEvent_PowerBeam, instigator as Pawn);
                    Find.BattleLog.Add(battleLogEntry_DamageTaken);
                }
                tmpThings[i].TakeDamage(new DamageInfo(DamageDefOf.Flame, num, 0f, -1f, instigator, null, weaponDef)).AssociateWithLog(battleLogEntry_DamageTaken);
            }
            tmpThings.Clear();
        }
示例#11
0
 private void StartRandomFire()
 {
     FireUtility.TryStartFireIn((from x in GenRadial.RadialCellsAround(base.Position, randomFireRadius, useCenter: true)
                                 where x.InBounds(base.Map)
                                 select x).RandomElementByWeight((IntVec3 x) => DistanceChanceFactor.Evaluate(x.DistanceTo(base.Position))), base.Map, Rand.Range(0.1f, 0.925f));
 }
示例#12
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);
        }
示例#13
0
        // Token: 0x0600001B RID: 27 RVA: 0x000030DC File Offset: 0x000012DC
        public static Building FindBreakDownTargetFor(Pawn p)
        {
            Predicate <Thing> breakdownValidator = delegate(Thing t)
            {
                Building building2 = (Building)t;
                return(ReservationUtility.CanReserveAndReach(p, t, (PathEndMode)1, (Danger)2, 1, -1, null, false) && !building2.GetComp <CompBreakdownable>().BrokenDown&& !FireUtility.IsBurning(building2));
            };
            ThingDef thingDef = GenCollection.RandomElement <ThingDef>((from t in DefDatabase <ThingDef> .AllDefsListForReading
                                                                        where t.GetCompProperties <CompProperties_Breakdownable>() != null
                                                                        select t).ToList <ThingDef>());
            Predicate <Thing> predicate = (Thing b) => breakdownValidator(b);
            Building          building  = (Building)GenClosest.ClosestThingReachable(p.Position, p.Map, ThingRequest.ForDef(thingDef), (PathEndMode)1, TraverseParms.For(p, (Danger)3, 0, false), 9999f, predicate, null, 0, -1, false, (RegionType)6, false);

            if (building != null)
            {
                return(building);
            }
            return(null);
        }
        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);
        }
        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 > 0.0)
                {
                    this.map.snowGrid.AddDepth(c, (float)(0.0 - this.outdoorMeltAmount));
                }
                if (!flag && this.snowRate > 0.0010000000474974513)
                {
                    this.AddFallenSnowAt(c, (float)(0.046000000089406967 * this.map.weatherManager.SnowRate));
                }
            }
            if (room != null)
            {
                if (flag2)
                {
                    if (!flag)
                    {
                        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 (thing.def.filth.rainWashes && Rand.Value < this.rainRate)
                                {
                                    ((Filth)thing).ThinFilth();
                                }
                            }
                            else
                            {
                                Corpse corpse = thing as Corpse;
                                if (corpse != null && corpse.InnerPawn.apparel != null)
                                {
                                    List <Apparel> wornApparel = corpse.InnerPawn.apparel.WornApparel;
                                    for (int j = 0; j < wornApparel.Count; j++)
                                    {
                                        this.TryDoDeteriorate(wornApparel[j], c, false);
                                    }
                                }
                                this.TryDoDeteriorate(thing, c, true);
                            }
                        }
                    }
                }
                else
                {
                    float temperature = room.Temperature;
                    if (temperature > 0.0)
                    {
                        float num = this.MeltAmountAt(temperature);
                        if (num > 0.0)
                        {
                            this.map.snowGrid.AddDepth(c, (float)(0.0 - num));
                        }
                        if (room.RegionType.Passable())
                        {
                            float      num2 = temperature;
                            FloatRange autoIgnitionTemperatureRange = SteadyAtmosphereEffects.AutoIgnitionTemperatureRange;
                            if (num2 > autoIgnitionTemperatureRange.min)
                            {
                                float value = Rand.Value;
                                if (value < SteadyAtmosphereEffects.AutoIgnitionTemperatureRange.InverseLerpThroughRange(temperature) * 0.699999988079071 && Rand.Chance(FireUtility.ChanceToStartFireIn(c, this.map)))
                                {
                                    FireUtility.TryStartFireIn(c, this.map, 0.1f);
                                }
                                if (value < 0.33000001311302185)
                                {
                                    MoteMaker.ThrowHeatGlow(c, this.map, 2.3f);
                                }
                            }
                        }
                    }
                }
            }
            List <GameCondition> activeConditions = this.map.gameConditionManager.ActiveConditions;

            for (int k = 0; k < activeConditions.Count; k++)
            {
                activeConditions[k].DoCellSteadyEffects(c);
            }
        }
示例#16
0
        private void DoComplexCalcs()
        {
            bool flag = false;

            flammableList.Clear();
            flammabilityMax = 0f;
            if (!base.Position.GetTerrain(base.Map).extinguishesFire)
            {
                if (parent == null)
                {
                    if (base.Position.TerrainFlammableNow(base.Map))
                    {
                        flammabilityMax = base.Position.GetTerrain(base.Map).GetStatValueAbstract(StatDefOf.Flammability);
                    }
                    List <Thing> list = base.Map.thingGrid.ThingsListAt(base.Position);
                    for (int i = 0; i < list.Count; i++)
                    {
                        Thing thing = list[i];
                        if (thing is Building_Door)
                        {
                            flag = true;
                        }
                        float statValue = thing.GetStatValue(StatDefOf.Flammability);
                        if (!(statValue < 0.01f))
                        {
                            flammableList.Add(list[i]);
                            if (statValue > flammabilityMax)
                            {
                                flammabilityMax = statValue;
                            }
                            if (parent == null && fireSize > 0.4f && list[i].def.category == ThingCategory.Pawn && Rand.Chance(FireUtility.ChanceToAttachFireCumulative(list[i], 150f)))
                            {
                                list[i].TryAttachFire(fireSize * 0.2f);
                            }
                        }
                    }
                }
                else
                {
                    flammableList.Add(parent);
                    flammabilityMax = parent.GetStatValue(StatDefOf.Flammability);
                }
            }
            if (flammabilityMax < 0.01f)
            {
                Destroy();
                return;
            }
            Thing thing2 = ((parent != null) ? parent : ((flammableList.Count <= 0) ? null : flammableList.RandomElement()));

            if (thing2 != null && (!(fireSize < 0.4f) || thing2 == parent || thing2.def.category != ThingCategory.Pawn))
            {
                DoFireDamage(thing2);
            }
            if (base.Spawned)
            {
                float num = fireSize * 160f;
                if (flag)
                {
                    num *= 0.15f;
                }
                GenTemperature.PushHeat(base.Position, base.Map, num);
                if (Rand.Value < 0.4f)
                {
                    float radius = fireSize * 3f;
                    SnowUtility.AddSnowRadial(base.Position, base.Map, radius, 0f - fireSize * 0.1f);
                }
                fireSize += 0.00055f * flammabilityMax * 150f;
                if (fireSize > 1.75f)
                {
                    fireSize = 1.75f;
                }
                if (base.Map.weatherManager.RainRate > 0.01f && VulnerableToRain() && Rand.Value < 6f)
                {
                    TakeDamage(new DamageInfo(DamageDefOf.Extinguish, 10f));
                }
            }
        }