コード例 #1
0
        // Token: 0x06000057 RID: 87 RVA: 0x000057F8 File Offset: 0x000039F8
        public static void ChkMSImmunisation(Pawn p, out string Reason, out bool Passed)
        {
            Reason = null;
            if (!p.RaceProps.Humanlike)
            {
                Passed = false;
                Reason = "MSExotic.NotHumanLike".Translate(p?.LabelShort.CapitalizeFirst());
                return;
            }
            TraitDef Immunity = DefDatabase <TraitDef> .GetNamed("Immunity", true);

            if (p.story.traits.HasTrait(Immunity) && p != null)
            {
                Pawn_StoryTracker story = p.story;
                int?num;
                if (story == null)
                {
                    num = null;
                }
                else
                {
                    TraitSet traits = story.traits;
                    num = ((traits != null) ? new int?(traits.GetTrait(Immunity).Degree) : null);
                }
                int?num2 = num;
                int num3 = 1;
                if (num2.GetValueOrDefault() == num3 & num2 != null)
                {
                    Passed = false;
                    Reason = "MSExotic.AlreadyHasImmunity".Translate(p?.LabelShort.CapitalizeFirst());
                    return;
                }
            }
            Passed = true;
        }
コード例 #2
0
        /// <summary>
        /// checks if the given pawn passes the restriction.
        /// </summary>
        /// <param name="pawn">The pawn.</param>
        /// <returns>
        /// if the def can be used with the given pawn
        /// </returns>
        /// <exception cref="ArgumentNullException">pawn</exception>
        protected override bool PassesRestrictionImpl(Pawn pawn)
        {
            if (pawn == null)
            {
                throw new ArgumentNullException(nameof(pawn));
            }
            TraitSet storyTraits = pawn.story?.traits;

            if (storyTraits == null)
            {
                return(false);
            }

            foreach (Entry entry in entries) //check all entries
            {
                var tInfo = storyTraits.GetTrait(entry.trait);
                if (tInfo == null)
                {
                    continue;
                }
                if (entry.traitDegree < 0)
                {
                    return(true);                       //if the entry has a traitDegree less then zero, this means any degree will pass
                }
                if (entry.traitDegree == tInfo.Degree)
                {
                    return(true);                                    //otherwise they must match
                }
            }

            return(false);
        }
コード例 #3
0
        public static void RemoveTrait(this TraitSet traits, TraitDef traitDef)
        {
            var trait = traits.GetTrait(traitDef);

            if (trait == null)
            {
                return;
            }
            traits.allTraits.Remove(trait);
        }
コード例 #4
0
        // Token: 0x06000056 RID: 86 RVA: 0x0000571C File Offset: 0x0000391C
        public static void DoMSImmunisation(Pawn p, ThingDef t)
        {
            bool           Sickly   = false;
            MessageTypeDef MsgType  = MessageTypeDefOf.PositiveEvent;
            TraitDef       Immunity = DefDatabase <TraitDef> .GetNamed("Immunity", true);

            if (p.story.traits.HasTrait(Immunity) && p != null)
            {
                Pawn_StoryTracker story = p.story;
                int?num;
                if (story == null)
                {
                    num = null;
                }
                else
                {
                    TraitSet traits = story.traits;
                    num = ((traits != null) ? new int?(traits.GetTrait(Immunity).Degree) : null);
                }
                int?num2 = num;
                int num3 = -1;
                if (num2.GetValueOrDefault() == num3 & num2 != null)
                {
                    Sickly = true;
                }
            }
            if (Sickly)
            {
                Pawn_StoryTracker story2 = p.story;
                Trait             trait;
                if (story2 == null)
                {
                    trait = null;
                }
                else
                {
                    TraitSet traits2 = story2.traits;
                    trait = (traits2?.GetTrait(Immunity));
                }
                Trait ToGo = trait;
                MSTraitChanger.RemoveTrait(p, ToGo, t.label, MsgType, true);
                return;
            }
            Trait ToAdd = new Trait(Immunity, 1, false);

            MSTraitChanger.AddTrait(p, ToAdd, t.label, MsgType, true);
        }
コード例 #5
0
        // Token: 0x06000058 RID: 88 RVA: 0x000058E0 File Offset: 0x00003AE0
        public static void DoMSCerebrax(Pawn p, ThingDef t)
        {
            int            degree  = 0;
            MessageTypeDef MsgType = MessageTypeDefOf.PositiveEvent;
            TraitDef       Psych   = DefDatabase <TraitDef> .GetNamed("PsychicSensitivity", true);

            if (p.story.traits.HasTrait(Psych))
            {
                degree = p.story.traits.GetTrait(Psych).Degree;
            }
            if (degree == 2)
            {
                Pawn_StoryTracker story = p.story;
                Trait             trait;
                if (story == null)
                {
                    trait = null;
                }
                else
                {
                    TraitSet traits = story.traits;
                    trait = (traits?.GetTrait(Psych));
                }
                Trait ToGo = trait;
                MSTraitChanger.RemoveTrait(p, ToGo, t.label, MsgType, true);
                Trait ToAdd = new Trait(Psych, 1, false);
                MSTraitChanger.AddTrait(p, ToAdd, t.label, MsgType, false);
                return;
            }
            if (degree == 1)
            {
                Pawn_StoryTracker story2 = p.story;
                Trait             trait2;
                if (story2 == null)
                {
                    trait2 = null;
                }
                else
                {
                    TraitSet traits2 = story2.traits;
                    trait2 = (traits2?.GetTrait(Psych));
                }
                Trait ToGo2 = trait2;
                MSTraitChanger.RemoveTrait(p, ToGo2, t.label, MsgType, true);
            }
        }
コード例 #6
0
        // Token: 0x06000059 RID: 89 RVA: 0x000059B0 File Offset: 0x00003BB0
        public static void ChkMSCerebrax(Pawn p, out string Reason, out bool Passed)
        {
            Reason = null;
            if (!p.RaceProps.Humanlike)
            {
                Passed = false;
                Reason = "MSExotic.NotHumanLike".Translate(p?.LabelShort.CapitalizeFirst());
                return;
            }
            TraitDef Psych = DefDatabase <TraitDef> .GetNamed("PsychicSensitivity", true);

            if (p.story.traits.HasTrait(Psych))
            {
                if (p != null)
                {
                    Pawn_StoryTracker story = p.story;
                    int?num;
                    if (story == null)
                    {
                        num = null;
                    }
                    else
                    {
                        TraitSet traits = story.traits;
                        num = ((traits != null) ? new int?(traits.GetTrait(Psych).Degree) : null);
                    }
                    int?num2 = num;
                    int num3 = 0;
                    if (num2.GetValueOrDefault() <= num3 & num2 != null)
                    {
                        Passed = false;
                        Reason = "MSExotic.HasNoPsychSensitivity".Translate(p?.LabelShort.CapitalizeFirst());
                        return;
                    }
                }
                Passed = true;
                return;
            }
            Passed = false;
            Reason = "MSExotic.HasNoPsychSensitivity".Translate(p?.LabelShort.CapitalizeFirst());
        }