Exemple #1
0
        private static void GetFromHeddifTolerance(Table table, ThingDef def, HediffDef hediff, float doerSeverity, float?minToleranceToAddict = null)
        {
            var row = table.NewRow();

            row["DrugName".ParserTranslate()] = def.LabelCap;

            float?severityPerDay = hediff.CompProps <HediffCompProperties_SeverityPerDay>()?.severityPerDay;
            float severity       = 0f;
            int   count          = 0;

            if (minToleranceToAddict == null)
            {
                Log.Error($"[AddRowFromHeddifTolerance] minToleranceToAddict = null");
            }
            else
            {
                severity = CalcSeverityLevelByMin(doerSeverity, (float)minToleranceToAddict, out count);
            }

            row["Title".ParserTranslate()]        = $"   {hediff.label}";
            row["Description".ParserTranslate()]  = "MinimumToleranceForAddiction".ParserTranslate(minToleranceToAddict == null ? 0f : (float)minToleranceToAddict) + "\r\n" + "TolerancePerDose".ParserTranslate(doerSeverity) + "\r\n" + "TheСhanceOfAddictionWillAppearAfterTheConsumedDoses".ParserTranslate(count, severity);
            row["BaseSeverity".ParserTranslate()] = "+" + doerSeverity.ToString("F2");

            if (minToleranceToAddict != null)
            {
                row["MinToleranceToAddict".ParserTranslate()] = $"{(float)minToleranceToAddict:F2}(x{count})";
            }

            if (severityPerDay != null)
            {
                row["SeverityPerDay".ParserTranslate()] = ((float)severityPerDay).ToString("F2");
                row["SeverityDays".ParserTranslate()]   = GetSeverityDays(severity, (float)severityPerDay).ToString("F2");
            }
        }
Exemple #2
0
 private void GetVerbsAndTools(ThingDef def, out List <VerbProperties> verbs, out List <Tool> tools)
 {
     if (def.isTechHediff)
     {
         HediffDef hediffDef = this.FindTechHediffHediff(def);
         if (hediffDef == null)
         {
             verbs = null;
             tools = null;
             return;
         }
         HediffCompProperties_VerbGiver hediffCompProperties_VerbGiver = hediffDef.CompProps <HediffCompProperties_VerbGiver>();
         if (hediffCompProperties_VerbGiver == null)
         {
             verbs = null;
             tools = null;
             return;
         }
         verbs = hediffCompProperties_VerbGiver.verbs;
         tools = hediffCompProperties_VerbGiver.tools;
     }
     else
     {
         verbs = def.Verbs;
         tools = def.tools;
     }
 }
Exemple #3
0
        private static void GetFromHeddifAddiction(Table table, ThingDef def, HediffDef hediff, float doerSeverity, ThoughtDef thought)
        {
            var row = table.NewRow();

            row["DrugName".ParserTranslate()] = def.LabelCap;

            var severityPerDay = hediff.CompProps <HediffCompProperties_SeverityPerDay>()?.severityPerDay;

            if (hediff.stages.Count > 1)
            {
                var stage = hediff.stages[1];
                row["BaseSeverity".ParserTranslate()] = doerSeverity.ToString("F2");
                row["Title".ParserTranslate()]        = $"   " + "Addiction".ParserTranslate();
                //row["Description".ParserTranslate()] = $"Это единственное состояние";
                if (thought != null)
                {
                    var thoughtStages = thought.stages;
                    row["BaseMoodEffect".ParserTranslate()] = 1 < thoughtStages.Count ? thoughtStages[1].baseMoodEffect : thoughtStages.Last().baseMoodEffect;
                }

                if (severityPerDay != null)
                {
                    row["SeverityPerDay".ParserTranslate()] = ((float)severityPerDay).ToString("F2");
                    row["SeverityDays".ParserTranslate()]   = GetSeverityDays(doerSeverity, (float)severityPerDay).ToString("F2");
                }

                row["PainFactor".ParserTranslate()] = stage.painFactor.ToPercent();
                row.FillFrom(hediff.stages[0].capMods);
            }
            else
            {
                Log.Error($"[GetFromHeddifAddiction] hediff.stages.Count not standart {hediff.stages.Count}");
            }
        }
