Exemplo n.º 1
0
        public static void DrawCurve(Rect rect, SimpleCurve curve, SimpleCurveDrawerStyle style = null, List <CurveMark> marks = null, Rect legendScreenRect = default(Rect))
        {
            SimpleCurveDrawInfo simpleCurveDrawInfo = new SimpleCurveDrawInfo();

            simpleCurveDrawInfo.curve = curve;
            DrawCurve(rect, simpleCurveDrawInfo, style, marks, legendScreenRect);
        }
Exemplo n.º 2
0
        public void SetViewRectAround(SimpleCurve curve)
        {
            if (curve.PointsCount == 0)
            {
                rect = identityRect;
                return;
            }
            rect.xMin = curve.Points.Select((CurvePoint pt) => pt.Loc.x).Min();
            rect.xMax = curve.Points.Select((CurvePoint pt) => pt.Loc.x).Max();
            rect.yMin = curve.Points.Select((CurvePoint pt) => pt.Loc.y).Min();
            rect.yMax = curve.Points.Select((CurvePoint pt) => pt.Loc.y).Max();
            if (Mathf.Approximately(rect.width, 0f))
            {
                rect.width = rect.xMin * 2f;
            }
            if (Mathf.Approximately(rect.height, 0f))
            {
                rect.height = rect.yMin * 2f;
            }
            if (Mathf.Approximately(rect.width, 0f))
            {
                rect.width = 1f;
            }
            if (Mathf.Approximately(rect.height, 0f))
            {
                rect.height = 1f;
            }
            float width  = rect.width;
            float height = rect.height;

            rect.xMin -= width * 0.1f;
            rect.xMax += width * 0.1f;
            rect.yMin -= height * 0.1f;
            rect.yMax += height * 0.1f;
        }
        public static void StunChances()
        {
            Func <ThingDef, float, bool, string> bluntBodyStunChance = delegate(ThingDef d, float dam, bool onHead)
            {
                SimpleCurve obj   = (onHead ? DamageDefOf.Blunt.bluntStunChancePerDamagePctOfCorePartToHeadCurve : DamageDefOf.Blunt.bluntStunChancePerDamagePctOfCorePartToBodyCurve);
                Pawn        pawn2 = PawnGenerator.GeneratePawn(new PawnGenerationRequest(d.race.AnyPawnKind, Find.FactionManager.FirstFactionOfDef(d.race.AnyPawnKind.defaultFactionType), PawnGenerationContext.NonPlayer, -1, forceGenerateNewPawn: true));
                float       x     = dam / d.race.body.corePart.def.GetMaxHealth(pawn2);
                Find.WorldPawns.PassToWorld(pawn2, PawnDiscardDecideMode.Discard);
                return(Mathf.Clamp01(obj.Evaluate(x)).ToStringPercent());
            };
            List <TableDataGetter <ThingDef> > list = new List <TableDataGetter <ThingDef> >();

            list.Add(new TableDataGetter <ThingDef>("defName", (ThingDef d) => d.defName));
            list.Add(new TableDataGetter <ThingDef>("body size", (ThingDef d) => d.race.baseBodySize.ToString("F2")));
            list.Add(new TableDataGetter <ThingDef>("health scale", (ThingDef d) => d.race.baseHealthScale.ToString("F2")));
            list.Add(new TableDataGetter <ThingDef>("body size\n* health scale", (ThingDef d) => (d.race.baseHealthScale * d.race.baseBodySize).ToString("F2")));
            list.Add(new TableDataGetter <ThingDef>("core part\nhealth", delegate(ThingDef d)
            {
                Pawn pawn       = PawnGenerator.GeneratePawn(new PawnGenerationRequest(d.race.AnyPawnKind, Find.FactionManager.FirstFactionOfDef(d.race.AnyPawnKind.defaultFactionType), PawnGenerationContext.NonPlayer, -1, forceGenerateNewPawn: true));
                float maxHealth = d.race.body.corePart.def.GetMaxHealth(pawn);
                Find.WorldPawns.PassToWorld(pawn, PawnDiscardDecideMode.Discard);
                return(maxHealth);
            }));
            list.Add(new TableDataGetter <ThingDef>("stun\nchance\nbody\n5", (ThingDef d) => bluntBodyStunChance(d, 5f, arg3: false)));
            list.Add(new TableDataGetter <ThingDef>("stun\nchance\nbody\n10", (ThingDef d) => bluntBodyStunChance(d, 10f, arg3: false)));
            list.Add(new TableDataGetter <ThingDef>("stun\nchance\nbody\n15", (ThingDef d) => bluntBodyStunChance(d, 15f, arg3: false)));
            list.Add(new TableDataGetter <ThingDef>("stun\nchance\nbody\n20", (ThingDef d) => bluntBodyStunChance(d, 20f, arg3: false)));
            list.Add(new TableDataGetter <ThingDef>("stun\nchance\nhead\n5", (ThingDef d) => bluntBodyStunChance(d, 5f, arg3: true)));
            list.Add(new TableDataGetter <ThingDef>("stun\nchance\nhead\n10", (ThingDef d) => bluntBodyStunChance(d, 10f, arg3: true)));
            list.Add(new TableDataGetter <ThingDef>("stun\nchance\nhead\n15", (ThingDef d) => bluntBodyStunChance(d, 15f, arg3: true)));
            list.Add(new TableDataGetter <ThingDef>("stun\nchance\nhead\n20", (ThingDef d) => bluntBodyStunChance(d, 20f, arg3: true)));
            DebugTables.MakeTablesDialog(DefDatabase <ThingDef> .AllDefs.Where((ThingDef d) => d.category == ThingCategory.Pawn), list.ToArray());
        }
