Пример #1
0
        public override void Notify_QuestSignalReceived(Signal signal)
        {
            base.Notify_QuestSignalReceived(signal);
            if (!(signal.tag == inSignal))
            {
                return;
            }
            pawns.RemoveAll((Pawn x) => x.Destroyed);
            items.RemoveAll((Thing x) => x.Destroyed);
            Thing thing  = Things.Where((Thing x) => x is Pawn).MaxByWithFallback((Thing x) => x.MarketValue);
            Thing thing2 = Things.MaxByWithFallback((Thing x) => x.MarketValue * (float)x.stackCount);

            if (mapParent != null && mapParent.HasMap && Things.Any())
            {
                Map     map    = mapParent.Map;
                IntVec3 intVec = (dropSpot.IsValid ? dropSpot : GetRandomDropSpot());
                if (sendStandardLetter)
                {
                    TaggedString title;
                    TaggedString text;
                    if (joinPlayer && pawns.Count == 1 && pawns[0].RaceProps.Humanlike)
                    {
                        text  = "LetterRefugeeJoins".Translate(pawns[0].Named("PAWN"));
                        title = "LetterLabelRefugeeJoins".Translate(pawns[0].Named("PAWN"));
                        PawnRelationUtility.TryAppendRelationsWithColonistsInfo(ref text, ref title, pawns[0]);
                    }
                    else
                    {
                        text  = "LetterQuestDropPodsArrived".Translate(GenLabel.ThingsLabel(Things));
                        title = "LetterLabelQuestDropPodsArrived".Translate();
                        PawnRelationUtility.Notify_PawnsSeenByPlayer_Letter(pawns, ref title, ref text, "LetterRelatedPawnsNeutralGroup".Translate(Faction.OfPlayer.def.pawnsPlural), informEvenIfSeenBefore: true);
                    }
                    title = (customLetterLabel.NullOrEmpty() ? title : customLetterLabel.Formatted(title.Named("BASELABEL")));
                    text  = (customLetterText.NullOrEmpty() ? text : customLetterText.Formatted(text.Named("BASETEXT")));
                    Find.LetterStack.ReceiveLetter(title, text, customLetterDef ?? LetterDefOf.PositiveEvent, new TargetInfo(intVec, map), null, quest);
                }
                if (joinPlayer)
                {
                    for (int i = 0; i < pawns.Count; i++)
                    {
                        if (pawns[i].Faction != Faction.OfPlayer)
                        {
                            pawns[i].SetFaction(Faction.OfPlayer);
                        }
                    }
                }
                else if (makePrisoners)
                {
                    for (int j = 0; j < pawns.Count; j++)
                    {
                        if (pawns[j].RaceProps.Humanlike)
                        {
                            if (!pawns[j].IsPrisonerOfColony)
                            {
                                pawns[j].guest.SetGuestStatus(Faction.OfPlayer, prisoner: true);
                            }
                            HealthUtility.TryAnesthetize(pawns[j]);
                        }
                    }
                }
                for (int k = 0; k < pawns.Count; k++)
                {
                    pawns[k].needs.SetInitialLevels();
                }
                DropPodUtility.DropThingsNear(intVec, map, Things, 110, canInstaDropDuringInit: false, leaveSlag: false, !useTradeDropSpot, forbid: false);
                importantLookTarget = items.Find((Thing x) => x.GetInnerIfMinified() is MonumentMarker).GetInnerIfMinified();
                items.Clear();
            }
            if (!outSignalResult.NullOrEmpty())
            {
                if (thing != null)
                {
                    Find.SignalManager.SendSignal(new Signal(outSignalResult, thing.Named("SUBJECT")));
                }
                else if (thing2 != null)
                {
                    Find.SignalManager.SendSignal(new Signal(outSignalResult, thing2.Named("SUBJECT")));
                }
                else
                {
                    Find.SignalManager.SendSignal(new Signal(outSignalResult));
                }
            }
        }