Example #1
0
        private void CreateDialogOptions(string text, Pawn refugee, IntVec3 spawnSpot, Map map, Faction enemyFac)
        {
            DiaNode   diaNode   = new DiaNode(text);
            DiaOption diaOption = CreateAcceptOption(refugee, spawnSpot, map, enemyFac);

            diaNode.options.Add(diaOption);

            string text2 = "RefugeeChasedRejected".Translate(new object[]
            {
                refugee.NameStringShort
            });
            DiaNode   diaNode2   = new DiaNode(text2);
            DiaOption diaOption2 = new DiaOption("OK".Translate());

            diaOption2.resolveTree = true;
            diaNode2.options.Add(diaOption2);
            DiaOption diaOption3 = new DiaOption("RefugeeChasedInitial_Reject".Translate());

            diaOption3.action = delegate
            {
                Find.WorldPawns.PassToWorld(refugee, PawnDiscardDecideMode.Decide);
            };
            diaOption3.link = diaNode2;
            diaNode.options.Add(diaOption3);
            Find.WindowStack.Add(new Dialog_NodeTree(diaNode, true, true));
        }
 public static void Postfix(Pawn negotiator, Faction faction, ref DiaNode __result)
 {
     if (negotiator.Map?.IsPlayerHome == true)
     {
         __result.options.Insert(0, InviteGuestsOption(negotiator.Map, faction, negotiator));
     }
 }
