Пример #1
0
        private Thought_SituationalSocial TryCreateSocialThought(ThoughtDef def, Pawn otherPawn)
        {
            Thought_SituationalSocial thought_SituationalSocial = null;

            try
            {
                if (!ThoughtUtility.CanGetThought_NewTemp(pawn, def))
                {
                    return(null);
                }
                if (!def.Worker.CurrentSocialState(pawn, otherPawn).ActiveFor(def))
                {
                    return(null);
                }
                thought_SituationalSocial           = (Thought_SituationalSocial)ThoughtMaker.MakeThought(def);
                thought_SituationalSocial.pawn      = pawn;
                thought_SituationalSocial.otherPawn = otherPawn;
                thought_SituationalSocial.RecalculateState();
                return(thought_SituationalSocial);
            }
            catch (Exception ex)
            {
                Log.Error(string.Concat("Exception while recalculating ", def, " thought state for pawn ", pawn, ": ", ex));
                return(thought_SituationalSocial);
            }
        }
Пример #2
0
 protected override Job TryGiveJob(Pawn pawn)
 {
     if (!pawn.guest.PrisonerIsSecure || pawn.apparel == null)
     {
         return(null);
     }
     if (ThoughtUtility.CanGetThought_NewTemp(pawn, ThoughtDefOf.ClothedNudist, checkIfNullified: true) && pawn.AmbientTemperature >= pawn.SafeTemperatureRange().min)
     {
         return(null);
     }
     if (pawn.royalty != null && pawn.royalty.AllTitlesInEffectForReading.Count > 0)
     {
         RoyalTitleDef def = pawn.royalty.MostSeniorTitle.def;
         if (def != null && def.requiredApparel != null)
         {
             for (int i = 0; i < def.requiredApparel.Count; i++)
             {
                 if (!def.requiredApparel[i].IsMet(pawn))
                 {
                     Apparel apparel = FindGarmentSatisfyingTitleRequirement(pawn, def.requiredApparel[i]);
                     if (apparel != null)
                     {
                         Job job = JobMaker.MakeJob(JobDefOf.Wear, apparel);
                         job.ignoreForbidden = true;
                         return(job);
                     }
                 }
             }
         }
     }
     if (!pawn.apparel.BodyPartGroupIsCovered(BodyPartGroupDefOf.Legs))
     {
         Apparel apparel2 = FindGarmentCoveringPart(pawn, BodyPartGroupDefOf.Legs);
         if (apparel2 != null)
         {
             Job job2 = JobMaker.MakeJob(JobDefOf.Wear, apparel2);
             job2.ignoreForbidden = true;
             return(job2);
         }
     }
     if (!pawn.apparel.BodyPartGroupIsCovered(BodyPartGroupDefOf.Torso))
     {
         Apparel apparel3 = FindGarmentCoveringPart(pawn, BodyPartGroupDefOf.Torso);
         if (apparel3 != null)
         {
             Job job3 = JobMaker.MakeJob(JobDefOf.Wear, apparel3);
             job3.ignoreForbidden = true;
             return(job3);
         }
     }
     return(null);
 }
