예제 #1
0
        public override void DoEditInterface(Listing_ScenEdit listing)
        {
            Rect scenPartRect = listing.GetScenPartRect(this, ScenPart.RowHeight * 3f);

            if (Widgets.ButtonText(scenPartRect.TopPart(0.333f), this.trait.DataAtDegree(this.degree).label.CapitalizeFirst(), true, false, true))
            {
                List <FloatMenuOption> list = new List <FloatMenuOption>();
                foreach (TraitDef current in from td in DefDatabase <TraitDef> .AllDefs
                         orderby td.label
                         select td)
                {
                    foreach (TraitDegreeData current2 in current.degreeDatas)
                    {
                        TraitDef        localDef = current;
                        TraitDegreeData localDeg = current2;
                        list.Add(new FloatMenuOption(localDeg.label.CapitalizeFirst(), delegate
                        {
                            this.trait  = localDef;
                            this.degree = localDeg.degree;
                        }, MenuOptionPriority.Default, null, null, 0f, null, null));
                    }
                }
                Find.WindowStack.Add(new FloatMenu(list));
            }
            base.DoPawnModifierEditInterface(scenPartRect.BottomPart(0.666f));
        }
예제 #2
0
        public override void DoEditInterface(Listing_ScenEdit listing)
        {
            Rect scenPartRect = listing.GetScenPartRect(this, ScenPart.RowHeight * 3f);

            if (Widgets.ButtonText(scenPartRect.TopPart(0.333f), trait.DataAtDegree(degree).label.CapitalizeFirst()))
            {
                List <FloatMenuOption> list = new List <FloatMenuOption>();
                foreach (TraitDef item in from td in DefDatabase <TraitDef> .AllDefs
                         orderby td.label
                         select td)
                {
                    foreach (TraitDegreeData degreeData in item.degreeDatas)
                    {
                        TraitDef        localDef = item;
                        TraitDegreeData localDeg = degreeData;
                        list.Add(new FloatMenuOption(localDeg.label.CapitalizeFirst(), delegate
                        {
                            trait  = localDef;
                            degree = localDeg.degree;
                        }));
                    }
                }
                Find.WindowStack.Add(new FloatMenu(list));
            }
            DoPawnModifierEditInterface(scenPartRect.BottomPart(0.666f));
        }
예제 #3
0
        private IEnumerable <ThoughtDef> GetPermaThoughts()
        {
            TraitDegreeData   degree      = this.CurrentData;
            List <ThoughtDef> allThoughts = DefDatabase <ThoughtDef> .AllDefsListForReading;
            int i = 0;

            while (true)
            {
                if (i < allThoughts.Count)
                {
                    if (allThoughts[i].IsSituational && allThoughts[i].Worker is ThoughtWorker_AlwaysActive && allThoughts[i].requiredTraits != null && allThoughts[i].requiredTraits.Contains(this.def))
                    {
                        if (!allThoughts[i].RequiresSpecificTraitsDegree)
                        {
                            break;
                        }
                        if (allThoughts[i].requiredTraitsDegree == degree.degree)
                        {
                            break;
                        }
                    }
                    i++;
                    continue;
                }
                yield break;
            }
            yield return(allThoughts[i]);

            /*Error: Unable to find new state assignment for yield return*/;
        }
예제 #4
0
 public override IEnumerable <string> ConfigErrors()
 {
     foreach (string err in this.< ConfigErrors > __BaseCallProxy0())
     {
         yield return(err);
     }
     if (this.commonality < 0.001f && this.commonalityFemale < 0.001f)
     {
         yield return("TraitDef " + this.defName + " has 0 commonality.");
     }
     if (!this.degreeDatas.Any <TraitDegreeData>())
     {
         yield return(this.defName + " has no degree datas.");
     }
     for (int i = 0; i < this.degreeDatas.Count; i++)
     {
         TraitDegreeData dd = this.degreeDatas[i];
         if ((from dd2 in this.degreeDatas
              where dd2.degree == dd.degree
              select dd2).Count <TraitDegreeData>() > 1)
         {
             yield return(">1 datas for degree " + dd.degree);
         }
     }
     yield break;
 }
예제 #5
0
        public void Notify_MentalStateEndedOn(Pawn pawn)
        {
            TraitDegreeData currentData = CurrentData;

            if (!currentData.mentalBreakInspirationGainSet.NullOrEmpty() && !(Rand.Value > currentData.mentalBreakInspirationGainChance))
            {
                pawn.mindState.inspirationHandler.TryStartInspiration_NewTemp(currentData.mentalBreakInspirationGainSet.RandomElement(), currentData.mentalBreakInspirationGainReasonText);
            }
        }