Exemplo n.º 4
0
 public static float ByCurve(SimpleCurve curve, int sampleCount = 100)
 {
     if (curve.PointsCount < 3)
     {
         throw new ArgumentException("curve has < 3 points");
     }
     if (!(curve[0].y > 0.0) && !(curve[curve.PointsCount - 1].y > 0.0))
     {
         float x    = curve[0].x;
         float x2   = curve[curve.PointsCount - 1].x;
         float num  = (x2 - x) / (float)sampleCount;
         float num2 = 0f;
         for (int i = 0; i < sampleCount; i++)
         {
             float x3   = (float)(x + ((float)i + 0.5) * num);
             float num3 = curve.Evaluate(x3);
             num2 += num3;
         }
         float num4 = Rand.Range(0f, num2);
         num2 = 0f;
         for (int j = 0; j < sampleCount; j++)
         {
             float num5 = (float)(x + ((float)j + 0.5) * num);
             float num6 = curve.Evaluate(num5);
             num2 += num6;
             if (num2 > num4)
             {
                 return(num5 + Rand.Range((float)((0.0 - num) / 2.0), (float)(num / 2.0)));
             }
         }
         throw new Exception("Reached end of Rand.ByCurve without choosing a point.");
     }
     throw new ArgumentException("curve has start/end point with y > 0");
 }
        private static string <StunChances> m__1(ThingDef d, float dam, bool onHead)
        {
            SimpleCurve           simpleCurve = (!onHead) ? DamageDefOf.Blunt.bluntStunChancePerDamagePctOfCorePartToBodyCurve : DamageDefOf.Blunt.bluntStunChancePerDamagePctOfCorePartToHeadCurve;
            PawnGenerationRequest request     = new PawnGenerationRequest(d.race.AnyPawnKind, Find.FactionManager.FirstFactionOfDef(d.race.AnyPawnKind.defaultFactionType), PawnGenerationContext.NonPlayer, -1, true, false, false, false, true, false, 1f, false, true, true, false, false, false, false, null, null, null, null, null, null, null, null);
            Pawn  pawn = PawnGenerator.GeneratePawn(request);
            float x    = dam / d.race.body.corePart.def.GetMaxHealth(pawn);

            Find.WorldPawns.PassToWorld(pawn, PawnDiscardDecideMode.Discard);
            return(Mathf.Clamp01(simpleCurve.Evaluate(x)).ToStringPercent());
        }
Exemplo n.º 6
0
        public static float ByCurveAverage(SimpleCurve curve)
        {
            float num  = 0f;
            float num2 = 0f;

            for (int i = 0; i < curve.PointsCount - 1; i++)
            {
                num  += (curve[i + 1].x - curve[i].x) * (curve[i].y + curve[i + 1].y);
                num2 += (curve[i + 1].x - curve[i].x) * (curve[i].x * (2f * curve[i].y + curve[i + 1].y) + curve[i + 1].x * (curve[i].y + 2f * curve[i + 1].y));
            }
            return(num2 / num / 3f);
        }