Exemple #4
0
        private static Drug GetFromHeddifTolerance(ThingDef def, HediffDef hediff, float doerSeverity, float?minToleranceToAddict = null)
        {
            var row = new Drug {
                DrugName = def.LabelCap
            };

            var severityPerDay = hediff.CompProps <HediffCompProperties_SeverityPerDay>()?.severityPerDay;

            if (minToleranceToAddict == null)
            {
                Log.Error($"[AddRowFromHeddifTolerance] minToleranceToAddict = null");
            }

            var severity = CalcSeverityLevelByMin(doerSeverity, (float)minToleranceToAddict, out int count);

            row.Label        = $"   {hediff.label}";
            row.Description  = $"Минимальная толерантность для привыкания: {minToleranceToAddict}\r\nЗа приём добавляется толерантности: {doerSeverity}\r\nШанс привыкания появится после употребленных доз: x{count}({severity})";
            row.BaseSeverity = "+" + doerSeverity.ToString("F2");

            if (minToleranceToAddict != null)
            {
                row.MinToleranceToAddict = $"{((float)minToleranceToAddict).ToString("F2")}(x{count})";
            }

            if (severityPerDay != null)
            {
                row.SeverityPerDay = ((float)severityPerDay).ToString("F2");
                row.SeverityDays   = GetSeverityDays(severity, (float)severityPerDay).ToString("F2");
            }

            return(row);
        }
 public static void GetVerbsAndTools(ThingWithComps weapon, out List <VerbProperties> verbs, out List <Tool> tools)
 {
     if (weapon.def.isTechHediff)
     {
         HediffDef hediffDef = FindTechHediffHediff(weapon);
         if (hediffDef == null)
         {
             verbs = null;
             tools = null;
             return;
         }
         HediffCompProperties_VerbGiver hediffCompProperties_VerbGiver = hediffDef.CompProps <HediffCompProperties_VerbGiver>();
         if (hediffCompProperties_VerbGiver == null)
         {
             verbs = null;
             tools = null;
             return;
         }
         verbs = hediffCompProperties_VerbGiver.verbs;
         tools = hediffCompProperties_VerbGiver.tools;
     }
     else
     {
         verbs = weapon.def.Verbs;
         tools = weapon.def.tools;
     }
 }
Exemple #6
0
        private VerbProperties TargetVerb(HediffDef parent)
        {
            var verbs = parent.CompProps <HediffCompProperties_VerbGiver>().verbs;

            return(VerbLabel.NullOrEmpty()
                ? verbs.FirstOrDefault()
                : verbs.FirstOrDefault(v => v.label == VerbLabel));
        }
Exemple #7
0
        public static float GetToleranceOffsetPerDay(ThingDef d)
        {
            HediffDef tolerance = GetTolerance(d);

            if (tolerance == null)
            {
                return(0f);
            }
            return(tolerance.CompProps <HediffCompProperties_SeverityPerDay>()?.severityPerDay ?? 0f);
        }
Exemple #8
0
        public static float GetAddictionOffsetPerDay(ThingDef d)
        {
            HediffDef hediffDef = GetChemical(d)?.addictionHediff;

            if (hediffDef == null)
            {
                return(0f);
            }
            return(hediffDef.CompProps <HediffCompProperties_SeverityPerDay>()?.severityPerDay ?? 0f);
        }
 private static void TryAddImmunityRecord2(ImmunityHandler __instance, HediffDef def, HediffDef source)
 {
     //can remove if transpiled
     if (def.CompProps <HediffCompProperties_Immunizable>() != null && !__instance.ImmunityRecordExists(def))
     {
         immunityList(__instance).Add(new ImmunityRecord
         {
             hediffDef = def,
             source    = source
         });
     }
 }
