public static void JoyJobs()
 {
     DebugTables.MakeTablesDialog(DefDatabase <JobDef> .AllDefs.Where((JobDef j) => j.joyKind != null), new TableDataGetter <JobDef>("defName", (JobDef d) => d.defName), new TableDataGetter <JobDef>("joyKind", (JobDef d) => d.joyKind.defName), new TableDataGetter <JobDef>("joyDuration", (JobDef d) => d.joyDuration.ToString()), new TableDataGetter <JobDef>("joyGainRate", (JobDef d) => d.joyGainRate.ToString()), new TableDataGetter <JobDef>("joyMaxParticipants", (JobDef d) => d.joyMaxParticipants.ToString()), new TableDataGetter <JobDef>("joySkill", (JobDef d) => (d.joySkill == null) ? "" : d.joySkill.defName), new TableDataGetter <JobDef>("joyXpPerTick", (JobDef d) => d.joyXpPerTick.ToString()));
 }
 public static void JoyGivers()
 {
     DebugTables.MakeTablesDialog(DefDatabase <JoyGiverDef> .AllDefs, new TableDataGetter <JoyGiverDef>("defName", (JoyGiverDef d) => d.defName), new TableDataGetter <JoyGiverDef>("joyKind", (JoyGiverDef d) => (d.joyKind != null) ? d.joyKind.defName : "null"), new TableDataGetter <JoyGiverDef>("baseChance", (JoyGiverDef d) => d.baseChance.ToString()), new TableDataGetter <JoyGiverDef>("canDoWhileInBed", (JoyGiverDef d) => d.canDoWhileInBed.ToStringCheckBlank()), new TableDataGetter <JoyGiverDef>("desireSit", (JoyGiverDef d) => d.desireSit.ToStringCheckBlank()), new TableDataGetter <JoyGiverDef>("unroofedOnly", (JoyGiverDef d) => d.unroofedOnly.ToStringCheckBlank()), new TableDataGetter <JoyGiverDef>("jobDef", (JoyGiverDef d) => (d.jobDef != null) ? d.jobDef.defName : "null"), new TableDataGetter <JoyGiverDef>("pctPawnsEverDo", (JoyGiverDef d) => d.pctPawnsEverDo.ToStringPercent()), new TableDataGetter <JoyGiverDef>("requiredCapacities", (JoyGiverDef d) => (d.requiredCapacities != null) ? d.requiredCapacities.Select((PawnCapacityDef c) => c.defName).ToCommaList() : ""), new TableDataGetter <JoyGiverDef>("thingDefs", (JoyGiverDef d) => (d.thingDefs != null) ? d.thingDefs.Select((ThingDef c) => c.defName).ToCommaList() : ""), new TableDataGetter <JoyGiverDef>("JoyGainFactors", (JoyGiverDef d) => (d.thingDefs != null) ? d.thingDefs.Select((ThingDef c) => c.GetStatValueAbstract(StatDefOf.JoyGainFactor).ToString("F2")).ToCommaList() : ""));
 }
 public static void JoyKinds()
 {
     DebugTables.MakeTablesDialog(DefDatabase <JoyKindDef> .AllDefs, new TableDataGetter <JoyKindDef>("defName", (JoyKindDef d) => d.defName), new TableDataGetter <JoyKindDef>("titleRequiredAny", (JoyKindDef d) => (d.titleRequiredAny != null) ? string.Join(",", d.titleRequiredAny.Select((RoyalTitleDef t) => t.defName).ToArray()) : "NULL"));
 }
