Exemplo n.º 1
0
 public override void Arrived(List <ActiveDropPodInfo> pods, int tile)
 {
     for (int i = 0; i < pods.Count; i++)
     {
         for (int j = 0; j < pods[i].innerContainer.Count; j++)
         {
             Pawn pawn = pods[i].innerContainer[j] as Pawn;
             if (pawn != null)
             {
                 if (pawn.RaceProps.Humanlike)
                 {
                     Pawn arg;
                     if (pawn.HomeFaction == this.settlement.Faction)
                     {
                         GenGuest.AddHealthyPrisonerReleasedThoughts(pawn);
                     }
                     else if (PawnsFinder.AllMapsCaravansAndTravelingTransportPods_Alive_FreeColonists.TryRandomElement(out arg))
                     {
                         Find.HistoryEventsManager.RecordEvent(new HistoryEvent(HistoryEventDefOf.SoldSlave, arg.Named(HistoryEventArgsNames.Doer)), true);
                     }
                 }
                 else if (pawn.RaceProps.Animal && pawn.relations != null)
                 {
                     Pawn firstDirectRelationPawn = pawn.relations.GetFirstDirectRelationPawn(PawnRelationDefOf.Bond, null);
                     if (firstDirectRelationPawn != null && firstDirectRelationPawn.needs.mood != null)
                     {
                         pawn.relations.RemoveDirectRelation(PawnRelationDefOf.Bond, firstDirectRelationPawn);
                         firstDirectRelationPawn.needs.mood.thoughts.memories.TryGainMemory(ThoughtDefOf.SoldMyBondedAnimalMood, null, null);
                     }
                 }
             }
         }
     }
     FactionGiftUtility.GiveGift(pods, this.settlement);
 }
        protected override IEnumerable <Toil> MakeNewToils()
        {
            this.FailOnDestroyedOrNull(TargetIndex.A);
            this.FailOnBurningImmobile(TargetIndex.B);
            this.FailOn(() => ((Pawn)(Thing)GetActor().CurJob.GetTarget(TargetIndex.A)).guest.interactionMode != PrisonerInteractionModeDefOf.Release);
            this.FailOnDowned(TargetIndex.A);
            this.FailOnAggroMentalState(TargetIndex.A);
            yield return(Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.ClosestTouch).FailOn(() => !Prisoner.IsPrisonerOfColony || !Prisoner.guest.PrisonerIsSecure).FailOnSomeonePhysicallyInteracting(TargetIndex.A));

            yield return(Toils_Haul.StartCarryThing(TargetIndex.A));

            Toil carryToCell = Toils_Haul.CarryHauledThingToCell(TargetIndex.B);

            yield return(carryToCell);

            yield return(Toils_Haul.PlaceHauledThingInCell(TargetIndex.B, carryToCell, storageMode: false));

            Toil setReleased = new Toil();

            setReleased.initAction = delegate
            {
                Pawn pawn = setReleased.actor.jobs.curJob.targetA.Thing as Pawn;
                GenGuest.PrisonerRelease(pawn);
                pawn.guest.ClearLastRecruiterData();
                if (!PawnBanishUtility.WouldBeLeftToDie(pawn, pawn.Map.Tile))
                {
                    GenGuest.AddHealthyPrisonerReleasedThoughts(pawn);
                }
            };
            yield return(setReleased);
        }
 public override void Arrived(List <ActiveDropPodInfo> pods, int tile)
 {
     for (int i = 0; i < pods.Count; i++)
     {
         for (int j = 0; j < pods[i].innerContainer.Count; j++)
         {
             Pawn pawn = pods[i].innerContainer[j] as Pawn;
             if (pawn == null)
             {
                 continue;
             }
             if (pawn.RaceProps.Humanlike)
             {
                 if (pawn.FactionOrExtraMiniOrHomeFaction == settlement.Faction)
                 {
                     GenGuest.AddHealthyPrisonerReleasedThoughts(pawn);
                 }
                 else
                 {
                     GenGuest.AddPrisonerSoldThoughts(pawn);
                 }
             }
             else if (pawn.RaceProps.Animal && pawn.relations != null)
             {
                 Pawn firstDirectRelationPawn = pawn.relations.GetFirstDirectRelationPawn(PawnRelationDefOf.Bond);
                 if (firstDirectRelationPawn != null && firstDirectRelationPawn.needs.mood != null)
                 {
                     pawn.relations.RemoveDirectRelation(PawnRelationDefOf.Bond, firstDirectRelationPawn);
                     firstDirectRelationPawn.needs.mood.thoughts.memories.TryGainMemory(ThoughtDefOf.SoldMyBondedAnimalMood);
                 }
             }
         }
     }
     FactionGiftUtility.GiveGift(pods, settlement);
 }