Example #3
0
        public static IEnumerable <DiaNode> TraverseNodes(this DiaNode root, HashSet <DiaNode> processed = null)
        {
            if (processed == null)
            {
                processed = new HashSet <DiaNode>();
            }

            if (!processed.Add(root))
            {
                yield break;
            }

            yield return(root);

            foreach (var opt in root.options)
            {
                if (opt.link != null)
                {
                    foreach (var node in TraverseNodes(opt.link, processed))
                    {
                        yield return(node);
                    }
                }
            }
        }
 public static IEnumerable <Gizmo> ShipStartupGizmos(Building building)
 {
     if (ArchotechUtility.HasHibernatingParts(building))
     {
         yield return(new Command_Action
         {
             action = delegate
             {
                 DiaNode diaNode = new DiaNode("GR_ArchotechProjectText".Translate());
                 DiaOption diaOption = new DiaOption("Confirm".Translate());
                 diaOption.action = delegate
                 {
                     ArchotechUtility.StartupHibernatingParts(building);
                 };
                 diaOption.resolveTree = true;
                 diaNode.options.Add(diaOption);
                 DiaOption diaOption2 = new DiaOption("GoBack".Translate());
                 diaOption2.resolveTree = true;
                 diaNode.options.Add(diaOption2);
                 Find.WindowStack.Add(new Dialog_NodeTree(diaNode, true, false, null));
             },
             defaultLabel = "GR_CommandArchotechStartup".Translate(),
             defaultDesc = "GR_CommandArchotechStartupDesc".Translate(),
             hotKey = KeyBindingDefOf.Misc1,
             icon = ContentFinder <Texture2D> .Get("ui/commands/GR_Microscope", true)
         });
     }
 }
        public override void DoEffect(Pawn usedBy)
        {
            base.DoEffect(usedBy);
            string  text     = "PolarisConvertCombatChipDESC".Translate();
            DiaNode diaNode  = new DiaNode(text);
            Hediff  reHediff = usedBy.health.hediffSet.hediffs.Find(x => x.def.hediffClass == typeof(Polarisbloc.Hediff_CombatChip));
            Hediff  bHediff  = usedBy.health.hediffSet.hediffs.Find(x => x.def == PolarisblocDefOf.PolarisCombatChip_NotActive);

            if (reHediff == null && bHediff == null)
            {
                Messages.Message("PolarisMessageFailedConvertCombatChip".Translate(usedBy.LabelShort), usedBy, MessageTypeDefOf.NegativeEvent);
                return;
            }
            if (bHediff != null)
            {
                foreach (DiaOption diaOption in this.GetDiaOptions(usedBy, bHediff))
                {
                    diaNode.options.Add(diaOption);
                }
            }
            else if (reHediff != null)
            {
                foreach (DiaOption diaOption in this.GetDiaOptions(usedBy, reHediff))
                {
                    diaNode.options.Add(diaOption);
                }
            }
            DiaOption diaOptionBack = new DiaOption("GoBack".Translate())
            {
                resolveTree = true
            };

            diaNode.options.Add(diaOptionBack);
            Find.WindowStack.Add(new Dialog_NodeTree(diaNode, true, true, "PolarisConvertCombatChipTitle".Translate()));
        }
        public DiaOption GetMedicalSupplyDiaOption(Building_OrbitalRelay orbitalRelay)
        {
            DiaOption           medicalSupplyDiaOption = new DiaOption("Request medical supply (" + Util_Spaceship.medicalSupplyCostInSilver + " silver)");
            Building_LandingPad landingPad             = Util_LandingPad.GetBestAvailableLandingPad(this.Map);

            if (Find.TickManager.TicksGame <= Util_Misc.Partnership.nextMedicalSupplyMinTick[this.Map])
            {
                medicalSupplyDiaOption.Disable("no available ship for now");
            }
            else if (TradeUtility.ColonyHasEnoughSilver(this.Map, Util_Spaceship.medicalSupplyCostInSilver) == false)
            {
                medicalSupplyDiaOption.Disable("not enough silver");
            }
            else if (landingPad == null)
            {
                medicalSupplyDiaOption.Disable("no available landing pad");
            }
            medicalSupplyDiaOption.action = delegate
            {
                TradeUtility.LaunchSilver(this.Map, Util_Spaceship.medicalSupplyCostInSilver);
                Util_Spaceship.SpawnSpaceship(landingPad, SpaceshipKind.Medical);
            };
            DiaNode supplyShipAcceptedDiaNode = new DiaNode("\"We are sending you a medical ship immediately.\n\n"
                                                            + "Hold on down there, we're coming!\n\n"
                                                            + "-- End of transmission --");
            DiaOption supplyShipAcceptedDiaOption = new DiaOption("OK");

            supplyShipAcceptedDiaOption.resolveTree = true;
            supplyShipAcceptedDiaNode.options.Add(supplyShipAcceptedDiaOption);
            medicalSupplyDiaOption.link = supplyShipAcceptedDiaNode;
            return(medicalSupplyDiaOption);
        }
        public DiaOption GetCargoSupplyDiaOption(Building_OrbitalRelay orbitalRelay)
        {
            DiaOption           cargoSupplyDiaOption = new DiaOption("Request cargo supply (" + Util_Spaceship.cargoSupplyCostInSilver + " silver)");
            Building_LandingPad landingPad           = Util_LandingPad.GetBestAvailableLandingPad(this.Map);

            if (Find.TickManager.TicksGame <= Util_Misc.Partnership.nextRequestedSupplyMinTick[this.Map])
            {
                cargoSupplyDiaOption.Disable("no available ship for now");
            }
            else if (TradeUtility.ColonyHasEnoughSilver(this.Map, Util_Spaceship.cargoSupplyCostInSilver) == false)
            {
                cargoSupplyDiaOption.Disable("not enough silver");
            }
            else if (landingPad == null)
            {
                cargoSupplyDiaOption.Disable("no available landing pad");
            }
            cargoSupplyDiaOption.action = delegate
            {
                TradeUtility.LaunchSilver(this.Map, Util_Spaceship.cargoSupplyCostInSilver);
                Util_Spaceship.SpawnSpaceship(landingPad, SpaceshipKind.CargoRequested);
            };
            DiaNode supplyShipAcceptedDiaNode = new DiaNode("\"Alright, a supply ship should arrive soon with our best stuff.\n"
                                                            + "Greetings partner!\"\n\n"
                                                            + "-- End of transmission --");
            DiaOption supplyShipAcceptedDiaOption = new DiaOption("OK");

            supplyShipAcceptedDiaOption.resolveTree = true;
            supplyShipAcceptedDiaNode.options.Add(supplyShipAcceptedDiaOption);
            cargoSupplyDiaOption.link = supplyShipAcceptedDiaNode;
            return(cargoSupplyDiaOption);
        }
        private static void ShowAskMayComeDialog(Faction faction, Map map, TaggedString reasons, Direction8Way spawnDirection, Action allow, Action refuse)
        {
            var text = "VisitorsArrivedDesc".Translate(faction, reasons);

            DiaNode   diaNode   = new DiaNode(text);
            DiaOption diaOption = new DiaOption("VisitorsArrivedAccept".Translate())
            {
                action = allow, resolveTree = true
            };

            diaNode.options.Add(diaOption);

            DiaOption diaOption2 = new DiaOption("VisitorsArrivedRefuse".Translate())
            {
                action = refuse, resolveTree = true
            };

            diaNode.options.Add(diaOption2);

            if (!map.listerBuildings.AllBuildingsColonistOfClass <Building_GuestBed>().Any())
            {
                DiaOption diaOption3 = new DiaOption("VisitorsArrivedRefuseUntilBeds".Translate());
                diaOption3.resolveTree = true;
                diaOption3.action      = () => {
                    Hospitality_MapComponent.RefuseGuestsUntilWeHaveBeds(map);
                    refuse();
                };
                diaNode.options.Add(diaOption3);
            }

            string title = "VisitorsArrivedTitle".Translate(new NamedArgument((MapParent)map.ParentHolder, "WORLDOBJECT"), spawnDirection.LabelShort());

            Find.WindowStack.Add(new Dialog_NodeTree(diaNode, true, true, title));
        }