Esempio n. 4
0
 public static void Turrets()
 {
     DebugTables.MakeTablesDialog(DefDatabase <ThingDef> .AllDefs.Where((ThingDef d) => d.category == ThingCategory.Building && d.building.IsTurret), new TableDataGetter <ThingDef>("defName", (ThingDef d) => d.defName), new TableDataGetter <ThingDef>("market\nvalue", (ThingDef d) => d.GetStatValueAbstract(StatDefOf.MarketValue).ToString("F0")), new TableDataGetter <ThingDef>("cost\nlist", (ThingDef d) => (!d.costList.NullOrEmpty()) ? d.costList.Select((ThingDefCountClass x) => x.Summary).ToCommaList() : ""), new TableDataGetter <ThingDef>("cost\nstuff\ncount", (ThingDef d) => (!d.MadeFromStuff) ? "" : d.costStuffCount.ToString()), new TableDataGetter <ThingDef>("work", (ThingDef d) => d.GetStatValueAbstract(StatDefOf.WorkToBuild).ToString("F0")), new TableDataGetter <ThingDef>("hp", (ThingDef d) => d.GetStatValueAbstract(StatDefOf.MaxHitPoints).ToString("F0")), new TableDataGetter <ThingDef>("damage", (ThingDef d) => damage(d.building.turretGunDef).ToString()), new TableDataGetter <ThingDef>("AP", (ThingDef d) => armorPenetration(d.building.turretGunDef).ToStringPercent()), new TableDataGetter <ThingDef>("stop\npower", (ThingDef d) => (!(stoppingPower(d.building.turretGunDef) > 0f)) ? "" : stoppingPower(d.building.turretGunDef).ToString("F1")), new TableDataGetter <ThingDef>("warmup", (ThingDef d) => warmup(d.building.turretGunDef).ToString("F2")), new TableDataGetter <ThingDef>("burst\nshots", (ThingDef d) => burstShots(d.building.turretGunDef).ToString()), new TableDataGetter <ThingDef>("cooldown", (ThingDef d) => cooldown(d.building.turretGunDef).ToString("F2")), new TableDataGetter <ThingDef>("full\ncycle", (ThingDef d) => fullcycle(d.building.turretGunDef).ToString("F2")), new TableDataGetter <ThingDef>("range", (ThingDef d) => d.building.turretGunDef.Verbs[0].range.ToString("F1")), new TableDataGetter <ThingDef>("projectile\nspeed", (ThingDef d) => (d.building.turretGunDef.projectile == null) ? "" : d.building.turretGunDef.projectile.speed.ToString("F0")), new TableDataGetter <ThingDef>("dps\nmissless", (ThingDef d) => dpsMissless(d.building.turretGunDef).ToString("F2")), new TableDataGetter <ThingDef>("accuracy\ntouch (" + 3f + ")", (ThingDef d) => accTouch(d.building.turretGunDef).ToStringPercent()), new TableDataGetter <ThingDef>("accuracy\nshort (" + 12f + ")", (ThingDef d) => accShort(d.building.turretGunDef).ToStringPercent()), new TableDataGetter <ThingDef>("accuracy\nmed (" + 25f + ")", (ThingDef d) => accMed(d.building.turretGunDef).ToStringPercent()), new TableDataGetter <ThingDef>("accuracy\nlong (" + 40f + ")", (ThingDef d) => accLong(d.building.turretGunDef).ToStringPercent()), new TableDataGetter <ThingDef>("accuracy\navg", (ThingDef d) => accAvg(d.building.turretGunDef).ToString("F2")), new TableDataGetter <ThingDef>("forced\nmiss\nradius", (ThingDef d) => (!(d.building.turretGunDef.Verbs[0].forcedMissRadius > 0f)) ? "" : d.building.turretGunDef.Verbs[0].forcedMissRadius.ToString()), new TableDataGetter <ThingDef>("dps\ntouch", (ThingDef d) => (dpsMissless(d.building.turretGunDef) * accTouch(d.building.turretGunDef)).ToString("F2")), new TableDataGetter <ThingDef>("dps\nshort", (ThingDef d) => (dpsMissless(d.building.turretGunDef) * accShort(d.building.turretGunDef)).ToString("F2")), new TableDataGetter <ThingDef>("dps\nmed", (ThingDef d) => (dpsMissless(d.building.turretGunDef) * accMed(d.building.turretGunDef)).ToString("F2")), new TableDataGetter <ThingDef>("dps\nlong", (ThingDef d) => (dpsMissless(d.building.turretGunDef) * accLong(d.building.turretGunDef)).ToString("F2")), new TableDataGetter <ThingDef>("dps\navg", (ThingDef d) => dpsAvg(d.building.turretGunDef).ToString("F2")), new TableDataGetter <ThingDef>("dpsAvg / $100", (ThingDef d) => (dpsAvg(d.building.turretGunDef) / (d.GetStatValueAbstract(StatDefOf.MarketValue) / 100f)).ToString("F3")), new TableDataGetter <ThingDef>("fuel\nshot capacity", (ThingDef d) => fuelCapacity(d).ToString()), new TableDataGetter <ThingDef>("fuel\ntype", (ThingDef d) => fuelType(d)), new TableDataGetter <ThingDef>("fuel to\nreload", (ThingDef d) => fuelToReload(d).ToString()));
Esempio n. 5
0
 public static void WeaponsRanged()
 {
     DebugTables.MakeTablesDialog(DefDatabase <ThingDef> .AllDefs.Where((ThingDef d) => d.IsRangedWeapon).OrderByDescending(dpsAvg), new TableDataGetter <ThingDef>("defName", (ThingDef d) => d.defName), new TableDataGetter <ThingDef>("damage", (ThingDef d) => damage(d).ToString()), new TableDataGetter <ThingDef>("AP", (ThingDef d) => armorPenetration(d).ToStringPercent()), new TableDataGetter <ThingDef>("stop\npower", (ThingDef d) => (!(stoppingPower(d) > 0f)) ? "" : stoppingPower(d).ToString("F1")), new TableDataGetter <ThingDef>("warmup", (ThingDef d) => warmup(d).ToString("F2")), new TableDataGetter <ThingDef>("burst\nshots", (ThingDef d) => burstShots(d).ToString()), new TableDataGetter <ThingDef>("cooldown", (ThingDef d) => cooldown(d).ToString("F2")), new TableDataGetter <ThingDef>("full\ncycle", (ThingDef d) => fullcycle(d).ToString("F2")), new TableDataGetter <ThingDef>("range", (ThingDef d) => d.Verbs[0].range.ToString("F1")), new TableDataGetter <ThingDef>("projectile\nspeed", (ThingDef d) => (d.projectile == null) ? "" : d.projectile.speed.ToString("F0")), new TableDataGetter <ThingDef>("dps\nmissless", (ThingDef d) => dpsMissless(d).ToString("F2")), new TableDataGetter <ThingDef>("accuracy\ntouch (" + 3f + ")", (ThingDef d) => accTouch(d).ToStringPercent()), new TableDataGetter <ThingDef>("accuracy\nshort (" + 12f + ")", (ThingDef d) => accShort(d).ToStringPercent()), new TableDataGetter <ThingDef>("accuracy\nmed (" + 25f + ")", (ThingDef d) => accMed(d).ToStringPercent()), new TableDataGetter <ThingDef>("accuracy\nlong (" + 40f + ")", (ThingDef d) => accLong(d).ToStringPercent()), new TableDataGetter <ThingDef>("accuracy\navg", (ThingDef d) => accAvg(d).ToString("F2")), new TableDataGetter <ThingDef>("forced\nmiss\nradius", (ThingDef d) => (!(d.Verbs[0].forcedMissRadius > 0f)) ? "" : d.Verbs[0].forcedMissRadius.ToString()), new TableDataGetter <ThingDef>("dps\ntouch", (ThingDef d) => (dpsMissless(d) * accTouch(d)).ToString("F2")), new TableDataGetter <ThingDef>("dps\nshort", (ThingDef d) => (dpsMissless(d) * accShort(d)).ToString("F2")), new TableDataGetter <ThingDef>("dps\nmed", (ThingDef d) => (dpsMissless(d) * accMed(d)).ToString("F2")), new TableDataGetter <ThingDef>("dps\nlong", (ThingDef d) => (dpsMissless(d) * accLong(d)).ToString("F2")), new TableDataGetter <ThingDef>("dps\navg", (ThingDef d) => dpsAvg(d).ToString("F2")), new TableDataGetter <ThingDef>("market\nvalue", (ThingDef d) => d.GetStatValueAbstract(StatDefOf.MarketValue).ToString("F0")), new TableDataGetter <ThingDef>("work", (ThingDef d) => d.GetStatValueAbstract(StatDefOf.WorkToMake).ToString("F0")), new TableDataGetter <ThingDef>("dpsAvg*100 / market value", (ThingDef d) => (dpsAvg(d) * 100f / d.GetStatValueAbstract(StatDefOf.MarketValue)).ToString("F3")));
 }
Esempio n. 6
0
        public static void Infections()
        {
            Func <InfectionLuck, float> ilc = delegate(InfectionLuck il)
            {
                float result = 1f;
                if (il == InfectionLuck.Bad)
                {
                    result = 0.8f;
                }
                if (il == InfectionLuck.Good)
                {
                    result = 1.2f;
                }
                return(result);
            };
            Func <Func <InfectionLuck, float>, string>   stringizeWithLuck      = (Func <InfectionLuck, float> func) => $"{func(InfectionLuck.Bad):F2} / {func(InfectionLuck.Good):F2}";
            Func <HediffDef, InfectionLuck, float>       baseImmunityIncrease   = (HediffDef d, InfectionLuck il) => d.CompProps <HediffCompProperties_Immunizable>().immunityPerDaySick *ilc(il);
            Func <HediffDef, float, float>               tendedSeverityIncrease = (HediffDef d, float tend) => baseSeverityIncrease(d) + d.CompProps <HediffCompProperties_TendDuration>().severityPerDayTended *tend;
            Func <HediffDef, InfectionLuck, bool, float> immunityIncrease       = delegate(HediffDef d, InfectionLuck il, bool bedridden)
            {
                float b    = isAnimal(d) ? 1f : ThingDefOf.Bed.GetStatValueAbstract(StatDefOf.ImmunityGainSpeedFactor);
                float num3 = Mathf.Lerp(1f, b, bedridden ? 1f : 0.3f) * StatDefOf.ImmunityGainSpeed.GetStatPart <StatPart_Resting>().factor;
                return(baseImmunityIncrease(d, il) * num3);
            };
            Func <HediffDef, InfectionLuck, float, float> immunityOnLethality = (HediffDef d, InfectionLuck il, float tend) => (tendedSeverityIncrease(d, tend) <= 0f) ? float.PositiveInfinity : (d.lethalSeverity / tendedSeverityIncrease(d, tend) * immunityIncrease(d, il, arg3: true));
            List <TableDataGetter <HediffDef> >           list = new List <TableDataGetter <HediffDef> >();

            list.Add(new TableDataGetter <HediffDef>("defName", (HediffDef d) => d.defName + (d.stages.Any((HediffStage stage) => stage.capMods.Any((PawnCapacityModifier cap) => cap.capacity == PawnCapacityDefOf.BloodFiltration)) ? " (inaccurate)" : "")));
            list.Add(new TableDataGetter <HediffDef>("lethal\nseverity", (HediffDef d) => d.lethalSeverity.ToString("F2")));
            list.Add(new TableDataGetter <HediffDef>("base\nseverity\nincrease", (HediffDef d) => baseSeverityIncrease(d).ToString("F2")));
            list.Add(new TableDataGetter <HediffDef>("base\nimmunity\nincrease", (HediffDef d) => stringizeWithLuck((InfectionLuck il) => baseImmunityIncrease(d, il))));
            List <Pawn> source = GenerateDoctorArray();

            for (float tendquality = 0f; tendquality <= 1.01f; tendquality += 0.1f)
            {
                tendquality = Mathf.Clamp01(tendquality);
                Pawn arg   = source.FirstOrFallback((Pawn doc) => TendUtility.CalculateBaseTendQuality(doc, null, null) >= Mathf.Clamp01(tendquality - 0.25f));
                Pawn arg2  = source.FirstOrFallback((Pawn doc) => TendUtility.CalculateBaseTendQuality(doc, null, ThingDefOf.MedicineHerbal) >= Mathf.Clamp01(tendquality - 0.25f));
                Pawn arg3  = source.FirstOrFallback((Pawn doc) => TendUtility.CalculateBaseTendQuality(doc, null, ThingDefOf.MedicineIndustrial) >= Mathf.Clamp01(tendquality - 0.25f));
                Pawn arg4  = source.FirstOrFallback((Pawn doc) => TendUtility.CalculateBaseTendQuality(doc, null, ThingDefOf.MedicineUltratech) >= Mathf.Clamp01(tendquality - 0.25f));
                Pawn arg5  = source.FirstOrFallback((Pawn doc) => TendUtility.CalculateBaseTendQuality(doc, null, null) >= tendquality);
                Pawn arg6  = source.FirstOrFallback((Pawn doc) => TendUtility.CalculateBaseTendQuality(doc, null, ThingDefOf.MedicineHerbal) >= tendquality);
                Pawn arg7  = source.FirstOrFallback((Pawn doc) => TendUtility.CalculateBaseTendQuality(doc, null, ThingDefOf.MedicineIndustrial) >= tendquality);
                Pawn arg8  = source.FirstOrFallback((Pawn doc) => TendUtility.CalculateBaseTendQuality(doc, null, ThingDefOf.MedicineUltratech) >= tendquality);
                Pawn arg9  = source.FirstOrFallback((Pawn doc) => TendUtility.CalculateBaseTendQuality(doc, null, null) >= Mathf.Clamp01(tendquality + 0.25f));
                Pawn arg10 = source.FirstOrFallback((Pawn doc) => TendUtility.CalculateBaseTendQuality(doc, null, ThingDefOf.MedicineHerbal) >= Mathf.Clamp01(tendquality + 0.25f));
                Pawn arg11 = source.FirstOrFallback((Pawn doc) => TendUtility.CalculateBaseTendQuality(doc, null, ThingDefOf.MedicineIndustrial) >= Mathf.Clamp01(tendquality + 0.25f));
                Pawn arg12 = source.FirstOrFallback((Pawn doc) => TendUtility.CalculateBaseTendQuality(doc, null, ThingDefOf.MedicineUltratech) >= Mathf.Clamp01(tendquality + 0.25f));
                Func <Pawn, Pawn, Pawn, string> obj = delegate(Pawn low, Pawn exp, Pawn high)
                {
                    string arg13 = (low != null) ? low.skills.GetSkill(SkillDefOf.Medicine).Level.ToString() : "X";
                    string arg14 = (exp != null) ? exp.skills.GetSkill(SkillDefOf.Medicine).Level.ToString() : "X";
                    string arg15 = (high != null) ? high.skills.GetSkill(SkillDefOf.Medicine).Level.ToString() : "X";
                    return($"{arg13}-{arg14}-{arg15}");
                };
                string text  = obj(arg, arg5, arg9);
                string text2 = obj(arg2, arg6, arg10);
                string text3 = obj(arg3, arg7, arg11);
                string text4 = obj(arg4, arg8, arg12);
                float  tq    = tendquality;
                list.Add(new TableDataGetter <HediffDef>($"survival chance at\ntend quality {tq.ToStringPercent()}\n\ndoc skill needed:\nno meds:  {text}\nherbal:  {text2}\nnormal:  {text3}\nglitter:  {text4}", delegate(HediffDef d)
                {
                    float num  = immunityOnLethality(d, InfectionLuck.Bad, tq);
                    float num2 = immunityOnLethality(d, InfectionLuck.Good, tq);
                    return((num == float.PositiveInfinity) ? float.PositiveInfinity.ToString() : Mathf.Clamp01((num2 - 1f) / (num2 - num)).ToStringPercent());
                }));
            }
            DebugTables.MakeTablesDialog(InfectionList(), list.ToArray());
            float baseSeverityIncrease(HediffDef d)
            {
                return(d.CompProps <HediffCompProperties_Immunizable>().severityPerDayNotImmune);
            }

            bool isAnimal(HediffDef d)
            {
                return(d.defName.Contains("Animal"));
            }
        }
Esempio n. 7
0
        private static IEnumerable InfectionSimulatorWorker()
        {
            int         trials    = 2;
            List <Pawn> doctors   = GenerateDoctorArray();
            List <int>  testSkill = new List <int>
            {
                4,
                10,
                16
            };
            List <ThingDef> testMedicine = new List <ThingDef>
            {
                null,
                ThingDefOf.MedicineHerbal,
                ThingDefOf.MedicineIndustrial,
                ThingDefOf.MedicineUltratech
            };
            PawnGenerationRequest pawngen  = new PawnGenerationRequest(PawnKindDefOf.Colonist, Faction.OfPlayer);
            int originalTicks              = Find.TickManager.TicksGame;
            List <InfectionSimRow> results = new List <InfectionSimRow>();
            int totalTests  = InfectionList().Count() * testMedicine.Count() * testSkill.Count() * trials;
            int currentTest = 0;

            foreach (HediffDef hediff in InfectionList())
            {
                foreach (ThingDef meds in testMedicine)
                {
                    foreach (int item in testSkill)
                    {
                        InfectionSimRow result = default(InfectionSimRow);
                        result.illness  = hediff;
                        result.skill    = item;
                        result.medicine = meds;
                        Pawn doctor = doctors[item];
                        int  i      = 0;
                        while (i < trials)
                        {
                            Pawn patient    = PawnGenerator.GeneratePawn(pawngen);
                            int  startTicks = Find.TickManager.TicksGame;
                            patient.health.AddHediff(result.illness);
                            Hediff activeHediff = patient.health.hediffSet.GetFirstHediffOfDef(result.illness);
                            while (!patient.Dead && patient.health.hediffSet.HasHediff(result.illness))
                            {
                                if (activeHediff.TendableNow())
                                {
                                    activeHediff.Tended(TendUtility.CalculateBaseTendQuality(doctor, patient, meds));
                                    result.medicineUsed += 1f;
                                }
                                foreach (Hediff item2 in patient.health.hediffSet.GetHediffsTendable())
                                {
                                    item2.Tended(TendUtility.CalculateBaseTendQuality(doctor, patient, meds));
                                }
                                Find.TickManager.DebugSetTicksGame(Find.TickManager.TicksGame + 1);
                                patient.health.HealthTick();
                                if (Find.TickManager.TicksGame % 900 == 0)
                                {
                                    yield return(null);
                                }
                            }
                            if (patient.Dead)
                            {
                                result.deathChance += 1f;
                            }
                            else
                            {
                                result.recoveryTimeDays += (Find.TickManager.TicksGame - startTicks).TicksToDays();
                            }
                            int num = currentTest + 1;
                            currentTest = num;
                            LongEventHandler.SetCurrentEventText($"Simulating ({currentTest}/{totalTests})");
                            yield return(null);

                            num = i + 1;
                            i   = num;
                        }
                        result.recoveryTimeDays /= (float)trials - result.deathChance;
                        result.deathChance      /= trials;
                        result.medicineUsed     /= trials;
                        results.Add(result);
                        result = default(InfectionSimRow);
                    }
                }
            }
            DebugTables.MakeTablesDialog(results, new TableDataGetter <InfectionSimRow>("defName", (InfectionSimRow isr) => isr.illness.defName), new TableDataGetter <InfectionSimRow>("meds", (InfectionSimRow isr) => (isr.medicine == null) ? "(none)" : isr.medicine.defName), new TableDataGetter <InfectionSimRow>("skill", (InfectionSimRow isr) => isr.skill.ToString()), new TableDataGetter <InfectionSimRow>("death chance", (InfectionSimRow isr) => isr.deathChance.ToStringPercent()), new TableDataGetter <InfectionSimRow>("recovery time (days)", (InfectionSimRow isr) => isr.recoveryTimeDays.ToString("F1")), new TableDataGetter <InfectionSimRow>("medicine used", (InfectionSimRow isr) => isr.medicineUsed.ToString()));
            Find.TickManager.DebugSetTicksGame(originalTicks);
        }