Exemplo n.º 7
0
 public void SetViewRectAround(SimpleCurve curve)
 {
     if (curve.PointsCount == 0)
     {
         rect = identityRect;
     }
     else
     {
         rect.xMin = curve.Points.Select(delegate(CurvePoint pt)
         {
             Vector2 loc4 = pt.Loc;
             return(loc4.x);
         }).Min();
         rect.xMax = curve.Points.Select(delegate(CurvePoint pt)
         {
             Vector2 loc3 = pt.Loc;
             return(loc3.x);
         }).Max();
         rect.yMin = curve.Points.Select(delegate(CurvePoint pt)
         {
             Vector2 loc2 = pt.Loc;
             return(loc2.y);
         }).Min();
         rect.yMax = curve.Points.Select(delegate(CurvePoint pt)
         {
             Vector2 loc = pt.Loc;
             return(loc.y);
         }).Max();
         if (Mathf.Approximately(rect.width, 0f))
         {
             rect.width = rect.xMin * 2f;
         }
         if (Mathf.Approximately(rect.height, 0f))
         {
             rect.height = rect.yMin * 2f;
         }
         if (Mathf.Approximately(rect.width, 0f))
         {
             rect.width = 1f;
         }
         if (Mathf.Approximately(rect.height, 0f))
         {
             rect.height = 1f;
         }
         float width  = rect.width;
         float height = rect.height;
         rect.xMin -= width * 0.1f;
         rect.xMax += width * 0.1f;
         rect.yMin -= height * 0.1f;
         rect.yMax += height * 0.1f;
     }
 }
 public void SetViewRectAround(SimpleCurve curve)
 {
     if (!curve.AllPoints.Any())
     {
         this.rect = SimpleCurveView.identityRect;
     }
     else
     {
         this.rect.xMin = curve.AllPoints.Select(delegate(CurvePoint pt)
         {
             Vector2 loc4 = pt.Loc;
             return(loc4.x);
         }).Min();
         this.rect.xMax = curve.AllPoints.Select(delegate(CurvePoint pt)
         {
             Vector2 loc3 = pt.Loc;
             return(loc3.x);
         }).Max();
         this.rect.yMin = curve.AllPoints.Select(delegate(CurvePoint pt)
         {
             Vector2 loc2 = pt.Loc;
             return(loc2.y);
         }).Min();
         this.rect.yMax = curve.AllPoints.Select(delegate(CurvePoint pt)
         {
             Vector2 loc = pt.Loc;
             return(loc.y);
         }).Max();
         if (Mathf.Approximately(this.rect.width, 0f))
         {
             this.rect.width = (float)(this.rect.xMin * 2.0);
         }
         if (Mathf.Approximately(this.rect.height, 0f))
         {
             this.rect.height = (float)(this.rect.yMin * 2.0);
         }
         if (Mathf.Approximately(this.rect.width, 0f))
         {
             this.rect.width = 1f;
         }
         if (Mathf.Approximately(this.rect.height, 0f))
         {
             this.rect.height = 1f;
         }
         float width  = this.rect.width;
         float height = this.rect.height;
         this.rect.xMin -= (float)(width * 0.10000000149011612);
         this.rect.xMax += (float)(width * 0.10000000149011612);
         this.rect.yMin -= (float)(height * 0.10000000149011612);
         this.rect.yMax += (float)(height * 0.10000000149011612);
     }
 }