Exemple #10
0
        private static List <Drug> GetFromHeddifStages(ThingDef def, HediffDef hediff, float doerSeverity, RimWorld.ThoughtDef thought)
        {
            var result         = new List <Drug>();
            var hasThought     = thought != null;
            var severityPerDay = hediff.CompProps <HediffCompProperties_SeverityPerDay>()?.severityPerDay;

            for (int i = 0; i < hediff.stages.Count; ++i)
            {
                var stage = hediff.stages[i];

                var row = new Drug {
                    DrugName = def.LabelCap
                };

                float severity;
                if (hediff.stages.Count == 1)
                {
                    severity         = doerSeverity;
                    row.BaseSeverity = severity.ToString("F2");
                    row.Label        = $"   {(string.IsNullOrEmpty(stage.label) ? hediff.label : stage.label)}(> {stage.minSeverity})";
                    row.Description  = $"Это единственное состояние";
                }
                else
                {
                    int count = 1;
                    severity         = stage.minSeverity == 0f ? doerSeverity : CalcSeverityLevelByMin(doerSeverity, stage.minSeverity, out count);
                    row.BaseSeverity = severity.ToString("F2");
                    row.Label        = $"   {(string.IsNullOrEmpty(stage.label) ? hediff.label : stage.label)}(> {stage.minSeverity}) x{count}";
                    row.Description  = $"Это состояние начинается после: {stage.minSeverity}\r\nДля этого состояния нужно принять раз: x{count}";
                }

                if (hasThought)
                {
                    var thoughtStages = thought.stages;
                    row.BaseMoodEffect = i < thoughtStages.Count ? thoughtStages[i].baseMoodEffect : thoughtStages.Last().baseMoodEffect;
                }

                if (severityPerDay != null)
                {
                    row.SeverityPerDay = ((float)severityPerDay).ToString("F2");
                    row.SeverityDays   = GetSeverityDays(severity, (float)severityPerDay).ToString("F2");
                }

                row.PainFactor = stage.painFactor.ToPercent();

                FillCapMods(ref row, /*hediff.stages[0]*/ stage); // why was [0] wtf?

                result.Add(row);
            }

            return(result);
        }
Exemple #11
0
        /// <summary> Gets the type of the transformation. </summary>
        /// <param name="inst"> The instance. </param>
        /// <returns> The type of the transformation. </returns>
        /// <exception cref="ArgumentNullException"> inst is null </exception>
        public static MorphTransformationTypes GetTransformationType([NotNull] this HediffDef inst)
        {
            if (inst == null)
            {
                throw new ArgumentNullException(nameof(inst));
            }
            if (!typeof(TransformationBase).IsAssignableFrom(inst.hediffClass))
            {
                return(0);
            }

            var comp = inst.CompProps <HediffCompProperties_Single>();

            return(comp == null ? MorphTransformationTypes.Full : MorphTransformationTypes.Partial);
        }
Exemple #12
0
        private static void GetFromHeddifStages(Table table, ThingDef def, HediffDef hediff, float doerSeverity, ThoughtDef thought)
        {
            var severityPerDay = hediff.CompProps <HediffCompProperties_SeverityPerDay>()?.severityPerDay;

            for (int i = 0; i < hediff.stages.Count; ++i)
            {
                var stage = hediff.stages[i];

                var row = table.NewRow();
                row["DrugName".ParserTranslate()] = def.LabelCap;

                float severity;
                if (hediff.stages.Count == 1)
                {
                    severity = doerSeverity;
                    row["BaseSeverity".ParserTranslate()] = severity.ToString("F2");
                    row["Title".ParserTranslate()]        = $"   {(string.IsNullOrEmpty(stage.label) ? hediff.label : stage.label)}(> {stage.minSeverity})";
                    row["Description".ParserTranslate()]  = "ThisIsTheOnlyCondition".ParserTranslate();
                }
                else
                {
                    int count = 1;
                    severity = stage.minSeverity == 0f ? doerSeverity : CalcSeverityLevelByMin(doerSeverity, stage.minSeverity, out count);
                    row["BaseSeverity".ParserTranslate()] = severity.ToString("F2");
                    row["Title".ParserTranslate()]        = $"   {(string.IsNullOrEmpty(stage.label) ? hediff.label : stage.label)}(> {stage.minSeverity}) x{count}";
                    row["Description".ParserTranslate()]  = "ThisStateStartsAfter".ParserTranslate(stage.minSeverity) + "\r\n" + "ForThisStateYouNeedToTakeTimes".ParserTranslate(count);
                }

                if (thought != null)
                {
                    var thoughtStages = thought.stages;
                    row["BaseMoodEffect".ParserTranslate()] = i < thoughtStages.Count ? thoughtStages[i].baseMoodEffect : thoughtStages.Last().baseMoodEffect;
                }

                if (severityPerDay != null)
                {
                    row["SeverityPerDay".ParserTranslate()] = ((float)severityPerDay).ToString("F2");
                    row["SeverityDays".ParserTranslate()]   = GetSeverityDays(severity, (float)severityPerDay).ToString("F2");
                }

                row["PainFactor".ParserTranslate()] = stage.painFactor.ToPercent();

                row.FillFrom(/*hediff.stages[0]*/ stage.capMods); // why was [0] wtf?
            }
        }
