private void Fulfill(Caravan caravan)
        {
            int          remaining = requestCount;
            List <Thing> list      = CaravanInventoryUtility.TakeThings(caravan, delegate(Thing thing)
            {
                if (requestThingDef != thing.def)
                {
                    return(0);
                }
                if (!PlayerCanGive(thing))
                {
                    return(0);
                }
                int num    = Mathf.Min(remaining, thing.stackCount);
                remaining -= num;
                return(num);
            });

            for (int i = 0; i < list.Count; i++)
            {
                list[i].Destroy();
            }
            if (parent.Faction != null)
            {
                parent.Faction.TryAffectGoodwillWith(Faction.OfPlayer, 12, canSendMessage: true, canSendHostilityLetter: true, "GoodwillChangedReason_FulfilledTradeRequest".Translate(), parent);
            }
            QuestUtility.SendQuestTargetSignals(parent.questTags, "TradeRequestFulfilled", parent.Named("SUBJECT"), caravan.Named("CARAVAN"));
            Disable();
        }
Example #2
0
        private void FulfillTradeRequest()
        {
            tradeRequest.FulfillRequest(tradeShip);

            QuestUtility.SendQuestTargetSignals(parent.questTags, "TradeRequestFulfilled", parent.Named("SUBJECT"));
            tradeRequest = null;
        }
Example #3
0
 private void CheckAllEnemiesDefeated()
 {
     if (!allEnemiesDefeatedSignalSent && base.HasMap && !GenHostility.AnyHostileActiveThreatToPlayer(base.Map, countDormantPawnsAsHostile: true))
     {
         QuestUtility.SendQuestTargetSignals(questTags, "AllEnemiesDefeated", this.Named("SUBJECT"));
         allEnemiesDefeatedSignalSent = true;
     }
 }
Example #4
0
 protected void ReportViolation(Pawn pawn, Pawn billDoer, Faction factionToInform, int goodwillImpact, string reason)
 {
     if (factionToInform != null && billDoer != null && billDoer.Faction != null)
     {
         factionToInform.TryAffectGoodwillWith(billDoer.Faction, goodwillImpact, canSendMessage: true, canSendHostilityLetter: true, reason, pawn);
         QuestUtility.SendQuestTargetSignals(pawn.questTags, "SurgeryViolation", pawn.Named("SUBJECT"));
     }
 }
Example #5
0
        public static void ThingDestroy(Thing __instance, DestroyMode mode = DestroyMode.Vanish)
        {
            if (!Thing.allowDestroyNonDestroyable && !__instance.def.destroyable)
            {
                Log.Error("Tried to destroy non-destroyable thing " + __instance);
                return;
            }

            if (__instance.Destroyed)
            {
                Log.Error("Tried to destroy already-destroyed thing " + __instance);
                return;
            }

            bool spawned = __instance.Spawned;
            Map  map     = __instance.Map;

            if (__instance.Spawned)
            {
                __instance.DeSpawn(mode);
            }

            mapIndexOrState(__instance) = -2;
            if (__instance.def.DiscardOnDestroyed)
            {
                __instance.Discard();
            }

            CompExplosive compExplosive = __instance.TryGetComp <CompExplosive>();

            if (spawned)
            {
                List <Thing> list = (compExplosive != null) ? new List <Thing>() : null;
                GenLeaving.DoLeavingsFor(__instance, map, mode, list);
                compExplosive?.AddThingsIgnoredByExplosion(list);
            }

            if (__instance.holdingOwner != null)
            {
                __instance.holdingOwner.Notify_ContainedItemDestroyed(__instance);
            }

            RemoveAllReservationsAndDesignationsOnThis(__instance);
            if (!(__instance is Pawn))
            {
                __instance.stackCount = 0;
            }

            if (mode != DestroyMode.QuestLogic)
            {
                QuestUtility.SendQuestTargetSignals(__instance.questTags, "Destroyed", __instance.Named("SUBJECT"));
            }

            if (mode == DestroyMode.KillFinalize)
            {
                QuestUtility.SendQuestTargetSignals(__instance.questTags, "Killed", __instance.Named("SUBJECT"));
            }
        }