예제 #6
0
        private IEnumerable <ThoughtDef> GetPermaThoughts()
        {
            TraitDegreeData   degree      = CurrentData;
            List <ThoughtDef> allThoughts = DefDatabase <ThoughtDef> .AllDefsListForReading;

            for (int i = 0; i < allThoughts.Count; i++)
            {
                if (allThoughts[i].IsSituational && allThoughts[i].Worker is ThoughtWorker_AlwaysActive && allThoughts[i].requiredTraits != null && allThoughts[i].requiredTraits.Contains(def) && (!allThoughts[i].RequiresSpecificTraitsDegree || allThoughts[i].requiredTraitsDegree == degree.degree))
                {
                    yield return(allThoughts[i]);
                }
            }
        }
예제 #7
0
 public static IEnumerable <Trait> GetTraitsAffectingPsylinkNegatively(Pawn p)
 {
     if (p.story != null && p.story.traits != null && !p.story.traits.allTraits.NullOrEmpty())
     {
         foreach (Trait allTrait in p.story.traits.allTraits)
         {
             TraitDegreeData traitDegreeData = allTrait.def.DataAtDegree(allTrait.Degree);
             if ((traitDegreeData.statFactors != null && traitDegreeData.statFactors.Any((StatModifier f) => f.stat == StatDefOf.PsychicSensitivity && f.value < 1f)) || (traitDegreeData.statOffsets != null && traitDegreeData.statOffsets.Any((StatModifier f) => f.stat == StatDefOf.PsychicSensitivity && f.value < 0f)))
             {
                 yield return(allTrait);
             }
         }
     }
 }
예제 #8
0
        public float MultiplierOfStat(StatDef stat)
        {
            float           num         = 1f;
            TraitDegreeData currentData = this.CurrentData;

            if (currentData.statFactors != null)
            {
                for (int i = 0; i < currentData.statFactors.Count; i++)
                {
                    if (currentData.statFactors[i].stat == stat)
                    {
                        num *= currentData.statFactors[i].value;
                    }
                }
            }
            return(num);
        }
예제 #9
0
        public float OffsetOfStat(StatDef stat)
        {
            float           num         = 0f;
            TraitDegreeData currentData = this.CurrentData;

            if (currentData.statOffsets != null)
            {
                for (int i = 0; i < currentData.statOffsets.Count; i++)
                {
                    if (currentData.statOffsets[i].stat == stat)
                    {
                        num += currentData.statOffsets[i].value;
                    }
                }
            }
            return(num);
        }
예제 #10
0
 public override IEnumerable <string> ConfigErrors()
 {
     foreach (string item in base.ConfigErrors())
     {
         yield return(item);
     }
     if (commonality < 0.001f && commonalityFemale < 0.001f)
     {
         yield return("TraitDef " + defName + " has 0 commonality.");
     }
     if (!degreeDatas.Any())
     {
         yield return(defName + " has no degree datas.");
     }
     for (int i = 0; i < degreeDatas.Count; i++)
     {
         TraitDegreeData dd3 = degreeDatas[i];
         if (degreeDatas.Where((TraitDegreeData dd2) => dd2.degree == dd3.degree).Count() > 1)
         {
             yield return(">1 datas for degree " + dd3.degree);
         }
     }
 }
예제 #11
0
        public string TipString(Pawn pawn)
        {
            StringBuilder   stringBuilder = new StringBuilder();
            TraitDegreeData currentData   = this.CurrentData;

            stringBuilder.Append(currentData.description.AdjustedFor(pawn));
            int count = this.CurrentData.skillGains.Count;

            if (count > 0)
            {
                stringBuilder.AppendLine();
                stringBuilder.AppendLine();
            }
            int num = 0;

            foreach (KeyValuePair <SkillDef, int> skillGain in this.CurrentData.skillGains)
            {
                if (skillGain.Value != 0)
                {
                    string value = "    " + skillGain.Key.skillLabel.CapitalizeFirst() + ":   " + skillGain.Value.ToString("+##;-##");
                    if (num < count - 1)
                    {
                        stringBuilder.AppendLine(value);
                    }
                    else
                    {
                        stringBuilder.Append(value);
                    }
                    num++;
                }
            }
            if (this.GetPermaThoughts().Any())
            {
                stringBuilder.AppendLine();
                foreach (ThoughtDef permaThought in this.GetPermaThoughts())
                {
                    stringBuilder.AppendLine();
                    stringBuilder.Append("    " + "PermanentMoodEffect".Translate() + " " + permaThought.stages[0].baseMoodEffect.ToStringByStyle(ToStringStyle.Integer, ToStringNumberSense.Offset));
                }
            }
            if (currentData.statOffsets != null)
            {
                stringBuilder.AppendLine();
                stringBuilder.AppendLine();
                for (int i = 0; i < currentData.statOffsets.Count; i++)
                {
                    StatModifier statModifier          = currentData.statOffsets[i];
                    string       valueToStringAsOffset = statModifier.ValueToStringAsOffset;
                    string       value2 = "    " + statModifier.stat.LabelCap + " " + valueToStringAsOffset;
                    if (i < currentData.statOffsets.Count - 1)
                    {
                        stringBuilder.AppendLine(value2);
                    }
                    else
                    {
                        stringBuilder.Append(value2);
                    }
                }
            }
            if (currentData.statFactors != null)
            {
                stringBuilder.AppendLine();
                stringBuilder.AppendLine();
                for (int j = 0; j < currentData.statFactors.Count; j++)
                {
                    StatModifier statModifier2    = currentData.statFactors[j];
                    string       toStringAsFactor = statModifier2.ToStringAsFactor;
                    string       value3           = "    " + statModifier2.stat.LabelCap + " " + toStringAsFactor;
                    if (j < currentData.statFactors.Count - 1)
                    {
                        stringBuilder.AppendLine(value3);
                    }
                    else
                    {
                        stringBuilder.Append(value3);
                    }
                }
            }
            return(stringBuilder.ToString());
        }
