예제 #1
0
        public override void Notify_QuestSignalReceived(Signal signal)
        {
            base.Notify_QuestSignalReceived(signal);
            if (!string.IsNullOrEmpty(getColonistsFromSignal) && signal.tag == getColonistsFromSignal)
            {
                if (signal.args.TryGetArg("SUBJECT", out var arg))
                {
                    ReadPawns(arg.arg);
                }
                if (signal.args.TryGetArg("SENT", out var arg2))
                {
                    ReadPawns(arg2.arg);
                }
            }
            if (!(signal.tag == inSignal))
            {
                return;
            }
            Letter letter = Gen.MemberwiseClone(this.letter);

            letter.ID = Find.UniqueIDsManager.GetNextLetterID();
            ChoiceLetter choiceLetter = letter as ChoiceLetter;

            if (choiceLetter != null)
            {
                choiceLetter.quest = quest;
            }
            ChoiceLetter_ChoosePawn choiceLetter_ChoosePawn = letter as ChoiceLetter_ChoosePawn;

            if (choiceLetter_ChoosePawn != null)
            {
                if (useColonistsOnMap != null && useColonistsOnMap.HasMap)
                {
                    choiceLetter_ChoosePawn.pawns.Clear();
                    choiceLetter_ChoosePawn.pawns.AddRange(useColonistsOnMap.Map.mapPawns.FreeColonists);
                    choiceLetter_ChoosePawn.chosenPawnSignal = chosenPawnSignal;
                }
                if (useColonistsFromCaravanArg && signal.args.TryGetArg("CARAVAN", out Caravan arg3) && arg3 != null)
                {
                    choiceLetter_ChoosePawn.pawns.Clear();
                    choiceLetter_ChoosePawn.pawns.AddRange(arg3.PawnsListForReading.Where((Pawn x) => x.IsFreeColonist));
                    choiceLetter_ChoosePawn.chosenPawnSignal = chosenPawnSignal;
                }
                if (!string.IsNullOrEmpty(getColonistsFromSignal))
                {
                    colonistsFromSignal.RemoveAll((Pawn x) => x.Dead);
                    choiceLetter_ChoosePawn.pawns.Clear();
                    choiceLetter_ChoosePawn.pawns.AddRange(colonistsFromSignal);
                    choiceLetter_ChoosePawn.chosenPawnSignal = chosenPawnSignal;
                }
            }
            if (getLookTargetsFromSignal && !letter.lookTargets.IsValid() && SignalArgsUtility.TryGetLookTargets(signal.args, "SUBJECT", out var lookTargets))
            {
                letter.lookTargets = lookTargets;
            }
            letter.label = signal.args.GetFormattedText(letter.label);
            ChoiceLetter choiceLetter2 = letter as ChoiceLetter;
            bool         flag          = true;

            if (choiceLetter2 != null)
            {
                choiceLetter2.title = signal.args.GetFormattedText(choiceLetter2.title);
                choiceLetter2.text  = signal.args.GetFormattedText(choiceLetter2.text);
                if (choiceLetter2.text.NullOrEmpty())
                {
                    flag = false;
                }
            }
            if (filterDeadPawnsFromLookTargets)
            {
                for (int num = letter.lookTargets.targets.Count - 1; num >= 0; num--)
                {
                    Thing thing = letter.lookTargets.targets[num].Thing;
                    Pawn  pawn  = thing as Pawn;
                    if (pawn != null && pawn.Dead)
                    {
                        letter.lookTargets.targets.Remove(thing);
                    }
                }
            }
            if (flag)
            {
                Find.LetterStack.ReceiveLetter(letter);
            }
            void ReadPawns(object obj)
            {
                Pawn item;

                if ((item = obj as Pawn) != null && !colonistsFromSignal.Contains(item))
                {
                    colonistsFromSignal.Add(item);
                }
                List <Pawn> source;

                if ((source = obj as List <Pawn>) != null)
                {
                    colonistsFromSignal.AddRange(source.Where((Pawn p) => !colonistsFromSignal.Contains(p)));
                }
                List <Thing> source2;

                if ((source2 = obj as List <Thing>) != null)
                {
                    colonistsFromSignal.AddRange(from Pawn p in source2.Where((Thing t) => t is Pawn)
                                                 where !colonistsFromSignal.Contains(p)
                                                 select p);
                }
            }
        }
예제 #2
0
        public override void Notify_QuestSignalReceived(Signal signal)
        {
            base.Notify_QuestSignalReceived(signal);
            if (!(signal.tag == inSignal))
            {
                return;
            }
            Letter letter = Gen.MemberwiseClone(this.letter);

            letter.ID = Find.UniqueIDsManager.GetNextLetterID();
            ChoiceLetter choiceLetter = letter as ChoiceLetter;

            if (choiceLetter != null)
            {
                choiceLetter.quest = quest;
            }
            ChoiceLetter_ChoosePawn choiceLetter_ChoosePawn = letter as ChoiceLetter_ChoosePawn;

            if (choiceLetter_ChoosePawn != null)
            {
                if (useColonistsOnMap != null && useColonistsOnMap.HasMap)
                {
                    choiceLetter_ChoosePawn.pawns.Clear();
                    choiceLetter_ChoosePawn.pawns.AddRange(useColonistsOnMap.Map.mapPawns.FreeColonists);
                    choiceLetter_ChoosePawn.chosenPawnSignal = chosenPawnSignal;
                }
                if (useColonistsFromCaravanArg && signal.args.TryGetArg("CARAVAN", out Caravan arg) && arg != null)
                {
                    choiceLetter_ChoosePawn.pawns.Clear();
                    choiceLetter_ChoosePawn.pawns.AddRange(arg.PawnsListForReading.Where((Pawn x) => x.IsFreeColonist));
                    choiceLetter_ChoosePawn.chosenPawnSignal = chosenPawnSignal;
                }
            }
            if (getLookTargetsFromSignal && !letter.lookTargets.IsValid() && SignalArgsUtility.TryGetLookTargets(signal.args, "SUBJECT", out LookTargets lookTargets))
            {
                letter.lookTargets = lookTargets;
            }
            letter.label = signal.args.GetFormattedText(letter.label);
            ChoiceLetter choiceLetter2 = letter as ChoiceLetter;
            bool         flag          = true;

            if (choiceLetter2 != null)
            {
                choiceLetter2.title = signal.args.GetFormattedText(choiceLetter2.title);
                choiceLetter2.text  = signal.args.GetFormattedText(choiceLetter2.text);
                if (choiceLetter2.text.NullOrEmpty())
                {
                    flag = false;
                }
            }
            if (filterDeadPawnsFromLookTargets)
            {
                for (int num = letter.lookTargets.targets.Count - 1; num >= 0; num--)
                {
                    Thing thing = letter.lookTargets.targets[num].Thing;
                    Pawn  pawn  = thing as Pawn;
                    if (pawn != null && pawn.Dead)
                    {
                        letter.lookTargets.targets.Remove(thing);
                    }
                }
            }
            if (flag)
            {
                Find.LetterStack.ReceiveLetter(letter);
            }
        }