Example #6
0
 private void Destroy()
 {
     lordManager.RemoveLord(this);
     curJob.Notify_LordDestroyed();
     if (faction != null)
     {
         QuestUtility.SendQuestTargetSignals(questTags, "AllEnemiesDefeated");
     }
 }
Example #7
0
        public virtual void PostMapGenerate()
        {
            List <WorldObjectComp> allComps = base.AllComps;

            for (int i = 0; i < allComps.Count; i++)
            {
                allComps[i].PostMapGenerate();
            }
            QuestUtility.SendQuestTargetSignals(questTags, "MapGenerated", this.Named("SUBJECT"));
        }
Example #8
0
        public virtual void Notify_MyMapRemoved(Map map)
        {
            List <WorldObjectComp> allComps = base.AllComps;

            for (int i = 0; i < allComps.Count; i++)
            {
                allComps[i].PostMyMapRemoved();
            }
            QuestUtility.SendQuestTargetSignals(questTags, "MapRemoved", this.Named("SUBJECT"));
        }
Example #9
0
 internal void ClearMentalStateDirect()
 {
     if (curStateInt != null)
     {
         curStateInt = null;
         QuestUtility.SendQuestTargetSignals(pawn.questTags, "ExitMentalState", pawn.Named("SUBJECT"));
         if (pawn.Spawned)
         {
             pawn.Map.attackTargetsCache.UpdateTarget(pawn);
         }
     }
 }
Example #10
0
        public virtual void Destroy(DestroyMode mode = DestroyMode.Vanish)
        {
            if (!allowDestroyNonDestroyable && !def.destroyable)
            {
                Log.Error("Tried to destroy non-destroyable thing " + this);
                return;
            }
            if (Destroyed)
            {
                Log.Error("Tried to destroy already-destroyed thing " + this);
                return;
            }
            bool spawned = Spawned;
            Map  map     = Map;

            if (Spawned)
            {
                DeSpawn(mode);
            }
            mapIndexOrState = -2;
            if (def.DiscardOnDestroyed)
            {
                Discard();
            }
            CompExplosive compExplosive = this.TryGetComp <CompExplosive>();

            if (spawned)
            {
                List <Thing> list = ((compExplosive != null) ? new List <Thing>() : null);
                GenLeaving.DoLeavingsFor(this, map, mode, list);
                compExplosive?.AddThingsIgnoredByExplosion(list);
            }
            if (holdingOwner != null)
            {
                holdingOwner.Notify_ContainedItemDestroyed(this);
            }
            RemoveAllReservationsAndDesignationsOnThis();
            if (!(this is Pawn))
            {
                stackCount = 0;
            }
            if (mode != DestroyMode.QuestLogic)
            {
                QuestUtility.SendQuestTargetSignals(questTags, "Destroyed", this.Named("SUBJECT"));
            }
            if (mode == DestroyMode.KillFinalize)
            {
                QuestUtility.SendQuestTargetSignals(questTags, "Killed", this.Named("SUBJECT"));
            }
        }
        protected override void StrikeAction(ActiveArtilleryStrike strike, CellRect mapRect, CellRect baseRect, ref bool destroyed)
        {
            Log.Message(Site.AllComps.ToStringSafeEnumerable());
            var radialCells = GenRadial.RadialCellsAround(mapRect.RandomCell, strike.shellDef.projectile.explosionRadius, true);
            int cellsInRect = radialCells.Count(c => baseRect.Contains(c));

            // Destroy outpost and give reward
            if (cellsInRect > 0 && Rand.Chance(cellsInRect * DestroyChancePerCellInRect))
            {
                QuestUtility.SendQuestTargetSignals(Site.questTags, QuestUtility.QuestTargetSignalPart_AllEnemiesDefeated, Site.Named("SUBJECT"));
                NonPublicFields.Site_allEnemiesDefeatedSignalSent.SetValue(Site, true);
                Find.WorldObjects.Remove(worldObject);
                destroyed = true;
            }
        }
 public override bool TryStart(Pawn pawn, string reason, bool causedByMood)
 {
     TrySendLetter(pawn, "LetterRunWildMentalBreak", reason);
     QuestUtility.SendQuestTargetSignals(pawn.questTags, "RanWild", pawn.Named("SUBJECT"));
     pawn.ChangeKind(PawnKindDefOf.WildMan);
     if (pawn.Faction != null)
     {
         pawn.SetFaction(null);
     }
     pawn.needs.mood.thoughts.memories.TryGainMemory(ThoughtDefOf.Catharsis);
     if (pawn.Spawned && !pawn.Downed)
     {
         pawn.jobs.StopAll();
     }
     return(true);
 }
 public virtual void PostRemove()
 {
     if (!def.useDynamicDrawer)
     {
         Find.World.renderer.Notify_StaticWorldObjectPosChanged();
     }
     if (def.useDynamicDrawer)
     {
         Find.WorldDynamicDrawManager.DeRegisterDrawable(this);
     }
     Find.WorldSelector.Deselect(this);
     for (int i = 0; i < comps.Count; i++)
     {
         comps[i].PostPostRemove();
     }
     QuestUtility.SendQuestTargetSignals(questTags, "Despawned", this.Named("SUBJECT"));
 }
