Ejemplo n.º 1
0
        public override string GetStatDrawEntryLabel(StatDef stat, float value, ToStringNumberSense numberSense, StatRequest optionalReq, bool finalized = true)
        {
            float    num  = 0f;
            float    num2 = 0f;
            ThingDef thingDef;

            if (optionalReq.Thing != null)
            {
                num2 = optionalReq.Thing.def.GetStatValueAbstract(stat);
                CompStatOffsetBase compStatOffsetBase = optionalReq.Thing.TryGetComp <CompStatOffsetBase>();
                if (compStatOffsetBase != null && compStatOffsetBase.Props.statDef == stat)
                {
                    num = compStatOffsetBase.Props.GetMaxOffset();
                }
            }
            else if ((thingDef = (optionalReq.Def as ThingDef)) != null)
            {
                num2 = thingDef.GetStatValueAbstract(stat);
                CompProperties_MeditationFocus compProperties = thingDef.GetCompProperties <CompProperties_MeditationFocus>();
                if (compProperties != null && compProperties.statDef == stat)
                {
                    num = compProperties.GetMaxOffset(forAbstract: true);
                }
            }
            if (num != 0f)
            {
                float  num3 = num2 + num;
                float  f    = (num > 0f) ? num2 : num3;
                float  val  = (num > 0f) ? num3 : num2;
                string str  = f.ToStringByStyle(stat.toStringStyle, numberSense);
                string str2 = stat.ValueToString(val, numberSense, finalized);
                return(str + " - " + str2);
            }
            return(stat.ValueToString(value, numberSense, finalized));
        }
        public static string FocusTypeAvailableExplanation(Pawn pawn)
        {
            string text = "";

            for (int i = 0; i < DefDatabase <MeditationFocusDef> .AllDefsListForReading.Count; i++)
            {
                MeditationFocusDef meditationFocusDef = DefDatabase <MeditationFocusDef> .AllDefsListForReading[i];
                if (!meditationFocusDef.CanPawnUse(pawn))
                {
                    continue;
                }
                text = text + "MeditationFocusCanUse".Translate(meditationFocusDef.label).RawText + ":\n" + meditationFocusDef.EnablingThingsExplanation(pawn) + "\n\n";
                if (!focusObjectsPerTypeCache.ContainsKey(meditationFocusDef))
                {
                    List <string> list = new List <string>();
                    foreach (ThingDef item in DefDatabase <ThingDef> .AllDefsListForReading)
                    {
                        CompProperties_MeditationFocus compProperties = item.GetCompProperties <CompProperties_MeditationFocus>();
                        if (compProperties != null && compProperties.focusTypes.Contains(meditationFocusDef))
                        {
                            list.AddDistinct(item.label);
                        }
                    }
                    focusObjectsPerTypeCache[meditationFocusDef] = list.ToLineList("  - ", capitalizeItems: true);
                }
                text += "MeditationFocusObjects".Translate(meditationFocusDef.label).CapitalizeFirst() + ":\n" + focusObjectsPerTypeCache[meditationFocusDef] + "\n\n";
            }
            return(text);
        }
 public static IEnumerable <Dialog_InfoCard.Hyperlink> FocusObjectsForPawnHyperlinks(Pawn pawn)
 {
     for (int i = 0; i < DefDatabase <MeditationFocusDef> .AllDefsListForReading.Count; i++)
     {
         MeditationFocusDef meditationFocusDef = DefDatabase <MeditationFocusDef> .AllDefsListForReading[i];
         if (!meditationFocusDef.CanPawnUse(pawn))
         {
             continue;
         }
         if (!focusObjectHyperlinksPerTypeCache.ContainsKey(meditationFocusDef))
         {
             List <Dialog_InfoCard.Hyperlink> list2 = new List <Dialog_InfoCard.Hyperlink>();
             foreach (ThingDef item in DefDatabase <ThingDef> .AllDefsListForReading)
             {
                 CompProperties_MeditationFocus compProperties = item.GetCompProperties <CompProperties_MeditationFocus>();
                 if (compProperties != null && compProperties.focusTypes.Contains(meditationFocusDef))
                 {
                     list2.Add(new Dialog_InfoCard.Hyperlink(item));
                 }
             }
             focusObjectHyperlinksPerTypeCache[meditationFocusDef] = list2;
         }
         List <Dialog_InfoCard.Hyperlink> list = focusObjectHyperlinksPerTypeCache[meditationFocusDef];
         for (int j = 0; j < list.Count; j++)
         {
             yield return(list[j]);
         }
     }
 }
