예제 #1
0
        public static void TrySpread(IntVec3 srcPos, Map map)
        {
            IntVec3 position = srcPos;
            bool    flag;

            if (Rand.Chance(0.8f))
            {
                position = srcPos + GenRadial.ManualRadialPattern[Rand.RangeInclusive(1, 8)];
                flag     = true;
            }
            else
            {
                position = srcPos + GenRadial.ManualRadialPattern[Rand.RangeInclusive(10, 20)];
                flag     = false;
            }
            if (!position.InBounds(map) || !Rand.Chance(FireUtility.ChanceToStartFireIn(position, map)))
            {
                return;
            }
            if (!flag)
            {
                CellRect startRect = CellRect.SingleCell(srcPos);
                CellRect endRect   = CellRect.SingleCell(position);
                if (GenSight.LineOfSight(srcPos, position, map, startRect, endRect))
                {
                    ((Spark)GenSpawn.Spawn(ThingDefOf.Spark, srcPos, map)).Launch(null, position, position, ProjectileHitFlags.All);
                }
            }
            else
            {
                FireUtility.TryStartFireIn(position, map, 0.1f);
            }
        }
예제 #2
0
파일: Fire.cs 프로젝트: KiameV/RimThreaded
        public static void TrySpread(Fire __instance)
        {
            IntVec3 position = __instance.Position;
            IntVec3 intVec3;
            bool    flag;

            if (Rand.Chance(0.8f))
            {
                intVec3 = __instance.Position + GenRadial.ManualRadialPattern[Rand.RangeInclusive(1, 8)];
                flag    = true;
            }
            else
            {
                intVec3 = __instance.Position + GenRadial.ManualRadialPattern[Rand.RangeInclusive(10, 20)];
                flag    = false;
            }
            if (!intVec3.InBounds(__instance.Map) || !Rand.Chance(FireUtility.ChanceToStartFireIn(intVec3, __instance.Map)))
            {
                return;
            }
            if (!flag)
            {
                CellRect startRect = CellRect.SingleCell(__instance.Position);
                CellRect endRect   = CellRect.SingleCell(intVec3);
                if (!GenSight.LineOfSight(__instance.Position, intVec3, __instance.Map, startRect, endRect, (Func <IntVec3, bool>)null))
                {
                    return;
                }
                ((Projectile)GenSpawn.Spawn(ThingDefOf.Spark, __instance.Position, __instance.Map, WipeMode.Vanish)).Launch((Thing)__instance, (LocalTargetInfo)intVec3, (LocalTargetInfo)intVec3, ProjectileHitFlags.All, (Thing)null);
            }
            else
            {
                FireUtility.TryStartFireIn(intVec3, __instance.Map, 0.1f);
            }
        }
예제 #3
0
 public override void ExplosionAffectCell(Explosion explosion, IntVec3 c, List <Thing> damagedThings, bool canThrowMotes)
 {
     base.ExplosionAffectCell(explosion, c, damagedThings, canThrowMotes);
     if (this.def == DamageDefOf.Flame && Rand.Chance(FireUtility.ChanceToStartFireIn(c, explosion.Map)))
     {
         FireUtility.TryStartFireIn(c, explosion.Map, Rand.Range(0.2f, 0.6f));
     }
 }
        // Token: 0x06000F42 RID: 3906 RVA: 0x00057D54 File Offset: 0x00055F54
        public override void ExplosionAffectCell(Explosion explosion, IntVec3 c, List <Thing> damagedThings, List <Thing> ignoredThings, bool canThrowMotes)
        {
            base.ExplosionAffectCell(explosion, c, damagedThings, ignoredThings, canThrowMotes);
            bool fire = this.def.defName.Contains("Fire") || this.def.defName.Contains("Flame");

            if (fire && Rand.Chance(FireUtility.ChanceToStartFireIn(c, explosion.Map)))
            {
                FireUtility.TryStartFireIn(c, explosion.Map, Rand.Range(0.2f, 0.6f));
            }
        }
예제 #5
0
        //---------------------------

        new protected void TrySpread()
        {
            IntVec3 position = base.Position;
            bool    flag;

            if (Rand.Chance(0.8f))
            {
                position = base.Position + GenRadial.ManualRadialPattern[Rand.RangeInclusive(1, 8)];
                flag     = true;
            }
            else
            {
                position = base.Position + GenRadial.ManualRadialPattern[Rand.RangeInclusive(10, 20)];
                flag     = false;
            }
            if (!position.InBounds(base.Map) || !Rand.Chance(FireUtility.ChanceToStartFireIn(position, base.Map)))
            {
                return;
            }
            if (!flag)
            {
                CellRect startRect = CellRect.SingleCell(base.Position);
                CellRect endRect   = CellRect.SingleCell(position);
                if (GenSight.LineOfSight(base.Position, position, base.Map, startRect, endRect))
                {
                    if (occult)
                    {
                        ((OccultSpark)GenSpawn.Spawn(CultsDefOf.Cults_OccultSpark, base.Position, base.Map)).Launch(this, position, position, ProjectileHitFlags.All);
                    }
                    else
                    {
                        ((Spark)GenSpawn.Spawn(ThingDefOf.Spark, base.Position, base.Map)).Launch(this, position, position, ProjectileHitFlags.All);
                    }
                }
            }
            else
            {
                if (occult)
                {
                    OccultFireUtility.TryStartFireIn(position, base.Map, 0.1f);
                }
                else
                {
                    FireUtility.TryStartFireIn(position, base.Map, 0.1f);
                }
            }
        }