Example #14
0
 public virtual void SetFaction(Faction newFaction, Pawn recruiter = null)
 {
     if (!def.CanHaveFaction)
     {
         Log.Error(string.Concat("Tried to SetFaction on ", this, " which cannot have a faction."));
         return;
     }
     factionInt = newFaction;
     if (Spawned)
     {
         IAttackTarget attackTarget = this as IAttackTarget;
         if (attackTarget != null)
         {
             Map.attackTargetsCache.UpdateTarget(attackTarget);
         }
     }
     QuestUtility.SendQuestTargetSignals(questTags, "ChangedFaction", this.Named("SUBJECT"), newFaction.Named("FACTION"));
 }
 public virtual void Destroy()
 {
     if (Destroyed)
     {
         Log.Error("Tried to destroy already-destroyed world object " + this);
         return;
     }
     if (Spawned)
     {
         Find.WorldObjects.Remove(this);
     }
     destroyed = true;
     for (int i = 0; i < comps.Count; i++)
     {
         comps[i].PostDestroy();
     }
     QuestUtility.SendQuestTargetSignals(questTags, "Destroyed", this.Named("SUBJECT"));
 }
 public void KillInnerPawn(bool affectFactionRelationship = false, Pawn affecter = null)
 {
     if (this.hasPawn)
     {
         Pawn pawn = PawnGenerator.GeneratePawn(new PawnGenerationRequest(PawnKindDefOf.Colonist, Faction.OfPlayer));
         this.OverwritePawn(pawn);
         if (affectFactionRelationship)
         {
             this.faction.TryAffectGoodwillWith(affecter.Faction, -70, canSendMessage: true, canSendHostilityLetter: true,
                                                "AlteredCarbon.GoodwillChangedReason_ErasedPawn".Translate(pawn.Named("PAWN")), affecter);
             QuestUtility.SendQuestTargetSignals(pawn.questTags, "SurgeryViolation", pawn.Named("SUBJECT"));
         }
         if (isFactionLeader)
         {
             pawn.Faction.leader = pawn;
         }
         pawn.Kill(null);
     }
 }