Example #9
0
        private static DiaNode CantMakeItInTime(Faction faction, Pawn negotiator)
        {
            DiaNode diaNode = new DiaNode("CantSendMilitaryAidInTime".Translate(faction.leader).CapitalizeFirst());

            diaNode.options.Add(OKToRoot(faction, negotiator));
            return(diaNode);
        }
        public static DiaNode BeguilementSuccessNode(bool factionKnown)
        {
            DiaNode diaNode;
            InterceptedIncident_HumanCrowd incident = DialogUtilities.tempCaravan.incident as InterceptedIncident_HumanCrowd;

            if (incident.IsHostileToPlayer)
            {
                if (factionKnown)
                {
                    diaNode = new DiaNode("PES_Beguilement_SuccessLeave_Hostile".Translate(DialogUtilities.tempCaravan.CaravanTitle));
                    diaNode.options.Add(DialogUtilities.CurtOption("PES_Reassuring", null, null, true));
                }
                else
                {
                    diaNode = new DiaNode("PES_Intimidation_SuccessFlee_Hostile".Translate(DialogUtilities.tempCaravan.CaravanTitle, incident.SourceFaction.Name));
                    diaNode.options.Add(DialogUtilities.CurtOption("PES_Reassuring", null, null, true));
                }
            }
            else
            {
                diaNode = new DiaNode("PES_Beguilement_SuccessFlee_Friendly".Translate(DialogUtilities.tempCaravan.CaravanTitle, incident.SourceFaction.Name));
                diaNode.options.Add(DialogUtilities.CurtOption("PES_ASHAME", null, null, true));
            }
            return(diaNode);
        }
