コード例 #1
0
 public void SetGuestStatus(Faction newHost, bool prisoner = false)
 {
     if (newHost != null)
     {
         Released = false;
     }
     if (newHost != HostFaction || prisoner != IsPrisoner)
     {
         if (!prisoner && pawn.Faction.HostileTo(newHost))
         {
             Log.Error("Tried to make " + pawn + " a guest of " + newHost + " but their faction " + pawn.Faction + " is hostile to " + newHost);
         }
         else if (newHost != null && newHost == pawn.Faction && !prisoner)
         {
             Log.Error("Tried to make " + pawn + " a guest of their own faction " + pawn.Faction);
         }
         else
         {
             bool flag = prisoner && (!IsPrisoner || HostFaction != newHost);
             isPrisonerInt  = prisoner;
             hostFactionInt = newHost;
             pawn.ClearMind();
             if (flag)
             {
                 pawn.DropAndForbidEverything();
                 pawn.GetLord()?.Notify_PawnLost(pawn, PawnLostCondition.MadePrisoner);
                 if (newHost == Faction.OfPlayer)
                 {
                     Find.StoryWatcher.watcherPopAdaptation.Notify_PawnEvent(pawn, PopAdaptationEvent.GainedPrisoner);
                 }
                 if (pawn.Drafted)
                 {
                     pawn.drafter.Drafted = false;
                 }
                 float x = pawn.RecruitDifficulty(Faction.OfPlayer);
                 resistance  = StartingResistancePerRecruitDifficultyCurve.Evaluate(x);
                 resistance *= StartingResistanceFactorFromPopulationIntentCurve.Evaluate(StorytellerUtilityPopulation.PopulationIntent);
                 resistance *= StartingResistanceRandomFactorRange.RandomInRange;
                 resistance  = (float)GenMath.RoundRandom(resistance);
             }
             PawnComponentsUtility.AddAndRemoveDynamicComponents(pawn);
             pawn.health.surgeryBills.Clear();
             if (pawn.ownership != null)
             {
                 pawn.ownership.Notify_ChangedGuestStatus();
             }
             ReachabilityUtility.ClearCacheFor(pawn);
             if (pawn.Spawned)
             {
                 pawn.Map.mapPawns.UpdateRegistryForPawn(pawn);
                 pawn.Map.attackTargetsCache.UpdateTarget(pawn);
             }
             AddictionUtility.CheckDrugAddictionTeachOpportunity(pawn);
             if (prisoner && pawn.playerSettings != null)
             {
                 pawn.playerSettings.Notify_MadePrisoner();
             }
         }
     }
 }
コード例 #2
0
 public override void Notify_PawnLost(Pawn p, PawnLostCondition condition)
 {
     ReachabilityUtility.ClearCacheFor(p);
     if (!this.caravanSent)
     {
         CaravanFormingUtility.RemovePawnFromCaravan(p, this.lord);
     }
 }
コード例 #3
0
 public override void Notify_PawnLost(Pawn p, PawnLostCondition condition)
 {
     base.Notify_PawnLost(p, condition);
     ReachabilityUtility.ClearCacheFor(p);
     if (!this.caravanSent)
     {
         if (condition == PawnLostCondition.IncappedOrKilled && p.Downed)
         {
             this.downedPawns.Add(p);
         }
         CaravanFormingUtility.RemovePawnFromCaravan(p, this.lord, false);
     }
 }
 public static bool Prefix(Pawn __instance, PawnKindDef newKindDef)
 {
     if (__instance.def is RaceAddonThingDef)
     {
         if (__instance.kindDef != newKindDef)
         {
             __instance.kindDef = newKindDef;
             if (__instance.kindDef == PawnKindDefOf.WildMan)
             {
                 __instance.mindState.WildManEverReachedOutside = false;
                 ReachabilityUtility.ClearCacheFor(__instance);
             }
         }
     }
     return(true);
 }
コード例 #5
0
 public override void Notify_PawnLost(Pawn p, PawnLostCondition condition)
 {
     ReachabilityUtility.ClearCacheFor(p);
 }
コード例 #6
0
 public override void Notify_PawnAdded(Pawn p)
 {
     ReachabilityUtility.ClearCacheFor(p);
 }