Example #17
0
 public override void Destroy(DestroyMode mode = DestroyMode.Vanish)
 {
     if (!this.questTags.NullOrEmpty <string>())
     {
         bool         flag = false;
         List <Thing> list = base.Map.listerThings.ThingsOfDef(this.def);
         for (int i = 0; i < list.Count; i++)
         {
             Hive hive;
             if ((hive = (list[i] as Hive)) != null && hive != this && hive.CompDormant.Awake && !hive.questTags.NullOrEmpty <string>() && QuestUtility.AnyMatchingTags(hive.questTags, this.questTags))
             {
                 flag = true;
                 break;
             }
         }
         if (!flag)
         {
             QuestUtility.SendQuestTargetSignals(this.questTags, "AllHivesDestroyed");
         }
     }
     base.Destroy(mode);
 }
        public void Notify_CaravanArrived(Caravan caravan)
        {
            Pawn pawn = BestCaravanPawnUtility.FindBestDiplomat(caravan);

            if (pawn == null)
            {
                Messages.Message("MessagePeaceTalksNoDiplomat".Translate(), caravan, MessageTypeDefOf.NegativeEvent, historical: false);
                return;
            }
            float badOutcomeWeightFactor = GetBadOutcomeWeightFactor(pawn);
            float num = 1f / badOutcomeWeightFactor;

            tmpPossibleOutcomes.Clear();
            tmpPossibleOutcomes.Add(new Pair <Action, float>(delegate
            {
                Outcome_Disaster(caravan);
            }, 0.05f * badOutcomeWeightFactor));
            tmpPossibleOutcomes.Add(new Pair <Action, float>(delegate
            {
                Outcome_Backfire(caravan);
            }, 0.1f * badOutcomeWeightFactor));
            tmpPossibleOutcomes.Add(new Pair <Action, float>(delegate
            {
                Outcome_TalksFlounder(caravan);
            }, 0.2f));
            tmpPossibleOutcomes.Add(new Pair <Action, float>(delegate
            {
                Outcome_Success(caravan);
            }, 0.55f * num));
            tmpPossibleOutcomes.Add(new Pair <Action, float>(delegate
            {
                Outcome_Triumph(caravan);
            }, 0.1f * num));
            tmpPossibleOutcomes.RandomElementByWeight((Pair <Action, float> x) => x.Second).First();
            pawn.skills.Learn(SkillDefOf.Social, 6000f, direct: true);
            QuestUtility.SendQuestTargetSignals(questTags, "Resolved", this.Named("SUBJECT"));
            Destroy();
        }