예제 #6
0
        protected void TrySpread()
        {
            IntVec3 intVec = base.Position;
            bool    flag;

            Rand.PushState();
            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;
            }
            Rand.PopState();
            if (!intVec.InBounds(base.Map))
            {
                return;
            }
            Rand.PushState();
            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, WipeMode.Vanish);
                    spark.Launch(this, intVec, intVec, ProjectileHitFlags.All, null);
                }
                else
                {
                    FireUtility.TryStartFireIn(intVec, base.Map, 0.1f);
                }
            }
            Rand.PopState();
        }
예제 #7
0
        protected void TrySpread()
        {
            IntVec3 intVec = base.Position;
            bool    flag;

            Rand.PushState();
            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;
            }
            Rand.PopState();
            if (!intVec.InBounds(base.Map))
            {
                return;
            }

            float chance;

            if (this.def.projectile.damageDef == AdeptusDamageDefOf.OG_Chaos_Deamon_Warpfire)
            {
                chance = WarpfireUtility.ChanceToStartWarpfireIn(intVec, base.Map);
            }
            else
            {
                chance = FireUtility.ChanceToStartFireIn(intVec, base.Map);
            }

            Rand.PushState();
            bool f = Rand.Chance(chance);

            Rand.PopState();
            if (f)
            {
                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;
                    if (this.def.projectile.damageDef == AdeptusDamageDefOf.OG_Chaos_Deamon_Warpfire)
                    {
                        spark = (Spark)GenSpawn.Spawn(AdeptusThingDefOf.OG_WarpSpark, base.Position, base.Map, WipeMode.Vanish);
                    }
                    else
                    {
                        spark = (Spark)GenSpawn.Spawn(ThingDefOf.Spark, base.Position, base.Map, WipeMode.Vanish);
                    }
                    spark.Launch(this, intVec, intVec, ProjectileHitFlags.All, false, null);
                }
                else
                {
                    if (this.def.projectile.damageDef == AdeptusDamageDefOf.OG_Chaos_Deamon_Warpfire)
                    {
                        WarpfireUtility.TryStartWarpfireIn(intVec, base.Map, 0.1f);
                    }
                    else
                    {
                        FireUtility.TryStartFireIn(intVec, base.Map, 0.1f);
                    }
                }
            }
        }
        public static void DoCellSteadyEffects(SteadyEnvironmentEffects __instance, IntVec3 c)
        {
            Map       map2      = map(__instance);
            Room      room      = c.GetRoom(map2, RegionType.Set_All);
            bool      roofed    = map2.roofGrid.Roofed(c);
            RoomGroup roomGroup = null;

            if (room != null)
            {
                roomGroup = room.Group;
            }
            bool roomUsesOutdoorTemperature = room != null && roomGroup != null && room.UsesOutdoorTemperature;

            if ((room == null) | roomUsesOutdoorTemperature)
            {
                if (outdoorMeltAmount(__instance) > 0.0)
                {
                    map2.snowGrid.AddDepth(c, -outdoorMeltAmount(__instance));
                }
                if (!roofed && snowRate(__instance) > 1.0 / 1000.0)
                {
                    AddFallenSnowAt(__instance, c, 23f / 500f * map2.weatherManager.SnowRate);
                }
            }
            if (room != null)
            {
                bool         protectedByEdifice = ProtectedByEdifice(c, map2);
                TerrainDef   terrain            = c.GetTerrain(map2);
                List <Thing> thingList          = c.GetThingList(map2);
                for (int index = 0; index < thingList.Count; ++index)
                {
                    Thing t = thingList[index];
                    if (t is Filth filth)
                    {
                        if (!roofed && t.def.filth.rainWashes && Rand.Chance(rainRate(__instance)))
                        {
                            filth.ThinFilth();
                        }
                        if (filth.DisappearAfterTicks != 0 && filth.TicksSinceThickened > filth.DisappearAfterTicks)
                        {
                            filth.Destroy(DestroyMode.Vanish);
                        }
                    }
                    else
                    {
                        TryDoDeteriorate(__instance, t, roofed, roomUsesOutdoorTemperature, protectedByEdifice, terrain);
                    }
                }
                if (!roomUsesOutdoorTemperature && roomGroup != null)
                {
                    float temperature = roomGroup.Temperature;
                    if (temperature > 0.0)
                    {
                        float num1 = MeltAmountAt(temperature);
                        if (num1 > 0.0)
                        {
                            map2.snowGrid.AddDepth(c, -num1);
                        }
                        if (room.RegionType.Passable() && temperature > (double)AutoIgnitionTemperatureRange.min)
                        {
                            double num2 = Rand.Value;
                            if (num2 < AutoIgnitionTemperatureRange.InverseLerpThroughRange(temperature) * 0.699999988079071 && Rand.Chance(FireUtility.ChanceToStartFireIn(c, map2)))
                            {
                                FireUtility.TryStartFireIn(c, map2, 0.1f);
                            }
                            if (num2 < 0.330000013113022)
                            {
                                MoteMaker.ThrowHeatGlow(c, map2, 2.3f);
                            }
                        }
                    }
                }
            }
            map2.gameConditionManager.DoSteadyEffects(c, map2);
        }
        private static bool TryStartFireNear(Building b)
        {
            GasExplosionUtility.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)
                {
                    GasExplosionUtility.tmpCells.Add(intVec);
                }
            }
            return(GasExplosionUtility.tmpCells.Any <IntVec3>() && FireUtility.TryStartFireIn(GasExplosionUtility.tmpCells.RandomElement <IntVec3>(), b.Map, Rand.Range(0.1f, 1.75f)));
        }