Exemplo n.º 9
0
        public static float ByCurve(SimpleCurve curve)
        {
            if (curve.PointsCount < 3)
            {
                throw new ArgumentException("curve has < 3 points");
            }
            if (curve[0].y != 0f || curve[curve.PointsCount - 1].y != 0f)
            {
                throw new ArgumentException("curve has start/end point with y != 0");
            }
            float num = 0f;

            for (int i = 0; i < curve.PointsCount - 1; i++)
            {
                if (curve[i].y < 0f)
                {
                    throw new ArgumentException("curve has point with y < 0");
                }
                num += (curve[i + 1].x - curve[i].x) * (curve[i].y + curve[i + 1].y);
            }
            float num2 = Range(0f, num);

            for (int j = 0; j < curve.PointsCount - 1; j++)
            {
                float num3 = (curve[j + 1].x - curve[j].x) * (curve[j].y + curve[j + 1].y);
                if (num3 < num2)
                {
                    num2 -= num3;
                    continue;
                }
                float num4 = curve[j + 1].x - curve[j].x;
                float y    = curve[j].y;
                float y2   = curve[j + 1].y;
                float num5 = num2 / (y + y2);
                if (Range(0f, (y + y2) / 2f) > Mathf.Lerp(y, y2, num5 / num4))
                {
                    num5 = num4 - num5;
                }
                return(num5 + curve[j].x);
            }
            throw new Exception("Reached end of Rand.ByCurve without choosing a point.");
        }
Exemplo n.º 10
0
        public static void RandByCurveTests()
        {
            DebugHistogram debugHistogram = new DebugHistogram((from x in Enumerable.Range(0, 30)
                                                                select(float) x).ToArray <float>());
            SimpleCurve curve = new SimpleCurve
            {
                {
                    new CurvePoint(0f, 0f),
                    true
                },
                {
                    new CurvePoint(10f, 1f),
                    true
                },
                {
                    new CurvePoint(15f, 2f),
                    true
                },
                {
                    new CurvePoint(20f, 2f),
                    true
                },
                {
                    new CurvePoint(21f, 0.5f),
                    true
                },
                {
                    new CurvePoint(30f, 0f),
                    true
                }
            };
            float num = 0f;

            for (int i = 0; i < 1000000; i++)
            {
                float num2 = Rand.ByCurve(curve);
                num += num2;
                debugHistogram.Add(num2);
            }
            debugHistogram.Display();
            Log.Message(string.Format("Average {0}, calculated as {1}", num / 1000000f, Rand.ByCurveAverage(curve)), false);
        }
Exemplo n.º 11
0
 public void SetViewRectAround(SimpleCurve curve)
 {
     if (curve.PointsCount == 0)
     {
         this.rect = SimpleCurveView.identityRect;
     }
     else
     {
         this.rect.xMin = (from pt in curve.Points
                           select pt.Loc.x).Min();
         this.rect.xMax = (from pt in curve.Points
                           select pt.Loc.x).Max();
         this.rect.yMin = (from pt in curve.Points
                           select pt.Loc.y).Min();
         this.rect.yMax = (from pt in curve.Points
                           select pt.Loc.y).Max();
         if (Mathf.Approximately(this.rect.width, 0f))
         {
             this.rect.width = this.rect.xMin * 2f;
         }
         if (Mathf.Approximately(this.rect.height, 0f))
         {
             this.rect.height = this.rect.yMin * 2f;
         }
         if (Mathf.Approximately(this.rect.width, 0f))
         {
             this.rect.width = 1f;
         }
         if (Mathf.Approximately(this.rect.height, 0f))
         {
             this.rect.height = 1f;
         }
         float width  = this.rect.width;
         float height = this.rect.height;
         this.rect.xMin = this.rect.xMin - width * 0.1f;
         this.rect.xMax = this.rect.xMax + width * 0.1f;
         this.rect.yMin = this.rect.yMin - height * 0.1f;
         this.rect.yMax = this.rect.yMax + height * 0.1f;
     }
 }
        public static void RandByCurveTests()
        {
            DebugHistogram debugHistogram = new DebugHistogram(Enumerable.Range(0, 30).Select((Func <int, float>)((int x) => x)).ToArray());
            SimpleCurve    curve          = new SimpleCurve
            {
                new CurvePoint(0f, 0f),
                new CurvePoint(10f, 1f),
                new CurvePoint(15f, 2f),
                new CurvePoint(20f, 2f),
                new CurvePoint(21f, 0.5f),
                new CurvePoint(30f, 0f)
            };
            float num = 0f;

            for (int i = 0; i < 1000000; i++)
            {
                float num2 = Rand.ByCurve(curve);
                num += num2;
                debugHistogram.Add(num2);
            }
            debugHistogram.Display();
            Log.Message($"Average {num / 1000000f}, calculated as {Rand.ByCurveAverage(curve)}");
        }