Example #11
0
        public static DiaNode RoyalHeirChangeConfirm(Faction faction, Pawn negotiator, Pawn currentHeir, Action confirmedAct)
        {
            StringBuilder stringBuilder = new StringBuilder();

            stringBuilder.Append("MakeHeirConfirm".Translate(faction, negotiator.Named("HOLDER")));
            if (currentHeir != null)
            {
                stringBuilder.Append(" " + "MakeHeirPreviousHeirWarning".Translate(negotiator.Named("HOLDER"), currentHeir.Named("HEIR")));
            }
            stringBuilder.Append(" " + "AreYouSure".Translate());
            DiaNode   diaNode = new DiaNode(stringBuilder.ToString());
            DiaOption item    = new DiaOption("Confirm".Translate())
            {
                action       = confirmedAct,
                linkLateBind = ResetToRoot(faction, negotiator)
            };

            diaNode.options.Add(item);
            DiaOption item2 = new DiaOption("GoBack".Translate())
            {
                linkLateBind = ResetToRoot(faction, negotiator)
            };

            diaNode.options.Add(item2);
            return(diaNode);
        }
        public static DiaNode ContactFailNode()
        {
            DiaNode diaNode = new DiaNode("PES_Contact_Fail".Translate(DialogUtilities.tempPawn.Name.ToStringShort));

            diaNode.options.Add(DialogUtilities.CurtOption("PES_ASHAME", null, null, true));
            return(diaNode);
        }
        private static DiaNode FightersSent()
        {
            DiaNode diaNode = new DiaNode("MilitaryAidSent".Translate(FactionDialogMaker.faction.leader.LabelIndefinite()).CapitalizeFirst());

            diaNode.options.Add(FactionDialogMaker.OKToRoot());
            return(diaNode);
        }
        public override void OpenLetter()
        {
            Pawn pawn = lookTargets.TryGetPrimaryTarget().Thing as Pawn;

            ThingWithComps deadlyItem = (ThingWithComps)lookTargets.targets.First(gti => gti.HasThing && gti.Thing.TryGetComp <CompLootAffixableThing>() != null).Thing;
            var            comp       = deadlyItem.TryGetComp <CompLootAffixableThing>();
            LootAffixDef   affix      = comp.AllAffixDefs.First(lad => lad.IsNegativeDeadly(deadlyItem));
            string         affixLabel = comp.AllAffixesByAffixDefs[affix];

            TaggedString text = "RimLoot_NegativeDeadlyAffixLetter_Desc".Translate(
                pawn.Named("PAWN"),
                deadlyItem.Named("ITEM"),
                affix.FullStatsReport(deadlyItem, affixLabel).Named("EFFECT")
                );

            DiaNode nodeRoot = new DiaNode(text);

            nodeRoot.options.AddRange(Choices);
            Find.WindowStack.Add(new Dialog_NodeTreeWithFactionInfo(
                                     nodeRoot:  nodeRoot,
                                     faction:   relatedFaction,
                                     radioMode: radioMode,
                                     title:     title
                                     ));
        }
        private static DiaOption RansomPrisoner(Faction faction, Pawn negotiator, Map map, DiaNode original)
        {
            IEnumerable <Pawn> prisoners = map.mapPawns.PrisonersOfColony.Where(predicate: p => p.Faction == faction).ToArray();
            DiaOption          dia       = new DiaOption(text: "DialogRansomDemand".Translate());

            if (!prisoners.Any())
            {
                dia.Disable(newDisabledReason: "DialogRansomNoPrisoners".Translate());
            }
            DiaNode diaNode = new DiaNode(text: "DialogRansomPrisonerList".Translate());

            foreach (Pawn p in prisoners)
            {
                int value = Mathf.RoundToInt(f: RansomSettings.MarketValue(p));

                DiaOption diaOption = new DiaOption(text: p.Name.ToStringFull + " (" + value + ")")
                {
                    resolveTree = true,
                    action      = () => Find.WindowStack.Add(new Page_PrisonerRansom(p, negotiator))
                };

                diaNode.options.Add(item: diaOption);
            }

            diaNode.options.Add(new DiaOption("GoBack".Translate())
            {
                link = original
            });
            dia.link = diaNode;
            return(dia);
        }
Example #16
0
        private static DiaNode FightersSent(Faction faction, Pawn negotiator)
        {
            DiaNode diaNode = new DiaNode("MilitaryAidSent".Translate(faction.leader).CapitalizeFirst());

            diaNode.options.Add(OKToRoot(faction, negotiator));
            return(diaNode);
        }
