public override void Notify_QuestSignalReceived(Signal signal)
        {
            base.Notify_QuestSignalReceived(signal);
            if (!(signal.tag == inSignal))
            {
                return;
            }
            LookTargets lookTargets = this.lookTargets;

            if (getLookTargetsFromSignal && !lookTargets.IsValid())
            {
                SignalArgsUtility.TryGetLookTargets(signal.args, "SUBJECT", out lookTargets);
            }
            if (lookTargets.IsValid())
            {
                if (select)
                {
                    CameraJumper.TryJumpAndSelect(lookTargets.TryGetPrimaryTarget());
                }
                else
                {
                    CameraJumper.TryJump(lookTargets.TryGetPrimaryTarget());
                }
            }
        }
Exemple #2
0
 protected override void Enable(SignalArgs receivedArgs)
 {
     base.Enable(receivedArgs);
     resolvedLabel       = receivedArgs.GetFormattedText(label);
     resolvedExplanation = receivedArgs.GetFormattedText(explanation);
     resolvedLookTargets = lookTargets;
     if (getLookTargetsFromSignal && !resolvedLookTargets.IsValid())
     {
         SignalArgsUtility.TryGetLookTargets(receivedArgs, "SUBJECT", out resolvedLookTargets);
     }
 }
        public override void Notify_QuestSignalReceived(Signal signal)
        {
            base.Notify_QuestSignalReceived(signal);
            if (!(signal.tag == inSignal))
            {
                return;
            }
            DiaNode     diaNode             = new DiaNode(signal.args.GetFormattedText(text));
            LookTargets resolvedLookTargets = lookTargets;

            if (getLookTargetsFromSignal && !resolvedLookTargets.IsValid())
            {
                SignalArgsUtility.TryGetLookTargets(signal.args, "SUBJECT", out resolvedLookTargets);
            }
            if (resolvedLookTargets.IsValid())
            {
                DiaOption diaOption = new DiaOption("JumpToLocation".Translate());
                diaOption.action = delegate
                {
                    CameraJumper.TryJumpAndSelect(resolvedLookTargets.TryGetPrimaryTarget());
                };
                diaOption.resolveTree = true;
                diaNode.options.Add(diaOption);
            }
            if (options.Any())
            {
                for (int i = 0; i < options.Count; i++)
                {
                    int       localIndex = i;
                    DiaOption diaOption2 = new DiaOption(signal.args.GetFormattedText(options[i].text));
                    diaOption2.action = delegate
                    {
                        Find.SignalManager.SendSignal(new Signal(options[localIndex].outSignal));
                    };
                    diaOption2.resolveTree = true;
                    diaNode.options.Add(diaOption2);
                }
            }
            else
            {
                DiaOption diaOption3 = new DiaOption("OK".Translate());
                diaOption3.resolveTree = true;
                diaNode.options.Add(diaOption3);
            }
            TaggedString formattedText = signal.args.GetFormattedText(title);

            Find.WindowStack.Add(new Dialog_NodeTreeWithFactionInfo(diaNode, relatedFaction, delayInteractivity: true, radioMode, formattedText));
            if (addToArchive)
            {
                Find.Archive.Add(new ArchivedDialog(diaNode.text, formattedText, relatedFaction));
            }
        }
Exemple #4
0
 public override void Notify_QuestSignalReceived(Signal signal)
 {
     base.Notify_QuestSignalReceived(signal);
     if (signal.tag == inSignal)
     {
         LookTargets lookTargets = this.lookTargets;
         if (getLookTargetsFromSignal && !lookTargets.IsValid())
         {
             SignalArgsUtility.TryGetLookTargets(signal.args, "SUBJECT", out lookTargets);
         }
         TaggedString formattedText = signal.args.GetFormattedText(message);
         if (!formattedText.NullOrEmpty())
         {
             Messages.Message(formattedText, lookTargets, messageType ?? MessageTypeDefOf.NeutralEvent, quest, historical);
         }
     }
 }
 public override void Notify_QuestSignalReceived(Signal signal)
 {
     base.Notify_QuestSignalReceived(signal);
     if (signal.tag == inSignal && faction != null && faction != Faction.OfPlayer)
     {
         LookTargets         lookTargets;
         GlobalTargetInfo    value = (lookTarget.IsValid ? lookTarget : ((!getLookTargetFromSignal) ? GlobalTargetInfo.Invalid : ((!SignalArgsUtility.TryGetLookTargets(signal.args, "SUBJECT", out lookTargets)) ? GlobalTargetInfo.Invalid : lookTargets.TryGetPrimaryTarget())));
         FactionRelationKind playerRelationKind = faction.PlayerRelationKind;
         int arg = 0;
         if (!signal.args.TryGetArg("GOODWILL", out arg))
         {
             arg = change;
         }
         faction.TryAffectGoodwillWith(Faction.OfPlayer, arg, canSendMessage, canSendHostilityLetter, signal.args.GetFormattedText(reason), value);
         TaggedString text = "";
         faction.TryAppendRelationKindChangedInfo(ref text, playerRelationKind, faction.PlayerRelationKind);
         if (!text.NullOrEmpty())
         {
             text = "\n\n" + text;
         }
     }
 }
Exemple #6
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);
                }
            }
        }
Exemple #7
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);
            }
        }