コード例 #7
0
        public void SetGuestStatus(Faction newHost, bool prisoner = false)
        {
            if (newHost != null)
            {
                this.Released = false;
            }
            if (newHost == this.HostFaction && prisoner == this.IsPrisoner)
            {
                return;
            }
            if (!prisoner && this.pawn.Faction.HostileTo(newHost))
            {
                Log.Error(string.Concat(new object[]
                {
                    "Tried to make ",
                    this.pawn,
                    " a guest of ",
                    newHost,
                    " but their faction ",
                    this.pawn.Faction,
                    " is hostile to ",
                    newHost
                }), false);
                return;
            }
            if (newHost != null && newHost == this.pawn.Faction && !prisoner)
            {
                Log.Error(string.Concat(new object[]
                {
                    "Tried to make ",
                    this.pawn,
                    " a guest of their own faction ",
                    this.pawn.Faction
                }), false);
                return;
            }
            bool flag = prisoner && (!this.IsPrisoner || this.HostFaction != newHost);

            this.isPrisonerInt  = prisoner;
            this.hostFactionInt = newHost;
            this.pawn.ClearMind(false);
            if (flag)
            {
                this.pawn.DropAndForbidEverything(false);
                Lord lord = this.pawn.GetLord();
                if (lord != null)
                {
                    lord.Notify_PawnLost(this.pawn, PawnLostCondition.MadePrisoner, null);
                }
                if (newHost == Faction.OfPlayer)
                {
                    Find.StoryWatcher.watcherPopAdaptation.Notify_PawnEvent(this.pawn, PopAdaptationEvent.GainedPrisoner);
                }
                if (this.pawn.Drafted)
                {
                    this.pawn.drafter.Drafted = false;
                }
                float x = this.pawn.RecruitDifficulty(Faction.OfPlayer);
                this.resistance  = Pawn_GuestTracker.StartingResistancePerRecruitDifficultyCurve.Evaluate(x);
                this.resistance *= Pawn_GuestTracker.StartingResistanceFactorFromPopulationIntentCurve.Evaluate(StorytellerUtilityPopulation.PopulationIntent);
                this.resistance *= Pawn_GuestTracker.StartingResistanceRandomFactorRange.RandomInRange;
                this.resistance  = (float)GenMath.RoundRandom(this.resistance);
            }
            PawnComponentsUtility.AddAndRemoveDynamicComponents(this.pawn, false);
            this.pawn.health.surgeryBills.Clear();
            if (this.pawn.ownership != null)
            {
                this.pawn.ownership.Notify_ChangedGuestStatus();
            }
            ReachabilityUtility.ClearCacheFor(this.pawn);
            if (this.pawn.Spawned)
            {
                this.pawn.Map.mapPawns.UpdateRegistryForPawn(this.pawn);
                this.pawn.Map.attackTargetsCache.UpdateTarget(this.pawn);
            }
            AddictionUtility.CheckDrugAddictionTeachOpportunity(this.pawn);
            if (prisoner && this.pawn.playerSettings != null)
            {
                this.pawn.playerSettings.Notify_MadePrisoner();
            }
        }
コード例 #8
0
        public void SetGuestStatus(Faction newHost, bool prisoner = false)
        {
            if (newHost != null)
            {
                Released = false;
            }
            if (newHost == HostFaction && prisoner == IsPrisoner)
            {
                return;
            }
            if (!prisoner && pawn.Faction.HostileTo(newHost))
            {
                Log.Error("Tried to make " + pawn + " a guest of " + newHost + " but their faction " + pawn.Faction + " is hostile to " + newHost);
                return;
            }
            if (newHost != null && newHost == pawn.Faction && !prisoner)
            {
                Log.Error("Tried to make " + pawn + " a guest of their own faction " + pawn.Faction);
                return;
            }
            bool num = prisoner && (!IsPrisoner || HostFaction != newHost);

            isPrisonerInt = prisoner;
            Faction faction = hostFactionInt;

            hostFactionInt = newHost;
            Pawn obj = pawn;
            bool clearMentalState = prisoner;

            obj.ClearMind(newHost != null, clearInspiration: false, clearMentalState);
            if (num)
            {
                pawn.DropAndForbidEverything();
                pawn.GetLord()?.Notify_PawnLost(pawn, PawnLostCondition.MadePrisoner);
                if (pawn.Drafted)
                {
                    pawn.drafter.Drafted = false;
                }
                float x = pawn.RecruitDifficulty(Faction.OfPlayer);
                resistance  = StartingResistancePerRecruitDifficultyCurve.Evaluate(x);
                resistance *= StartingResistanceFactorFromPopulationIntentCurve.Evaluate(StorytellerUtilityPopulation.PopulationIntent);
                resistance *= StartingResistanceRandomFactorRange.RandomInRange;
                if (pawn.royalty != null)
                {
                    RoyalTitle mostSeniorTitle = pawn.royalty.MostSeniorTitle;
                    if (mostSeniorTitle != null)
                    {
                        resistance *= mostSeniorTitle.def.recruitmentResistanceFactor;
                        resistance += mostSeniorTitle.def.recruitmentResistanceOffset;
                    }
                }
                resistance = GenMath.RoundRandom(resistance);
            }
            PawnComponentsUtility.AddAndRemoveDynamicComponents(pawn);
            pawn.health.surgeryBills.Clear();
            if (pawn.ownership != null)
            {
                pawn.ownership.Notify_ChangedGuestStatus();
            }
            ReachabilityUtility.ClearCacheFor(pawn);
            if (pawn.Spawned)
            {
                pawn.Map.mapPawns.UpdateRegistryForPawn(pawn);
                pawn.Map.attackTargetsCache.UpdateTarget(pawn);
            }
            AddictionUtility.CheckDrugAddictionTeachOpportunity(pawn);
            if (prisoner && pawn.playerSettings != null)
            {
                pawn.playerSettings.Notify_MadePrisoner();
            }
            if (faction != hostFactionInt)
            {
                QuestUtility.SendQuestTargetSignals(pawn.questTags, "ChangedHostFaction", pawn.Named("SUBJECT"), hostFactionInt.Named("FACTION"));
            }
        }