Ejemplo n.º 4
0
        private (float, float) AbstractValueRange(StatRequest req, ToStringNumberSense numberSense)
        {
            ThingDef obj = (ThingDef)req.Def;
            float    num;
            float    num2 = (num = obj.GetStatValueAbstract(stat));
            CompProperties_MeditationFocus compProperties = obj.GetCompProperties <CompProperties_MeditationFocus>();

            if (compProperties != null && compProperties.statDef == stat)
            {
                for (int i = 0; i < compProperties.offsets.Count; i++)
                {
                    FocusStrengthOffset focusStrengthOffset = compProperties.offsets[i];
                    if (!focusStrengthOffset.NeedsToBeSpawned && req.Thing != null)
                    {
                        num += focusStrengthOffset.GetOffset(req.Thing);
                        continue;
                    }
                    float num3 = focusStrengthOffset.MinOffset();
                    float num4 = focusStrengthOffset.MaxOffset();
                    if (num4 > 0f)
                    {
                        num2 += num4;
                    }
                    if (num4 < 0f)
                    {
                        num += num4;
                    }
                    num += num3;
                }
            }
            return(num, num2);
        }
Ejemplo n.º 5
0
        public override string GetExplanationUnfinalized(StatRequest req, ToStringNumberSense numberSense)
        {
            string        explanationUnfinalized = base.GetExplanationUnfinalized(req, numberSense);
            StringBuilder stringBuilder          = new StringBuilder();
            ThingDef      thingDef;

            if (req.Thing != null)
            {
                Thing thing = req.Thing;
                CompStatOffsetBase compStatOffsetBase = thing.TryGetComp <CompStatOffsetBase>();
                List <string>      list  = new List <string>();
                List <string>      list2 = new List <string>();
                if (compStatOffsetBase != null && compStatOffsetBase.Props.statDef == stat)
                {
                    stringBuilder.AppendLine();
                    for (int i = 0; i < compStatOffsetBase.Props.offsets.Count; i++)
                    {
                        FocusStrengthOffset focusStrengthOffset = compStatOffsetBase.Props.offsets[i];
                        if (focusStrengthOffset.CanApply(thing))
                        {
                            list.Add(focusStrengthOffset.GetExplanation(thing));
                        }
                        else
                        {
                            list2.Add(focusStrengthOffset.GetExplanationAbstract(thing.def));
                        }
                    }
                    if (list.Count > 0)
                    {
                        stringBuilder.AppendLine(list.ToLineList());
                    }
                    if (list2.Count > 0)
                    {
                        if (list.Count > 0)
                        {
                            stringBuilder.AppendLine();
                        }
                        stringBuilder.AppendLine("StatReport_PossibleOffsets".Translate() + ":");
                        stringBuilder.AppendLine(list2.ToLineList("  - "));
                    }
                }
            }
            else if ((thingDef = req.Def as ThingDef) != null)
            {
                CompProperties_MeditationFocus compProperties = thingDef.GetCompProperties <CompProperties_MeditationFocus>();
                if (compProperties != null && compProperties.offsets.Count > 0 && compProperties.statDef == stat)
                {
                    stringBuilder.AppendLine();
                    stringBuilder.AppendLine("StatReport_PossibleOffsets".Translate() + ":");
                    stringBuilder.AppendLine(compProperties.GetExplanationAbstract(thingDef).ToLineList("  - "));
                }
            }
            return(explanationUnfinalized + stringBuilder);
        }