Esempio n. 1
0
        public static void GiveScoutingComp(Faction faction, int delayDays, int totalDays, int scoutDays, int addDaysIfAlreadyHas = 5)
        {
            if (!ScoutingComp.ScoutAlready(faction, out ScoutingComp outComp))
            {
                ScoutingComp comp = new ScoutingComp(faction, delayDays * 60000, totalDays * 60000, scoutDays);
                comp.id = QuestsManager.Communications.UniqueIdManager.GetNextComponentID();

                QuestsManager.Communications.RegisterComponent(comp);

                FactionInteraction interaction = QuestsManager.Communications.FactionManager.GetInteraction(faction);
                foreach (var opt in interaction.Options)
                {
                    if (opt is CommOption_SubscribeScout opt2)
                    {
                        opt2.Active = true;
                    }
                }

                Find.LetterStack.ReceiveLetter("ScoutComp_GiveTitle".Translate(), "ScoutComp_Give".Translate(faction.Name, delayDays, totalDays), LetterDefOf.PositiveEvent);
            }
            else
            {
                outComp.AddDays(addDaysIfAlreadyHas);
                Find.LetterStack.ReceiveLetter("ScoutComp_AlreadyGiveTitle".Translate(), "ScoutComp_AlreadyGive".Translate(faction.Name, addDaysIfAlreadyHas), LetterDefOf.PositiveEvent);
            }
        }
Esempio n. 2
0
        public override void DoAction(FactionInteraction interaction, Pawn speaker, Pawn defendant)
        {
            var war = interaction.FirstWarWithPlayer();

            if (war != null)
            {
                Messages.Message("CommOption_SubscribeScout_CantSub".Translate(), MessageTypeDefOf.NeutralEvent);
                return;
            }

            bool subAlready = ScoutingComp.ScoutAlready(interaction.Faction, out ScoutingComp outComp);

            StringBuilder builder = new StringBuilder();

            builder.Append("CommOption_SubscribeScout_SubTitle".Translate());

            DiaOption diaOption = new DiaOption("CommOption_SubscribeScout_SubButton".Translate());

            if (subAlready)
            {
                builder.Append("CommOption_SubscribeScout_SubAlready".Translate(outComp.GetDays()));
                diaOption.Disable("CommOption_SubscribeScout_SubAlreadyOption".Translate());
            }
            else if (interaction.Faction.PlayerGoodwill < 80)
            {
                diaOption.Disable("CommOption_SubscribeScout_SubGoodWillOption".Translate());
            }

            diaOption.action = delegate
            {
                if (!subAlready)
                {
                    ScoutingComp.GiveScoutingComp(interaction.Faction, 2, 14, 5);
                }
            };
            diaOption.resolveTree = true;

            DiaOption diaOption2 = new DiaOption("CommOption_ExitNode".Translate());

            diaOption2.resolveTree = true;

            DiaNode diaNode = new DiaNode(builder.ToString());

            diaNode.options.Add(diaOption);
            diaNode.options.Add(diaOption2);

            Dialog_NodeTree dialog_NodeTree = new Dialog_NodeTree(diaNode, delayInteractivity: true);

            Find.WindowStack.Add(dialog_NodeTree);
        }