Пример #3
0
 public void TryGainMemory(Thought_Memory newThought, Pawn otherPawn = null)
 {
     if (!ThoughtUtility.CanGetThought_NewTemp(pawn, newThought.def))
     {
         return;
     }
     if (newThought is Thought_MemorySocial && newThought.otherPawn == null && otherPawn == null)
     {
         Log.Error(string.Concat("Can't gain social thought ", newThought.def, " because its otherPawn is null and otherPawn passed to this method is also null. Social thoughts must have otherPawn."));
         return;
     }
     newThought.pawn      = pawn;
     newThought.otherPawn = otherPawn;
     if (!newThought.TryMergeWithExistingMemory(out var showBubble))
     {
         memories.Add(newThought);
     }
     if (newThought.def.stackLimitForSameOtherPawn >= 0)
     {
         while (NumMemoriesInGroup(newThought) > newThought.def.stackLimitForSameOtherPawn)
         {
             RemoveMemory(OldestMemoryInGroup(newThought));
         }
     }
     if (newThought.def.stackLimit >= 0)
     {
         while (NumMemoriesOfDef(newThought.def) > newThought.def.stackLimit)
         {
             RemoveMemory(OldestMemoryOfDef(newThought.def));
         }
     }
     if (newThought.def.thoughtToMake != null)
     {
         TryGainMemory(newThought.def.thoughtToMake, newThought.otherPawn);
     }
     if (showBubble && newThought.def.showBubble && pawn.Spawned && PawnUtility.ShouldSendNotificationAbout(pawn))
     {
         MoteMaker.MakeMoodThoughtBubble(pawn, newThought);
     }
 }
        public static float ApparelScoreRaw(Pawn pawn, Apparel ap)
        {
            float num  = 0.1f;
            float num2 = ap.GetStatValue(StatDefOf.ArmorRating_Sharp) + ap.GetStatValue(StatDefOf.ArmorRating_Blunt);

            num += num2;
            if (ap.def.useHitPoints)
            {
                float x = (float)ap.HitPoints / (float)ap.MaxHitPoints;
                num *= HitPointsPercentScoreFactorCurve.Evaluate(x);
            }
            num += ap.GetSpecialApparelScoreOffset();
            float num3 = 1f;

            if (neededWarmth == NeededWarmth.Warm)
            {
                float statValue = ap.GetStatValue(StatDefOf.Insulation_Cold);
                num3 *= InsulationColdScoreFactorCurve_NeedWarm.Evaluate(statValue);
            }
            num *= num3;
            if (ap.WornByCorpse && (pawn == null || ThoughtUtility.CanGetThought_NewTemp(pawn, ThoughtDefOf.DeadMansApparel, checkIfNullified: true)))
            {
                num -= 0.5f;
                if (num > 0f)
                {
                    num *= 0.1f;
                }
            }
            if (ap.Stuff == ThingDefOf.Human.race.leatherDef)
            {
                if (pawn == null || ThoughtUtility.CanGetThought_NewTemp(pawn, ThoughtDefOf.HumanLeatherApparelSad, checkIfNullified: true))
                {
                    num -= 0.5f;
                    if (num > 0f)
                    {
                        num *= 0.1f;
                    }
                }
                if (pawn != null && ThoughtUtility.CanGetThought_NewTemp(pawn, ThoughtDefOf.HumanLeatherApparelHappy, checkIfNullified: true))
                {
                    num += 0.12f;
                }
            }
            if (pawn != null && !ap.def.apparel.CorrectGenderForWearing(pawn.gender))
            {
                num *= 0.01f;
            }
            if (pawn != null && pawn.royalty != null && pawn.royalty.AllTitlesInEffectForReading.Count > 0)
            {
                tmpAllowedApparels.Clear();
                tmpRequiredApparels.Clear();
                tmpBodyPartGroupsWithRequirement.Clear();
                QualityCategory qualityCategory = QualityCategory.Awful;
                foreach (RoyalTitle item in pawn.royalty.AllTitlesInEffectForReading)
                {
                    if (item.def.requiredApparel != null)
                    {
                        for (int i = 0; i < item.def.requiredApparel.Count; i++)
                        {
                            tmpAllowedApparels.AddRange(item.def.requiredApparel[i].AllAllowedApparelForPawn(pawn, ignoreGender: false, includeWorn: true));
                            tmpRequiredApparels.AddRange(item.def.requiredApparel[i].AllRequiredApparelForPawn(pawn, ignoreGender: false, includeWorn: true));
                            tmpBodyPartGroupsWithRequirement.AddRange(item.def.requiredApparel[i].bodyPartGroupsMatchAny);
                        }
                    }
                    if ((int)item.def.requiredMinimumApparelQuality > (int)qualityCategory)
                    {
                        qualityCategory = item.def.requiredMinimumApparelQuality;
                    }
                }
                bool num4 = ap.def.apparel.bodyPartGroups.Any((BodyPartGroupDef bp) => tmpBodyPartGroupsWithRequirement.Contains(bp));
                if (ap.TryGetQuality(out QualityCategory qc) && (int)qc < (int)qualityCategory)
                {
                    num *= 0.25f;
                }
                if (num4)
                {
                    foreach (ThingDef tmpRequiredApparel in tmpRequiredApparels)
                    {
                        tmpAllowedApparels.Remove(tmpRequiredApparel);
                    }
                    if (tmpAllowedApparels.Contains(ap.def))
                    {
                        num *= 10f;
                    }
                    if (tmpRequiredApparels.Contains(ap.def))
                    {
                        num *= 25f;
                    }
                }
            }
            return(num);
        }