Exemplo n.º 13
0
        public static void RandByCurveTests()
        {
            DebugHistogram debugHistogram = new DebugHistogram((from x in Enumerable.Range(0, 30)
                                                                select(float) x).ToArray());
            SimpleCurve simpleCurve = new SimpleCurve();

            simpleCurve.Add(new CurvePoint(0f, 0f));
            simpleCurve.Add(new CurvePoint(10f, 1f));
            simpleCurve.Add(new CurvePoint(15f, 2f));
            simpleCurve.Add(new CurvePoint(20f, 2f));
            simpleCurve.Add(new CurvePoint(21f, 0.5f));
            simpleCurve.Add(new CurvePoint(30f, 0f));
            SimpleCurve curve = simpleCurve;
            float       num   = 0f;

            for (int i = 0; i < 1000000; i++)
            {
                float num2 = Rand.ByCurve(curve);
                num += num2;
                debugHistogram.Add(num2);
            }
            debugHistogram.Display();
            Log.Message($"Average {num / 1000000f}, calculated as {Rand.ByCurveAverage(curve)}");
        }
Exemplo n.º 14
0
 public EditWindow_CurveEditor(SimpleCurve curve, string title)
 {
     this.curve         = curve;
     this.optionalTitle = title;
 }
Exemplo n.º 15
0
 public SurfaceColumn(float x, SimpleCurve y)
 {
     this.x = x;
     this.y = y;
 }
        protected override void ApplySpecialEffectsToPart(Pawn pawn, float totalDamage, DamageInfo dinfo, DamageWorker.DamageResult result)
        {
            bool       flag     = Rand.Chance(this.def.bluntInnerHitChance);
            float      num      = (!flag) ? 0f : this.def.bluntInnerHitDamageFractionToConvert.RandomInRange;
            float      num2     = totalDamage * (1f - num);
            DamageInfo lastInfo = dinfo;

            for (;;)
            {
                num2 -= base.FinalizeAndAddInjury(pawn, num2, lastInfo, result);
                if (!pawn.health.hediffSet.PartIsMissing(lastInfo.HitPart))
                {
                    break;
                }
                if (num2 <= 1f)
                {
                    break;
                }
                BodyPartRecord parent = lastInfo.HitPart.parent;
                if (parent == null)
                {
                    break;
                }
                lastInfo.SetHitPart(parent);
            }
            if (flag && !lastInfo.HitPart.def.IsSolid(lastInfo.HitPart, pawn.health.hediffSet.hediffs) && lastInfo.HitPart.depth == BodyPartDepth.Outside)
            {
                IEnumerable <BodyPartRecord> source = from x in pawn.health.hediffSet.GetNotMissingParts(BodyPartHeight.Undefined, BodyPartDepth.Undefined, null)
                                                      where x.parent == lastInfo.HitPart && x.def.IsSolid(x, pawn.health.hediffSet.hediffs) && x.depth == BodyPartDepth.Inside
                                                      select x;
                BodyPartRecord hitPart;
                if (source.TryRandomElementByWeight((BodyPartRecord x) => x.coverageAbs, out hitPart))
                {
                    DamageInfo lastInfo2 = lastInfo;
                    lastInfo2.SetHitPart(hitPart);
                    float totalDamage2 = totalDamage * num + totalDamage * this.def.bluntInnerHitDamageFractionToAdd.RandomInRange;
                    base.FinalizeAndAddInjury(pawn, totalDamage2, lastInfo2, result);
                }
            }
            if (!pawn.Dead)
            {
                SimpleCurve simpleCurve = null;
                if (lastInfo.HitPart.parent == null)
                {
                    simpleCurve = this.def.bluntStunChancePerDamagePctOfCorePartToBodyCurve;
                }
                else
                {
                    foreach (BodyPartRecord lhs in pawn.RaceProps.body.GetPartsWithTag(BodyPartTagDefOf.ConsciousnessSource))
                    {
                        if (this.InSameBranch(lhs, lastInfo.HitPart))
                        {
                            simpleCurve = this.def.bluntStunChancePerDamagePctOfCorePartToHeadCurve;
                            break;
                        }
                    }
                }
                if (simpleCurve != null)
                {
                    float x2 = totalDamage / pawn.def.race.body.corePart.def.GetMaxHealth(pawn);
                    if (Rand.Chance(simpleCurve.Evaluate(x2)))
                    {
                        DamageInfo dinfo2 = dinfo;
                        dinfo2.Def = DamageDefOf.Stun;
                        dinfo2.SetAmount((float)3.5f.SecondsToTicks() / 30f);
                        pawn.TakeDamage(dinfo2);
                    }
                }
            }
        }
        private static void RoyalFavorAvailability()
        {
            StorytellerCompProperties_OnOffCycle storytellerCompProperties_OnOffCycle = (StorytellerCompProperties_OnOffCycle)StorytellerDefOf.Cassandra.comps.Find(delegate(StorytellerCompProperties x)
            {
                StorytellerCompProperties_OnOffCycle storytellerCompProperties_OnOffCycle2 = x as StorytellerCompProperties_OnOffCycle;
                if (storytellerCompProperties_OnOffCycle2 == null)
                {
                    return(false);
                }
                if (storytellerCompProperties_OnOffCycle2.IncidentCategory != IncidentCategoryDefOf.GiveQuest)
                {
                    return(false);
                }
                return((storytellerCompProperties_OnOffCycle2.enableIfAnyModActive != null && storytellerCompProperties_OnOffCycle2.enableIfAnyModActive.Any((string m) => m.ToLower() == ModContentPack.RoyaltyModPackageId)) ? true : false);
            });
            float       onDays      = storytellerCompProperties_OnOffCycle.onDays;
            float       average     = storytellerCompProperties_OnOffCycle.numIncidentsRange.Average;
            float       num         = average / onDays;
            SimpleCurve simpleCurve = new SimpleCurve
            {
                new CurvePoint(0f, 35f),
                new CurvePoint(15f, 150f),
                new CurvePoint(150f, 5000f)
            };
            int num2 = 0;
            List <RoyalTitleDef> royalTitlesAwardableInSeniorityOrderForReading = FactionDefOf.Empire.RoyalTitlesAwardableInSeniorityOrderForReading;

            for (int i = 0; i < royalTitlesAwardableInSeniorityOrderForReading.Count; i++)
            {
                num2 += royalTitlesAwardableInSeniorityOrderForReading[i].favorCost;
                if (royalTitlesAwardableInSeniorityOrderForReading[i] == RoyalTitleDefOf.Count)
                {
                    break;
                }
            }
            float      num3       = 0f;
            int        num4       = 0;
            int        num5       = 0;
            int        num6       = 0;
            int        num7       = 0;
            int        num8       = -1;
            int        num9       = -1;
            int        num10      = -1;
            int        ticksGame  = Find.TickManager.TicksGame;
            StoryState storyState = new StoryState(Find.World);

            for (int j = 0; j < 200; j++)
            {
                Find.TickManager.DebugSetTicksGame(j * 60000);
                num3 += num * storytellerCompProperties_OnOffCycle.acceptFractionByDaysPassedCurve.Evaluate(j);
                while (num3 >= 1f)
                {
                    num3 -= 1f;
                    num4++;
                    float points = simpleCurve.Evaluate(j);
                    Slate slate  = new Slate();
                    slate.Set("points", points);
                    QuestScriptDef questScriptDef = DefDatabase <QuestScriptDef> .AllDefsListForReading.Where((QuestScriptDef x) => x.IsRootRandomSelected && x.CanRun(slate)).RandomElementByWeight((QuestScriptDef x) => NaturalRandomQuestChooser.GetNaturalRandomSelectionWeight(x, points, storyState));

                    Quest quest = QuestGen.Generate(questScriptDef, slate);
                    if (quest.InvolvedFactions.Contains(Faction.Empire))
                    {
                        num7++;
                    }
                    QuestPart_GiveRoyalFavor questPart_GiveRoyalFavor = (QuestPart_GiveRoyalFavor)quest.PartsListForReading.Find((QuestPart x) => x is QuestPart_GiveRoyalFavor);
                    if (questPart_GiveRoyalFavor != null)
                    {
                        num5 += questPart_GiveRoyalFavor.amount;
                        num6++;
                        if (num5 >= num2 && num8 < 0)
                        {
                            num8 = j;
                        }
                        if (num9 < 0 || questPart_GiveRoyalFavor.amount < num9)
                        {
                            num9 = questPart_GiveRoyalFavor.amount;
                        }
                        if (num10 < 0 || questPart_GiveRoyalFavor.amount > num10)
                        {
                            num10 = questPart_GiveRoyalFavor.amount;
                        }
                    }
                    storyState.RecordRandomQuestFired(questScriptDef);
                    quest.CleanupQuestParts();
                }
            }
            Find.TickManager.DebugSetTicksGame(ticksGame);
            StringBuilder stringBuilder = new StringBuilder();

            stringBuilder.AppendLine("Results for: Days=" + 200 + ", intervalDays=" + onDays + ", questsPerInterval=" + average + ":");
            stringBuilder.AppendLine("Quests: " + num4);
            stringBuilder.AppendLine("Quests with honor: " + num6);
            stringBuilder.AppendLine("Quests from Empire: " + num7);
            stringBuilder.AppendLine("Min honor reward: " + num9);
            stringBuilder.AppendLine("Max honor reward: " + num10);
            stringBuilder.AppendLine("Total honor: " + num5);
            stringBuilder.AppendLine("Honor required for Count: " + num2);
            stringBuilder.AppendLine("Count title possible on day: " + num8);
            Log.Message(stringBuilder.ToString());
        }
        protected override void ApplySpecialEffectsToPart(Pawn pawn, float totalDamage, DamageInfo dinfo, DamageResult result)
        {
            bool       flag     = Rand.Chance(def.bluntInnerHitChance);
            float      num      = (flag ? def.bluntInnerHitDamageFractionToConvert.RandomInRange : 0f);
            float      num2     = totalDamage * (1f - num);
            DamageInfo lastInfo = dinfo;

            while (true)
            {
                num2 -= FinalizeAndAddInjury(pawn, num2, lastInfo, result);
                if (!pawn.health.hediffSet.PartIsMissing(lastInfo.HitPart) || num2 <= 1f)
                {
                    break;
                }
                BodyPartRecord parent = lastInfo.HitPart.parent;
                if (parent == null)
                {
                    break;
                }
                lastInfo.SetHitPart(parent);
            }
            if (flag && !lastInfo.HitPart.def.IsSolid(lastInfo.HitPart, pawn.health.hediffSet.hediffs) && lastInfo.HitPart.depth == BodyPartDepth.Outside && (from x in pawn.health.hediffSet.GetNotMissingParts()
                                                                                                                                                              where x.parent == lastInfo.HitPart && x.def.IsSolid(x, pawn.health.hediffSet.hediffs) && x.depth == BodyPartDepth.Inside
                                                                                                                                                              select x).TryRandomElementByWeight((BodyPartRecord x) => x.coverageAbs, out var result2))
            {
                DamageInfo dinfo2 = lastInfo;
                dinfo2.SetHitPart(result2);
                float totalDamage2 = totalDamage * num + totalDamage * def.bluntInnerHitDamageFractionToAdd.RandomInRange;
                FinalizeAndAddInjury(pawn, totalDamage2, dinfo2, result);
            }
            if (pawn.Dead)
            {
                return;
            }
            SimpleCurve simpleCurve = null;

            if (lastInfo.HitPart.parent == null)
            {
                simpleCurve = def.bluntStunChancePerDamagePctOfCorePartToBodyCurve;
            }
            else
            {
                foreach (BodyPartRecord item in pawn.RaceProps.body.GetPartsWithTag(BodyPartTagDefOf.ConsciousnessSource))
                {
                    if (InSameBranch(item, lastInfo.HitPart))
                    {
                        simpleCurve = def.bluntStunChancePerDamagePctOfCorePartToHeadCurve;
                        break;
                    }
                }
            }
            if (simpleCurve != null)
            {
                float x2 = totalDamage / pawn.def.race.body.corePart.def.GetMaxHealth(pawn);
                if (Rand.Chance(simpleCurve.Evaluate(x2)))
                {
                    DamageInfo dinfo3 = dinfo;
                    dinfo3.Def = DamageDefOf.Stun;
                    dinfo3.SetAmount((float)def.bluntStunDuration.SecondsToTicks() / 30f);
                    pawn.TakeDamage(dinfo3);
                }
            }
        }