Example #17
0
        private void EndGameDialogMessage(string msg)
        {
            bool    allowKeepPlaying = true;
            Color   screenFillColor  = Color.clear;
            DiaNode diaNode          = new DiaNode(msg);

            if (allowKeepPlaying)
            {
                DiaOption diaOption = new DiaOption("GameOverKeepPlaying".Translate());
                diaOption.resolveTree = true;
                diaNode.options.Add(diaOption);
            }
            DiaOption diaOption2 = new DiaOption("GameOverMainMenu".Translate());

            diaOption2.action = delegate
            {
                GenScene.GoToMainMenu();
            };
            diaOption2.resolveTree = true;
            diaNode.options.Add(diaOption2);
            Dialog_NodeTree dialog_NodeTree = new Dialog_GameEnd(diaNode, true, false, "Challenge Complete!");

            dialog_NodeTree.screenFillColor     = screenFillColor;
            dialog_NodeTree.silenceAmbientSound = !allowKeepPlaying;
            Find.WindowStack.Add(dialog_NodeTree);
        }
        public static DiaNode FriendlyNode()
        {
            TravelingIncidentCaravan caravan = DialogUtilities.tempCaravan;
            Pawn pawn = DialogUtilities.tempPawn;

            if (!(caravan.incident is InterceptedIncident_HumanCrowd_Neutral incident))
            {
                return(null);
            }

            DiaNode diaNode = new DiaNode("PES_Friendly_Greeting".Translate(caravan.CaravanTitle, pawn.Name.ToStringShort) + "\n");

            DiaNode diaNodeLeaving = new DiaNode("PES_Friendly_Dismissed".Translate());

            diaNodeLeaving.options.Add(DialogUtilities.NormalDisconnectOption());

            DiaOption option = new DiaOption("PES_Friendly_Dismiss".Translate() + "\n");

            option.link   = diaNodeLeaving;
            option.action = () => { caravan.Dismiss(); };

            diaNode.options.Add(option);
            diaNode.options.Add(DialogUtilities.NormalDisconnectOption());

            return(diaNode);
        }
        public DiaNode GetAirStrikeDetailsDiaNode(DiaNode parentNode, AirStrikeDef strikeDef)
        {
            DiaNode airStrikeDetailsDiaNode = new DiaNode(strikeDef.LabelCap + "\n\n"
                                                          + strikeDef.description + "\n\n"
                                                          + "Runs number: " + strikeDef.runsNumber + "\n\n"
                                                          + "Cost: " + strikeDef.costInSilver + " silvers");
            DiaOption airStrikeConfirmDiaOption = new DiaOption("Confirm");

            airStrikeConfirmDiaOption.action = delegate
            {
                this.previousTimeSpeed        = Find.TickManager.CurTimeSpeed;
                Find.TickManager.CurTimeSpeed = TimeSpeed.Paused;
                this.selectedStrikeDef        = strikeDef;
                Util_Misc.SelectAirStrikeTarget(this.Map, SpawnAirStrikeBeacon);
            };
            airStrikeConfirmDiaOption.resolveTree = true;
            if (TradeUtility.ColonyHasEnoughSilver(this.Map, strikeDef.costInSilver) == false)
            {
                airStrikeConfirmDiaOption.Disable("not enough silver");
            }
            airStrikeDetailsDiaNode.options.Add(airStrikeConfirmDiaOption);
            DiaOption airStrikeBackDiaOption = new DiaOption("Back");

            airStrikeBackDiaOption.link = parentNode;
            airStrikeDetailsDiaNode.options.Add(airStrikeBackDiaOption);
            return(airStrikeDetailsDiaNode);
        }
        public static DiaNode FactionWarPeaceTalks(Pawn pawn, Faction factionOne, Faction factionInstigator, IIncidentTarget incidentTarget = null)
        {
            string factionInstigatorLeaderName = factionInstigator.leader != null
                ? factionInstigator.leader.Name.ToStringFull
                : factionInstigator.Name;

            string factionOneLeaderName =
                factionOne.leader != null ? factionOne.leader.Name.ToStringFull : factionOne.Name;

            DiaNode dialogueGreeting = new DiaNode(text: "MFI_FactionWarPeaceTalksIntroduction".Translate(factionOneLeaderName, factionInstigatorLeaderName, pawn.Label));

            foreach (DiaOption option in DialogueOptions(pawn: pawn, factionOne: factionOne, factionInstigator: factionInstigator, incidentTarget: incidentTarget))
            {
                dialogueGreeting.options.Add(item: option);
            }
            if (Prefs.DevMode)
            {
                dialogueGreeting.options.Add(item: new DiaOption(text: "(Dev: start war)")
                {
                    action = () =>
                    { Find.World.GetComponent <WorldComponent_MFI_FactionWar>().StartWar(factionOne: factionOne, factionInstigator: factionInstigator, selfResolved: false); },
                    linkLateBind =
                        () => DialogueResolver(textResult: "Alrighty. War started. Sorry about the lack of fancy flavour text for this dev mode only option.")
                });
            }
            return(dialogueGreeting);
        }