Example #19
0
 public override IEnumerable <Toil> MakeNewToils()
 {
     this.FailOnDestroyedOrNull(TargetIndex.A).
     FailOnDestroyedOrNull(TargetIndex.B).
     FailOnAggroMentalStateAndHostile(TargetIndex.A).
     FailOn(delegate()
     {
         return(!this.Cage.CageComp.AssignedPawnsForReading.Contains(this.Takee));
     });
     this.AddFinishAction(delegate
     {
         if (this.pawn.carryTracker.CarriedThing is null)
         {
             return;
         }
         var cage   = this.Cage;
         var target = this.Takee;
         var comp   = cage.CageComp;
         if (!cage.Destroyed && comp.AssignedPawnsForReading.Contains(target))
         {
             if (this.pawn.Position.IsInside(cage))
             {
                 if (!target.AnimalOrWildMan())
                 {
                     target.GetLord()?.Notify_PawnAttemptArrested(target);
                     GenClamor.DoClamor(target, 10f, ClamorDefOf.Harm);
                     if (!target.IsPrisoner)
                     {
                         QuestUtility.SendQuestTargetSignals(target.questTags, "Arrested", target.Named("SUBJECT"));
                     }
                 }
                 this.pawn.carryTracker.TryDropCarriedThing(this.pawn.Position, ThingPlaceMode.Direct, out var thing);
                 target.Notify_Teleported(false);
                 target.stances.CancelBusyStanceHard();
                 if (target.Downed || HealthAIUtility.ShouldSeekMedicalRest(target))
                 {
                     target.jobs.StartJob(JobMaker.MakeJob(JobDefOf.LayDown, target.Position),
                                          JobCondition.InterruptForced, tag: new JobTag?(JobTag.TuckedIntoBed));
                 }
                 target.mindState.Notify_TuckedIntoBed();
                 var duty = new PawnDuty(DefDatabase <DutyDef> .GetNamed("ZzZomboRW_AnimalCage_BeingHelpCaptive"),
                                         cage)
                 {
                     attackDownedIfStarving = true
                 };
                 target.mindState.duty = duty;
             }
             else
             {
                 this.pawn.carryTracker.TryDropCarriedThing(this.pawn.Position, ThingPlaceMode.Direct, out var thing);
             }
             if (target.IsPrisonerOfColony)
             {
                 LessonAutoActivator.TeachOpportunity(ConceptDefOf.PrisonerTab, this.Takee, OpportunityType.GoodToKnow);
             }
         }
         else
         {
             this.pawn.carryTracker.TryDropCarriedThing(this.pawn.Position, ThingPlaceMode.Direct, out var thing);
         }
     });
Example #20
0
        public override void SpawnSetup(Map map, bool respawningAfterLoad)
        {
            if (Destroyed)
            {
                Log.Error(string.Concat("Spawning destroyed thing ", this, " at ", Position, ". Correcting."));
                mapIndexOrState = -1;
                if (HitPoints <= 0 && def.useHitPoints)
                {
                    HitPoints = 1;
                }
            }
            if (Spawned)
            {
                Log.Error(string.Concat("Tried to spawn already-spawned thing ", this, " at ", Position));
                return;
            }
            int num = Find.Maps.IndexOf(map);

            if (num < 0)
            {
                Log.Error(string.Concat("Tried to spawn thing ", this, ", but the map provided does not exist."));
                return;
            }
            if (stackCount > def.stackLimit)
            {
                Log.Error(string.Concat("Spawned ", this, " with stackCount ", stackCount, " but stackLimit is ", def.stackLimit, ". Truncating."));
                stackCount = def.stackLimit;
            }
            mapIndexOrState = (sbyte)num;
            RegionListersUpdater.RegisterInRegions(this, map);
            if (!map.spawnedThings.TryAdd(this, canMergeWithExistingStacks: false))
            {
                Log.Error(string.Concat("Couldn't add thing ", this, " to spawned things."));
            }
            map.listerThings.Add(this);
            map.thingGrid.Register(this);
            if (Find.TickManager != null)
            {
                Find.TickManager.RegisterAllTickabilityFor(this);
            }
            DirtyMapMesh(map);
            if (def.drawerType != DrawerType.MapMeshOnly)
            {
                map.dynamicDrawManager.RegisterDrawable(this);
            }
            map.tooltipGiverList.Notify_ThingSpawned(this);
            if (def.graphicData != null && def.graphicData.Linked)
            {
                map.linkGrid.Notify_LinkerCreatedOrDestroyed(this);
                map.mapDrawer.MapMeshDirty(Position, MapMeshFlag.Things, regenAdjacentCells: true, regenAdjacentSections: false);
            }
            if (!def.CanOverlapZones)
            {
                map.zoneManager.Notify_NoZoneOverlapThingSpawned(this);
            }
            if (def.AffectsRegions)
            {
                map.regionDirtyer.Notify_ThingAffectingRegionsSpawned(this);
            }
            if (def.pathCost != 0 || def.passability == Traversability.Impassable)
            {
                map.pathGrid.RecalculatePerceivedPathCostUnderThing(this);
            }
            if (def.AffectsReachability)
            {
                map.reachability.ClearCache();
            }
            map.coverGrid.Register(this);
            if (def.category == ThingCategory.Item)
            {
                map.listerHaulables.Notify_Spawned(this);
                map.listerMergeables.Notify_Spawned(this);
            }
            map.attackTargetsCache.Notify_ThingSpawned(this);
            (map.regionGrid.GetValidRegionAt_NoRebuild(Position)?.Room)?.Notify_ContainedThingSpawnedOrDespawned(this);
            StealAIDebugDrawer.Notify_ThingChanged(this);
            IHaulDestination haulDestination = this as IHaulDestination;

            if (haulDestination != null)
            {
                map.haulDestinationManager.AddHaulDestination(haulDestination);
            }
            if (this is IThingHolder && Find.ColonistBar != null)
            {
                Find.ColonistBar.MarkColonistsDirty();
            }
            if (def.category == ThingCategory.Item)
            {
                SlotGroup slotGroup = Position.GetSlotGroup(map);
                if (slotGroup != null && slotGroup.parent != null)
                {
                    slotGroup.parent.Notify_ReceivedThing(this);
                }
            }
            if (def.receivesSignals)
            {
                Find.SignalManager.RegisterReceiver(this);
            }
            if (!respawningAfterLoad)
            {
                QuestUtility.SendQuestTargetSignals(questTags, "Spawned", this.Named("SUBJECT"));
            }
        }
Example #21
0
        public override void DeSpawn(DestroyMode mode = DestroyMode.Vanish)
        {
            if (Destroyed)
            {
                Log.Error("Tried to despawn " + this.ToStringSafe() + " which is already destroyed.");
                return;
            }
            if (!Spawned)
            {
                Log.Error("Tried to despawn " + this.ToStringSafe() + " which is not spawned.");
                return;
            }
            Map map = Map;

            RegionListersUpdater.DeregisterInRegions(this, map);
            map.spawnedThings.Remove(this);
            map.listerThings.Remove(this);
            map.thingGrid.Deregister(this);
            map.coverGrid.DeRegister(this);
            if (def.receivesSignals)
            {
                Find.SignalManager.DeregisterReceiver(this);
            }
            map.tooltipGiverList.Notify_ThingDespawned(this);
            if (def.graphicData != null && def.graphicData.Linked)
            {
                map.linkGrid.Notify_LinkerCreatedOrDestroyed(this);
                map.mapDrawer.MapMeshDirty(Position, MapMeshFlag.Things, regenAdjacentCells: true, regenAdjacentSections: false);
            }
            if (Find.Selector.IsSelected(this))
            {
                Find.Selector.Deselect(this);
                Find.MainButtonsRoot.tabs.Notify_SelectedObjectDespawned();
            }
            DirtyMapMesh(map);
            if (def.drawerType != DrawerType.MapMeshOnly)
            {
                map.dynamicDrawManager.DeRegisterDrawable(this);
            }
            (map.regionGrid.GetValidRegionAt_NoRebuild(Position)?.Room)?.Notify_ContainedThingSpawnedOrDespawned(this);
            if (def.AffectsRegions)
            {
                map.regionDirtyer.Notify_ThingAffectingRegionsDespawned(this);
            }
            if (def.pathCost != 0 || def.passability == Traversability.Impassable)
            {
                map.pathGrid.RecalculatePerceivedPathCostUnderThing(this);
            }
            if (def.AffectsReachability)
            {
                map.reachability.ClearCache();
            }
            Find.TickManager.DeRegisterAllTickabilityFor(this);
            mapIndexOrState = -1;
            if (def.category == ThingCategory.Item)
            {
                map.listerHaulables.Notify_DeSpawned(this);
                map.listerMergeables.Notify_DeSpawned(this);
            }
            map.attackTargetsCache.Notify_ThingDespawned(this);
            map.physicalInteractionReservationManager.ReleaseAllForTarget(this);
            StealAIDebugDrawer.Notify_ThingChanged(this);
            IHaulDestination haulDestination = this as IHaulDestination;

            if (haulDestination != null)
            {
                map.haulDestinationManager.RemoveHaulDestination(haulDestination);
            }
            if (this is IThingHolder && Find.ColonistBar != null)
            {
                Find.ColonistBar.MarkColonistsDirty();
            }
            if (def.category == ThingCategory.Item)
            {
                SlotGroup slotGroup = Position.GetSlotGroup(map);
                if (slotGroup != null && slotGroup.parent != null)
                {
                    slotGroup.parent.Notify_LostThing(this);
                }
            }
            QuestUtility.SendQuestTargetSignals(questTags, "Despawned", this.Named("SUBJECT"));
        }
Example #22
0
        /// <summary>
        /// recruits the sapient animal
        /// </summary>
        /// <param name="recruiter">The recruiter.</param>
        /// <param name="recruitee">The recruitee.</param>
        /// <param name="recruitChance">The recruit chance.</param>
        /// <param name="letterLabel">The letter label.</param>
        /// <param name="letter">The letter.</param>
        /// <param name="useAudiovisualEffects">if set to <c>true</c> [use audiovisual effects].</param>
        /// <param name="sendLetter">if set to <c>true</c> [send letter].</param>
        public static void DoRecruit(
            Pawn recruiter,
            Pawn recruitee,
            float recruitChance,
            out string letterLabel,
            out string letter,
            bool useAudiovisualEffects = true,
            bool sendLetter            = true)
        {
            letterLabel   = null;
            letter        = null;
            recruitChance = Mathf.Clamp01(recruitChance);
            string str = recruitee.LabelIndefinite();

            if (recruitee.guest != null)
            {
                recruitee.guest.SetGuestStatus(null);
            }
            bool flag = recruitee.Name != null;

            if (recruitee.Faction != recruiter.Faction)
            {
                recruitee.SetFaction(recruiter.Faction, recruiter);
            }
            if (recruitee.IsHumanlike())
            {
                if (useAudiovisualEffects)
                {
                    letterLabel = "LetterLabelMessageRecruitSuccess".Translate() + ": " + recruitee.LabelShortCap;
                    if (sendLetter)
                    {
                        Find.LetterStack.ReceiveLetter((TaggedString)letterLabel,
                                                       "MessageRecruitSuccess".Translate((NamedArgument)recruiter,
                                                                                         (NamedArgument)recruitee,
                                                                                         (NamedArgument)recruitChance
                                                                                         .ToStringPercent(),
                                                                                         recruiter.Named("RECRUITER"),
                                                                                         recruitee.Named("RECRUITEE")),
                                                       LetterDefOf.PositiveEvent, recruitee);
                    }
                }

                TaleRecorder.RecordTale(RimWorld.TaleDefOf.Recruited, (object)recruiter, (object)recruitee);
                recruiter.records.Increment(RecordDefOf.PrisonersRecruited);
                if (recruitee.needs.mood != null)
                {
                    recruitee.needs.mood.thoughts.memories.TryGainMemory(ThoughtDefOf.RecruitedMe, recruiter);
                }
                QuestUtility.SendQuestTargetSignals(recruitee.questTags, "Recruited", recruitee.Named("SUBJECT"));
            }
            else
            {
                if (useAudiovisualEffects)
                {
                    if (!flag)
                    {
                        Messages.Message("MessageTameAndNameSuccess".Translate((NamedArgument)recruiter.LabelShort, (NamedArgument)str, (NamedArgument)recruitChance.ToStringPercent(), (NamedArgument)recruitee.Name.ToStringFull, recruiter.Named("RECRUITER"), recruitee.Named("RECRUITEE")).AdjustedFor(recruitee),
                                         recruitee, MessageTypeDefOf.PositiveEvent);
                    }
                    else
                    {
                        Messages.Message("MessageTameSuccess".Translate((NamedArgument)recruiter.LabelShort, (NamedArgument)str, (NamedArgument)recruitChance.ToStringPercent(), recruiter.Named("RECRUITER")),
                                         recruitee, MessageTypeDefOf.PositiveEvent);
                    }
                    if (recruiter.Spawned && recruitee.Spawned)
                    {
                        MoteMaker.ThrowText((recruiter.DrawPos + recruitee.DrawPos) / 2f, recruiter.Map,
                                            "TextMote_TameSuccess".Translate((NamedArgument)recruitChance.ToStringPercent()),
                                            8f);
                    }
                }

                recruiter.records.Increment(RecordDefOf.AnimalsTamed);
                RelationsUtility.TryDevelopBondRelation(recruiter, recruitee, 0.01f);
                if (Rand.Chance(Mathf.Lerp(0.02f, 1f, recruitee.RaceProps.wildness)) || recruitee.IsWildMan())
                {
                    TaleRecorder.RecordTale(RimWorld.TaleDefOf.TamedAnimal, (object)recruiter, (object)recruitee);
                }
                if (PawnsFinder.AllMapsWorldAndTemporary_Alive.Count(p =>
                {
                    if (p.playerSettings != null)
                    {
                        return(p.playerSettings.Master == recruiter);
                    }
                    return(false);
                })
                    >= 5)
                {
                    TaleRecorder.RecordTale(RimWorld.TaleDefOf.IncreasedMenagerie, (object)recruiter, (object)recruitee);
                }
            }

            if (recruitee.caller == null)
            {
                return;
            }
            recruitee.caller.DoCall();
        }
 public virtual void PostAdd()
 {
     QuestUtility.SendQuestTargetSignals(questTags, "Spawned", this.Named("SUBJECT"));
 }
        private static void PassPawnsToWorld(Map map)
        {
            List <Pawn> list  = new List <Pawn>();
            List <Pawn> list2 = new List <Pawn>();
            bool        flag  = map.ParentFaction != null && map.ParentFaction.HostileTo(Faction.OfPlayer);
            List <Pawn> list3 = map.mapPawns.AllPawns.ToList();

            for (int i = 0; i < list3.Count; i++)
            {
                Find.Storyteller.Notify_PawnEvent(list3[i], AdaptationEvent.LostBecauseMapClosed);
                try
                {
                    Pawn pawn = list3[i];
                    if (pawn.Spawned)
                    {
                        pawn.DeSpawn();
                    }
                    if (pawn.IsColonist && flag)
                    {
                        list.Add(pawn);
                        map.ParentFaction.kidnapped.Kidnap(pawn, null);
                        continue;
                    }
                    if (pawn.Faction == Faction.OfPlayer || pawn.HostFaction == Faction.OfPlayer)
                    {
                        list2.Add(pawn);
                        PawnDiedOrDownedThoughtsUtility.TryGiveThoughts(pawn, null, PawnDiedOrDownedThoughtsKind.Lost);
                    }
                    CleanUpAndPassToWorld(pawn);
                }
                catch (Exception ex)
                {
                    Log.Error(string.Concat("Could not despawn and pass to world ", list3[i], ": ", ex));
                }
            }
            for (int j = 0; j < list.Count; j++)
            {
                QuestUtility.SendQuestTargetSignals(list[j].questTags, "LeftMap", list[j].Named("SUBJECT"));
            }
            for (int k = 0; k < list2.Count; k++)
            {
                QuestUtility.SendQuestTargetSignals(list2[k].questTags, "LeftMap", list2[k].Named("SUBJECT"));
            }
            if (!list.Any() && !list2.Any())
            {
                return;
            }
            StringBuilder stringBuilder = new StringBuilder();

            if (list.Any())
            {
                list.SortByDescending((Pawn x) => x.RaceProps.Humanlike);
                for (int l = 0; l < list.Count; l++)
                {
                    stringBuilder.AppendLineTagged("  - " + list[l].NameShortColored.CapitalizeFirst() + ": " + "capturedBy".Translate(map.ParentFaction.NameColored).CapitalizeFirst());
                }
            }
            if (list2.Any())
            {
                list2.SortByDescending((Pawn x) => x.RaceProps.Humanlike);
                for (int m = 0; m < list2.Count; m++)
                {
                    stringBuilder.AppendLineTagged("  - " + list2[m].NameShortColored.CapitalizeFirst());
                }
            }
            string str;
            string str2;

            if (map.IsPlayerHome)
            {
                str  = "LetterLabelPawnsLostBecauseMapClosed_Home".Translate();
                str2 = "LetterPawnsLostBecauseMapClosed_Home".Translate();
            }
            else
            {
                str  = "LetterLabelPawnsLostBecauseMapClosed_Caravan".Translate();
                str2 = "LetterPawnsLostBecauseMapClosed_Caravan".Translate();
            }
            str2 = str2 + ":\n\n" + stringBuilder.ToString().TrimEndNewlines();
            Find.LetterStack.ReceiveLetter(str, str2, LetterDefOf.NegativeEvent, new GlobalTargetInfo(map.Tile));
        }