Пример #1
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);
        }
Пример #2
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);
        }
Пример #3
0
        public override string GetStatDrawEntryLabel(StatDef stat, float value, ToStringNumberSense numberSense, StatRequest optionalReq, bool finalized = true)
        {
            float num  = 0f;
            float num2 = 0f;
            bool  flag = false;

            if (optionalReq.Thing != null && optionalReq.Thing.Spawned)
            {
                num = (num2 = optionalReq.Thing.def.GetStatValueAbstract(stat));
                Thing thing = optionalReq.Thing;
                CompStatOffsetBase compStatOffsetBase = thing.TryGetComp <CompStatOffsetBase>();
                if (compStatOffsetBase != null && compStatOffsetBase.Props.statDef == stat)
                {
                    for (int i = 0; i < compStatOffsetBase.Props.offsets.Count; i++)
                    {
                        FocusStrengthOffset focusStrengthOffset = compStatOffsetBase.Props.offsets[i];
                        if (!focusStrengthOffset.DependsOnPawn)
                        {
                            if (focusStrengthOffset.CanApply(thing))
                            {
                                float offset = focusStrengthOffset.GetOffset(thing);
                                num  += offset;
                                num2 += offset;
                            }
                        }
                        else
                        {
                            flag = true;
                        }
                    }
                }
            }
            else if (optionalReq.Def is ThingDef)
            {
                (num2, num) = AbstractValueRange(optionalReq, numberSense);
            }
            string str = (flag ? " (+)" : "");

            return(RangeToString(num2, num, numberSense, finalized) + str);
        }