예제 #12
0
        public string TipString(Pawn pawn)
        {
            StringBuilder   stringBuilder = new StringBuilder();
            TraitDegreeData currentData   = CurrentData;

            stringBuilder.Append(currentData.description.Formatted(pawn.Named("PAWN")).AdjustedFor(pawn).Resolve());
            bool num   = CurrentData.skillGains.Count > 0;
            bool flag  = GetPermaThoughts().Any();
            bool flag2 = currentData.statOffsets != null;
            bool flag3 = currentData.statFactors != null;

            if (num || flag || flag2 || flag3)
            {
                stringBuilder.AppendLine();
                stringBuilder.AppendLine();
            }
            if (num)
            {
                foreach (KeyValuePair <SkillDef, int> skillGain in CurrentData.skillGains)
                {
                    if (skillGain.Value != 0)
                    {
                        string value = "    " + skillGain.Key.skillLabel.CapitalizeFirst() + ":   " + skillGain.Value.ToString("+##;-##");
                        stringBuilder.AppendLine(value);
                    }
                }
            }
            if (flag)
            {
                foreach (ThoughtDef permaThought in GetPermaThoughts())
                {
                    stringBuilder.AppendLine("    " + "PermanentMoodEffect".Translate() + " " + permaThought.stages[0].baseMoodEffect.ToStringByStyle(ToStringStyle.Integer, ToStringNumberSense.Offset));
                }
            }
            if (flag2)
            {
                for (int i = 0; i < currentData.statOffsets.Count; i++)
                {
                    StatModifier statModifier          = currentData.statOffsets[i];
                    string       valueToStringAsOffset = statModifier.ValueToStringAsOffset;
                    string       value2 = "    " + statModifier.stat.LabelCap + " " + valueToStringAsOffset;
                    stringBuilder.AppendLine(value2);
                }
            }
            if (flag3)
            {
                for (int j = 0; j < currentData.statFactors.Count; j++)
                {
                    StatModifier statModifier2    = currentData.statFactors[j];
                    string       toStringAsFactor = statModifier2.ToStringAsFactor;
                    string       value3           = "    " + statModifier2.stat.LabelCap + " " + toStringAsFactor;
                    stringBuilder.AppendLine(value3);
                }
            }
            if (currentData.hungerRateFactor != 1f)
            {
                string t      = currentData.hungerRateFactor.ToStringByStyle(ToStringStyle.PercentOne, ToStringNumberSense.Factor);
                string value4 = "    " + "HungerRate".Translate() + " " + t;
                stringBuilder.AppendLine(value4);
            }
            if (ModsConfig.RoyaltyActive)
            {
                List <MeditationFocusDef> allowedMeditationFocusTypes = CurrentData.allowedMeditationFocusTypes;
                if (!allowedMeditationFocusTypes.NullOrEmpty())
                {
                    stringBuilder.AppendLine();
                    stringBuilder.AppendLine();
                    stringBuilder.AppendLine("EnablesMeditationFocusType".Translate() + ":\n" + allowedMeditationFocusTypes.Select((MeditationFocusDef f) => f.LabelCap.RawText).ToLineList("  - "));
                }
            }
            if (stringBuilder.Length > 0 && stringBuilder[stringBuilder.Length - 1] == '\n')
            {
                if (stringBuilder.Length > 1 && stringBuilder[stringBuilder.Length - 2] == '\r')
                {
                    stringBuilder.Remove(stringBuilder.Length - 2, 2);
                }
                else
                {
                    stringBuilder.Remove(stringBuilder.Length - 1, 1);
                }
            }
            return(stringBuilder.ToString());
        }