Example #21
0
        public static void OpenDialog(DiaNode node)
        {
            Dialog_Negotiation dialog_Negotiation = new Dialog_Negotiation(tempPawn, tempCaravan, node, true);

            dialog_Negotiation.soundAmbient = SoundDefOf.RadioComms_Ambience;
            Find.WindowStack.Add(dialog_Negotiation);
        }
Example #22
0
        protected override IEnumerable <Toil> MakeNewToils()
        {
            yield return(Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.InteractionCell));

            yield return(new Toil
            {
                defaultCompleteMode = ToilCompleteMode.Delay,
                initAction = delegate()
                {
                    Log.Message(" - MakeNewToils - var comp = TargetA.Pawn.TryGetComp<CompQuestGiver>(); - 2", true);
                    var comp = TargetA.Pawn.TryGetComp <CompQuestGiver>();
                    Log.Message(" - MakeNewToils - if (comp != null) - 3", true);
                    if (comp != null)
                    {
                        Log.Message(" - MakeNewToils - var diaNode = new DiaNode(comp.startDialog.text); - 4", true);
                        Log.Message("comp.startDialog: " + comp.startDialog, true);
                        var diaNode = new DiaNode(comp.startDialog.text);
                        Log.Message(" - MakeNewToils - var window = new DialogWindow(diaNode); - 5", true);
                        var window = new DialogWindow(diaNode);
                        Log.Message(" - MakeNewToils - window.curDialog = comp.startDialog; - 6", true);
                        window.curDialog = comp.startDialog;
                        Log.Message(" - MakeNewToils - window.initiator = pawn; - 7", true);
                        window.initiator = pawn;
                        Log.Message(" - MakeNewToils - window.talker = comp.parent as Pawn; - 8", true);
                        window.talker = comp.parent as Pawn;
                        Log.Message(" - MakeNewToils - window.StartDialog(); - 9", true);
                        window.StartDialog();
                    }
                }
            });

            Log.Message(" - MakeNewToils - yield break; - 11", true);
            yield break;
        }
 public override void PostGameStart()
 {
     if (Find.GameInitData.startedFromEntry)
     {
         Find.MusicManagerPlay.disabled = true;
         Find.WindowStack.Notify_GameStartDialogOpened();
         DiaNode   diaNode   = new DiaNode(text.NullOrEmpty() ? textKey.TranslateSimple() : text);
         DiaOption diaOption = new DiaOption();
         diaOption.resolveTree = true;
         diaOption.clickSound  = null;
         diaNode.options.Add(diaOption);
         Dialog_NodeTree dialog_NodeTree = new Dialog_NodeTree(diaNode);
         dialog_NodeTree.soundClose  = ((closeSound != null) ? closeSound : SoundDefOf.GameStartSting);
         dialog_NodeTree.closeAction = delegate
         {
             Find.MusicManagerPlay.ForceSilenceFor(7f);
             Find.MusicManagerPlay.disabled = false;
             Find.WindowStack.Notify_GameStartDialogClosed();
             Find.TickManager.CurTimeSpeed = TimeSpeed.Normal;
             TutorSystem.Notify_Event("GameStartDialogClosed");
         };
         Find.WindowStack.Add(dialog_NodeTree);
         Find.Archive.Add(new ArchivedDialog(diaNode.text));
     }
 }