Exemple #13
0
        private static Drug GetFromHeddifAddiction(ThingDef def, HediffDef hediff, float doerSeverity, ThoughtDef thought)
        {
            var row = new Drug {
                DrugName = def.LabelCap
            };

            var hasThought     = thought != null;
            var severityPerDay = hediff.CompProps <HediffCompProperties_SeverityPerDay>()?.severityPerDay;

            if (hediff.stages.Count > 1)
            {
                var stage = hediff.stages[1];
                row.BaseSeverity = doerSeverity.ToString("F2");
                row.Label        = $"   Ломка";
                //row.Description = $"Это единственное состояние";
                if (hasThought)
                {
                    var thoughtStages = thought.stages;
                    row.BaseMoodEffect = 1 < thoughtStages.Count ? thoughtStages[1].baseMoodEffect : thoughtStages.Last().baseMoodEffect;
                }

                if (severityPerDay != null)
                {
                    row.SeverityPerDay = ((float)severityPerDay).ToString("F2");
                    row.SeverityDays   = GetSeverityDays(doerSeverity, (float)severityPerDay).ToString("F2");
                }

                row.PainFactor = stage.painFactor.ToPercent();

                FillCapMods(ref row, hediff.stages[0]);
            }
            else
            {
                Log.Error($"[GetFromHeddifAddiction] hediff.stages.Count not standart {hediff.stages.Count}");
            }

            return(row);
        }
Exemple #14
0
        public static TaggedString CheckForViolations(Pawn pawn, HediffDef hediff, int levelOffset)
        {
            if (levelOffset < 0)
            {
                return("");
            }
            if (pawn.Faction != Faction.OfPlayer || !hediff.HasComp(typeof(HediffComp_RoyalImplant)))
            {
                return("");
            }
            Hediff_ImplantWithLevel hediff_ImplantWithLevel = (Hediff_ImplantWithLevel)pawn.health.hediffSet.hediffs.FirstOrDefault((Hediff h) => h.def == hediff);
            int num = (levelOffset != 0 && hediff_ImplantWithLevel != null) ? (hediff_ImplantWithLevel.level + levelOffset) : 0;

            foreach (Faction item in Find.FactionManager.AllFactionsListForReading)
            {
                if (pawn.Faction != null && !item.def.hidden && !item.HostileTo(Faction.OfPlayer) && ThingRequiringRoyalPermissionUtility.IsViolatingRulesOf(hediff, pawn, item, num))
                {
                    RoyalTitleDef minTitleForImplant = item.GetMinTitleForImplant(hediff, num);
                    HediffCompProperties_RoyalImplant hediffCompProperties_RoyalImplant = hediff.CompProps <HediffCompProperties_RoyalImplant>();
                    string       arg          = hediff.label + ((num == 0) ? "" : (" (" + num + "x)"));
                    TaggedString taggedString = hediffCompProperties_RoyalImplant.violationTriggerDescriptionKey.Translate(pawn.Named("PAWN"));
                    TaggedString t            = "RoyalImplantIllegalUseWarning".Translate(pawn.Named("PAWN"), arg.Named("IMPLANT"), item.Named("FACTION"), minTitleForImplant.GetLabelCapFor(pawn).Named("TITLE"), taggedString.Named("VIOLATIONTRIGGER"));
                    if (levelOffset != 0)
                    {
                        return(t + ("\n\n" + "RoyalImplantUpgradeConfirmation".Translate()));
                    }
                    return(t + ("\n\n" + "RoyalImplantInstallConfirmation".Translate()));
                }
            }
            return("");
        }