Пример #1
0
        public static void DoFireDamage(Fire __instance, Thing targ)
        {
            int num = GenMath.RoundRandom(Mathf.Clamp((float)(0.0125000001862645 + 0.00359999993816018 * (double)__instance.fireSize), 0.0125f, 0.05f) * 150f);

            if (num < 1)
            {
                num = 1;
            }
            if (targ is Pawn recipient)
            {
                BattleLogEntry_DamageTaken entryDamageTaken = new BattleLogEntry_DamageTaken(recipient, RulePackDefOf.DamageEvent_Fire, (Pawn)null);
                Find.BattleLog.Add((LogEntry)entryDamageTaken);
                DamageInfo dinfo = new DamageInfo(DamageDefOf.Flame, (float)num, 0.0f, -1f, (Thing)__instance, (BodyPartRecord)null, (ThingDef)null, DamageInfo.SourceCategory.ThingOrUnknown, (Thing)null);
                dinfo.SetBodyRegion(BodyPartHeight.Undefined, BodyPartDepth.Outside);
                targ.TakeDamage(dinfo).AssociateWithLog((LogEntry_DamageResult)entryDamageTaken);
                Apparel result;
                if (recipient.apparel == null || !recipient.apparel.WornApparel.TryRandomElement <Apparel>(out result))
                {
                    return;
                }
                DamageWorker.DamageResult dresult = new DamageWorker.DamageResult();
                //result.TakeDamage(new DamageInfo(DamageDefOf.Flame, (float)num, 0.0f, -1f, (Thing)__instance, (BodyPartRecord)null, (ThingDef)null, DamageInfo.SourceCategory.ThingOrUnknown, (Thing)null));
                Thing_Patch.TakeDamage(result, ref dresult, new DamageInfo(DamageDefOf.Flame, (float)num, 0.0f, -1f, (Thing)__instance, (BodyPartRecord)null, (ThingDef)null, DamageInfo.SourceCategory.ThingOrUnknown, (Thing)null));
            }
            else
            {
                DamageWorker.DamageResult dresult = new DamageWorker.DamageResult();
                //targ.TakeDamage(new DamageInfo(DamageDefOf.Flame, (float)num, 0.0f, -1f, (Thing)__instance, (BodyPartRecord)null, (ThingDef)null, DamageInfo.SourceCategory.ThingOrUnknown, (Thing)null));
                Thing_Patch.TakeDamage(targ, ref dresult, new DamageInfo(DamageDefOf.Flame, (float)num, 0.0f, -1f, (Thing)__instance, (BodyPartRecord)null, (ThingDef)null, DamageInfo.SourceCategory.ThingOrUnknown, (Thing)null));
            }
        }
Пример #2
0
        public static bool DoComplexCalcs(Fire __instance)
        {
            bool flag = false;
            //flammableList.Clear();
            List <Thing> flammableList = new List <Thing>();

            flammabilityMax(__instance) = 0.0f;
            if (null != __instance.Map)
            {
                if (!__instance.Position.GetTerrain(__instance.Map).extinguishesFire)
                {
                    if (__instance.parent == null)
                    {
                        if (__instance.Position.TerrainFlammableNow(__instance.Map))
                        {
                            flammabilityMax(__instance) = __instance.Position.GetTerrain(__instance.Map).GetStatValueAbstract(StatDefOf.Flammability, (ThingDef)null);
                        }
                        List <Thing> thingList = __instance.Map.thingGrid.ThingsListAt(__instance.Position);
                        for (int index = 0; index < thingList.Count; ++index)
                        {
                            Thing thing = thingList[index];
                            if (thing is Building_Door)
                            {
                                flag = true;
                            }
                            float statValue = thing.GetStatValue(StatDefOf.Flammability, true);
                            if ((double)statValue >= 0.00999999977648258)
                            {
                                flammableList.Add(thingList[index]);
                                if ((double)statValue > (double)flammabilityMax(__instance))
                                {
                                    flammabilityMax(__instance) = statValue;
                                }
                                if (__instance.parent == null && (double)__instance.fireSize > 0.400000005960464 && (thingList[index].def.category == ThingCategory.Pawn && Rand.Chance(FireUtility.ChanceToAttachFireCumulative(thingList[index], 150f))))
                                {
                                    thingList[index].TryAttachFire(__instance.fireSize * 0.2f);
                                }
                            }
                        }
                    }
                    else
                    {
                        flammableList.Add(__instance.parent);
                        flammabilityMax(__instance) = __instance.parent.GetStatValue(StatDefOf.Flammability, true);
                    }
                }
                if ((double)flammabilityMax(__instance) < 0.00999999977648258)
                {
                    __instance.Destroy(DestroyMode.Vanish);
                }
                else
                {
                    Thing targ = __instance.parent == null ? (flammableList.Count <= 0 ? (Thing)null : flammableList[Rand.Range(0, flammableList.Count)]) : __instance.parent;
                    if (targ != null && ((double)__instance.fireSize >= 0.400000005960464 || targ == __instance.parent || targ.def.category != ThingCategory.Pawn))
                    {
                        DoFireDamage(__instance, targ);
                    }
                    if (!__instance.Spawned)
                    {
                        return(false);
                    }
                    float energy = __instance.fireSize * 160f;
                    if (flag)
                    {
                        energy *= 0.15f;
                    }
                    GenTemperature.PushHeat(__instance.Position, __instance.Map, energy);
                    if ((double)Rand.Value < 0.400000005960464)
                    {
                        SnowUtility.AddSnowRadial(__instance.Position, __instance.Map, __instance.fireSize * 3f, (float)-((double)__instance.fireSize * 0.100000001490116));
                    }
                    __instance.fireSize += (float)(0.000549999997019768 * (double)flammabilityMax(__instance) * 150.0);
                    if ((double)__instance.fireSize > 1.75)
                    {
                        __instance.fireSize = 1.75f;
                    }
                    if ((double)__instance.Map.weatherManager.RainRate <= 0.00999999977648258 || !VulnerableToRain(__instance) || (double)Rand.Value >= 6.0)
                    {
                        return(false);
                    }
                    //__instance.TakeDamage(new DamageInfo(DamageDefOf.Extinguish, 10f, 0.0f, -1f, (Thing)null, (BodyPartRecord)null, (ThingDef)null, DamageInfo.SourceCategory.ThingOrUnknown, (Thing)null));
                    DamageInfo daminfo = new DamageInfo(DamageDefOf.Extinguish, 10f, 0.0f, -1f, (Thing)null, (BodyPartRecord)null, (ThingDef)null, DamageInfo.SourceCategory.ThingOrUnknown, (Thing)null);
                    DamageWorker.DamageResult dresult = new DamageWorker.DamageResult();
                    Thing_Patch.TakeDamage(__instance, ref dresult, daminfo);
                }
            }
            return(false);
        }