Example #24
0
        public static void Prompt(Action onAccept, string content, string title, bool forcePrompt = false)
        {
            if (forcePrompt || Controller.ShowPrompts)
            {
                DiaOption accept = new DiaOption("Archiver_Accept".CachedTranslation())
                {
                    action      = onAccept,
                    resolveTree = true
                };

                DiaOption reject = new DiaOption("Archiver_Cancel".CachedTranslation())
                {
                    resolveTree = true
                };

                DiaNode prompt = new DiaNode(content)
                {
                    options = new List <DiaOption> {
                        accept, reject
                    }
                };

                Find.WindowStack.Add(new Dialog_NodeTree(prompt, false, false, title));
            }

            else
            {
                onAccept();
            }
        }
Example #25
0
        public static void EndGameDialogMessage(string msg, bool allowKeepPlaying, Color screenFillColor)
        {
            DiaNode diaNode = new DiaNode(msg);

            if (allowKeepPlaying)
            {
                DiaOption diaOption = new DiaOption("GameOverKeepPlaying".Translate());
                diaOption.resolveTree = true;
                diaNode.options.Add(diaOption);
            }
            DiaOption diaOption2 = new DiaOption("GameOverMainMenu".Translate());

            diaOption2.action = delegate
            {
                GenScene.GoToMainMenu();
            };
            diaOption2.resolveTree = true;
            diaNode.options.Add(diaOption2);
            Dialog_NodeTree dialog_NodeTree = new Dialog_NodeTree(diaNode, true, false, null);

            dialog_NodeTree.screenFillColor     = screenFillColor;
            dialog_NodeTree.silenceAmbientSound = !allowKeepPlaying;
            dialog_NodeTree.closeOnAccept       = allowKeepPlaying;
            dialog_NodeTree.closeOnCancel       = allowKeepPlaying;
            Find.WindowStack.Add(dialog_NodeTree);
            Find.Archive.Add(new ArchivedDialog(diaNode.text, null, null));
        }
Example #26
0
        public static void AddOption(DiaNode __instance, ref DiaNode __result, Pawn negotiator, Faction faction)
        {
            if (faction.PlayerRelationKind != FactionRelationKind.Ally &&
                faction.PlayerRelationKind != FactionRelationKind.Neutral)
            {
                return;
            }

            if (!faction.def.pawnGroupMakers.Any(maker => maker.kindDef == PawnGroupKindDefOf.Trader))
            {
                return;
            }

            var map       = negotiator.Map;
            var newOption = RequestItemOption(map, faction, negotiator);

            // If there's a third option for requesting the AI Persona Core
            // then put it after that. Otherwise put it after first two
            // options (Request caravan & request military aid).
            var insertAtIndex = DefDatabase <ResearchProjectDef> .AllDefsListForReading.Any(rp =>
                                                                                            rp.HasTag(ResearchProjectTagDefOf.ShipRelated) && rp.IsFinished)
                ? 3
                : 2;

            __result.options.Insert(insertAtIndex, newOption);
        }
        private static DiaOption RequestMilitaryAidOption(Map map)
        {
            var text = "RequestMilitaryAid".Translate(new object[]
            {
                -25f
            });

            if (!faction.def.allowedArrivalTemperatureRange.ExpandedBy(-4f).Includes(map.mapTemperature.SeasonalTemp))
            {
                var diaOption = new DiaOption(text);
                diaOption.Disable("BadTemperature".Translate());
                return(diaOption);
            }
            var diaOption2 = new DiaOption(text);
            IEnumerable <IAttackTarget> targetsHostileToColony = map.attackTargetsCache.TargetsHostileToColony;

            if (JecsToolsFactionDialogMaker.megaOne == null)
            {
                JecsToolsFactionDialogMaker.megaOne = new Func <IAttackTarget, bool>(GenHostility.IsActiveThreatToPlayer);
            }
            if (targetsHostileToColony.Any(JecsToolsFactionDialogMaker.megaOne))
            {
                if (!map.attackTargetsCache.TargetsHostileToColony.Any((IAttackTarget p) => ((Thing)p).Faction != null && ((Thing)p).Faction.HostileTo(faction)))
                {
                    IEnumerable <IAttackTarget> targetsHostileToColony2 = map.attackTargetsCache.TargetsHostileToColony;
                    if (JecsToolsFactionDialogMaker.megaTwo == null)
                    {
                        JecsToolsFactionDialogMaker.megaTwo = new Func <IAttackTarget, bool>(GenHostility.IsActiveThreatToPlayer);
                    }
                    IEnumerable <Faction> source = (from pa in targetsHostileToColony2.Where(JecsToolsFactionDialogMaker.megaTwo)
                                                    select((Thing)pa).Faction into fa
                                                    where fa != null && !fa.HostileTo(faction)
                                                    select fa).Distinct <Faction>();
                    var key   = "MilitaryAidConfirmMutualEnemy";
                    var array = new object[2];
                    array[0] = faction.Name;
                    array[1] = GenText.ToCommaList(from fa in source
                                                   select fa.Name, true);
                    var diaNode    = new DiaNode(key.Translate(array));
                    var diaOption3 = new DiaOption("CallConfirm".Translate());
                    diaOption3.action = delegate
                    {
                        CallForAid(map);
                    };
                    diaOption3.link = FightersSent();
                    var diaOption4 = new DiaOption("CallCancel".Translate());
                    diaOption4.linkLateBind = ResetToRoot();
                    diaNode.options.Add(diaOption3);
                    diaNode.options.Add(diaOption4);
                    diaOption2.link = diaNode;
                    return(diaOption2);
                }
            }
            diaOption2.action = delegate
            {
                CallForAid(map);
            };
            diaOption2.link = FightersSent();
            return(diaOption2);
        }
 public static void FactionDialogForPostFix(ref DiaNode __result, Pawn negotiator, Faction faction)
 {
     if (faction.HostileTo(other: Faction.OfPlayer))
     {
         __result.options.Insert(index: 0, item: RansomPrisoner(faction: faction, negotiator: negotiator, map: negotiator.Map, original: __result));
     }
 }
Example #29
0
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            int rootTile;

            if (!this.TryFindRootTile(out rootTile))
            {
                return(false);
            }
            int tile;

            if (!this.TryFindDestinationTile(rootTile, out tile))
            {
                return(false);
            }
            WorldObject journeyDestination = WorldObjectMaker.MakeWorldObject(WorldObjectDefOf.EscapeShip);

            journeyDestination.Tile = tile;
            Find.WorldObjects.Add(journeyDestination);
            DiaNode   diaNode   = new DiaNode("JourneyOffer".Translate());
            DiaOption diaOption = new DiaOption("JumpToLocation".Translate());

            diaOption.action = delegate
            {
                CameraJumper.TryJumpAndSelect(journeyDestination);
            };
            diaOption.resolveTree = true;
            diaNode.options.Add(diaOption);
            DiaOption diaOption2 = new DiaOption("OK".Translate());

            diaOption2.resolveTree = true;
            diaNode.options.Add(diaOption2);
            Find.WindowStack.Add(new Dialog_NodeTree(diaNode, true, true, null));
            Find.Archive.Add(new ArchivedDialog(diaNode.text, null, null));
            return(true);
        }
Example #30
0
 public static void FactionDialogMaker_FactionDialogFor_Postfix(DiaNode __result, Pawn negotiator, Faction faction)
 {
     if (EndGame_Settings.FactionHistory || EndGame_Settings.FactionHistory || EndGame_Settings.FactionServitude)
     {
         __result.options.Insert(__result.options.Count - 1, FactionHistoryDialog.RequestFactionInfoOption(faction, negotiator));
     }
 }