public void StartDialog() { foreach (var option in curDialog.options) { var diaOption = new DiaOption(option.text); diaOption.action = delegate() { foreach (var action in option.actions) { action.window = this; action.DoAction(); } }; curNode.options.Add(diaOption); } Find.WindowStack.Add(this); }
private static DiaOption RequestAICoreQuest(Map map, Faction faction, Pawn negotiator) { string text = "RequestAICoreInformation".Translate(ThingDefOf.AIPersonaCore.label, 1500.ToString()); if (faction.PlayerGoodwill < 40) { DiaOption diaOption = new DiaOption(text); diaOption.Disable("NeedGoodwill".Translate(40.ToString("F0"))); return(diaOption); } IncidentDef def = IncidentDefOf.Quest_ItemStashAICore; bool flag = PlayerItemAccessibilityUtility.ItemStashHas(ThingDefOf.AIPersonaCore); IncidentParms coreIncidentParms = StorytellerUtility.DefaultParmsNow(IncidentCategoryDefOf.Misc, Find.World); coreIncidentParms.faction = faction; bool flag2 = def.Worker.CanFireNow(coreIncidentParms); if (flag || !flag2) { DiaOption diaOption2 = new DiaOption(text); diaOption2.Disable("NoKnownAICore".Translate(1500)); return(diaOption2); } if (AmountSendableSilver(map) < 1500) { DiaOption diaOption3 = new DiaOption(text); diaOption3.Disable("NeedSilverLaunchable".Translate(1500)); return(diaOption3); } DiaOption diaOption4 = new DiaOption(text); diaOption4.action = delegate { if (def.Worker.TryExecute(coreIncidentParms)) { TradeUtility.LaunchThingsOfType(ThingDefOf.Silver, 1500, map, null); } Current.Game.GetComponent <GameComponent_OnetimeNotification>().sendAICoreRequestReminder = false; }; string text2 = "RequestAICoreInformationResult".Translate(faction.leader).CapitalizeFirst(); DiaNode diaNode = new DiaNode(text2); diaNode.options.Add(OKToRoot(faction, negotiator)); diaOption4.link = diaNode; return(diaOption4); }
public void FinishProject(ResearchProjectDef proj, bool doCompletionDialog = false, Pawn researcher = null) { if (proj.prerequisites != null) { for (int i = 0; i < proj.prerequisites.Count; i++) { if (!proj.prerequisites[i].IsFinished) { FinishProject(proj.prerequisites[i]); } } } progress[proj] = proj.baseCost; if (researcher != null) { TaleRecorder.RecordTale(TaleDefOf.FinishedResearchProject, researcher, currentProj); } ReapplyAllMods(); if (doCompletionDialog) { string text = "ResearchFinished".Translate(currentProj.LabelCap) + "\n\n" + currentProj.description; DiaNode diaNode = new DiaNode(text); diaNode.options.Add(DiaOption.DefaultOK); DiaOption diaOption = new DiaOption("ResearchScreen".Translate()); diaOption.resolveTree = true; diaOption.action = delegate { Find.MainTabsRoot.SetCurrentTab(MainButtonDefOf.Research); }; diaNode.options.Add(diaOption); Find.WindowStack.Add(new Dialog_NodeTree(diaNode, delayInteractivity: true)); } if (!proj.discoveredLetterTitle.NullOrEmpty() && Find.Storyteller.difficulty.difficulty >= proj.discoveredLetterMinDifficulty) { Find.LetterStack.ReceiveLetter(proj.discoveredLetterTitle, proj.discoveredLetterText, LetterDefOf.NeutralEvent); } if (proj.unlockExtremeDifficulty && Find.Storyteller.difficulty.difficulty >= DifficultyDefOf.Rough.difficulty) { Prefs.ExtremeDifficultyUnlocked = true; Prefs.Save(); } if (currentProj == proj) { currentProj = null; } }
public DiaNode GetAirSupporDeniedDiaNode(DiaNode parentDiaNode) { DiaNode airSupporDeniedDiaNode = new DiaNode("\"We cannot send you the requested air support.\n" + "Damn those pirates, our ammo stock is too low to help you right now.\n" + "I hope you will find a solution on your own!\n\n" + "Greetings partner!\"\n\n" + "-- End of transmission --"); DiaOption airSupportDeniedDiaOption = new DiaOption("OK"); airSupportDeniedDiaOption.resolveTree = true; airSupporDeniedDiaNode.options.Add(airSupportDeniedDiaOption); DiaOption airSupportBackDiaOption = new DiaOption("Back"); airSupportBackDiaOption.link = parentDiaNode; airSupporDeniedDiaNode.options.Add(airSupportBackDiaOption); return(airSupporDeniedDiaNode); }
public void FinishProject(ResearchProjectDef proj, bool doCompletionDialog = false, Pawn researcher = null) { if (proj.prerequisites != null) { for (int i = 0; i < proj.prerequisites.Count; i++) { if (!proj.prerequisites[i].IsFinished) { FinishProject(proj.prerequisites[i]); } } } int num = GetTechprints(proj); if (num < proj.TechprintCount) { AddTechprints(proj, proj.TechprintCount - num); } progress[proj] = proj.baseCost; if (researcher != null) { TaleRecorder.RecordTale(TaleDefOf.FinishedResearchProject, researcher, currentProj); } ReapplyAllMods(); if (doCompletionDialog) { DiaNode diaNode = new DiaNode((string)("ResearchFinished".Translate(currentProj.LabelCap) + "\n\n" + currentProj.description)); diaNode.options.Add(DiaOption.DefaultOK); DiaOption diaOption = new DiaOption("ResearchScreen".Translate()); diaOption.resolveTree = true; diaOption.action = delegate { Find.MainTabsRoot.SetCurrentTab(MainButtonDefOf.Research); }; diaNode.options.Add(diaOption); Find.WindowStack.Add(new Dialog_NodeTree(diaNode, delayInteractivity: true)); } if (!proj.discoveredLetterTitle.NullOrEmpty() && Find.Storyteller.difficultyValues.AllowedBy(proj.discoveredLetterDisabledWhen)) { Find.LetterStack.ReceiveLetter(proj.discoveredLetterTitle, proj.discoveredLetterText, LetterDefOf.NeutralEvent); } if (currentProj == proj) { currentProj = null; } }
private IEnumerable <DiaOption> DialogueOptions(Pawn participatingPawn) { var annualExpoDialogueOutcome = $"Something went wrong with More Faction Interaction. Contact the mod author with this year's theme. If you bring a log (press CTRL + F12 now), you get a cookie. P: {participatingPawn} C: {caravan} E: {activity} H: {host}"; var broughtArt = (activity == MFI_DefOf.MFI_CulturalSwap) & MFI_Utilities.TryGetBestArt(caravan, out var art, out _); yield return(new DiaOption("MFI_AnnualExpoFirstOption".Translate()) { action = () => DetermineOutcome(out annualExpoDialogueOutcome), linkLateBind = () => { var endpoint = DialogueResolver(annualExpoDialogueOutcome, broughtArt); if (broughtArt) { endpoint.options[0].linkLateBind = () => EventRewardWorker_CulturalSwap.DialogueResolverArtOffer( "MFI_culturalSwapOutcomeWhoaYouActuallyBroughtArt", art, caravan); } return endpoint; } }); #if DEBUG var devModeTest = new DiaOption("DevMode: Test chances and outcomes") { action = DebugLogChances }; if (!Prefs.DevMode) { yield break; } yield return(devModeTest); yield return(new DiaOption("restart") { action = GenCommandLine.Restart }); #endif }
private static IEnumerable <DiaOption> AvailableMechanicusTemplates(Map map, Faction faction) { float mecRelationFactor = 100 * faction.GoodwillWith(Faction.OfPlayer); List <ResearchProjectDef> mecTecs = DefDatabase <ResearchProjectDef> .AllDefsListForReading.FindAll(x => x.defName.Contains("MecTec_")); foreach (ResearchProjectDef def in mecTecs) { if (def.baseCost <= mecRelationFactor && !def.IsFinished) { string optionText = "PurchaseTemplate".Translate() + ": " + def.label + " (" + def.baseCost + ")"; if (FactionDialogMaker_IoM.AmountSendableSilver(map) < def.baseCost) { DiaOption diaOption = new DiaOption(optionText); diaOption.Disable("NeedSilverLaunchable".Translate(new object[] { (int)def.baseCost })); yield return(diaOption); } else { DiaOption diaOption2 = new DiaOption(optionText); diaOption2.action = delegate { }; string text = "PurchaseTemplateConfirmation".Translate(new object[] { def.label }).CapitalizeFirst(); diaOption2.link = new DiaNode(text) { options = { FactionDialogMaker_IoM.ConfirmPurchase(map, def), new DiaOption("GoBack".Translate()) { linkLateBind = FactionDialogMaker_IoM.ResetToRoot() } } }; yield return(diaOption2); } } } }
private static DiaOption RequestRoyalHeirChangeOption(Map map, Faction faction, Pawn factionRepresentative, Pawn negotiator) { RoyalTitleDef currentTitle = negotiator.royalty.GetCurrentTitle(faction); Pawn heir = negotiator.royalty.GetHeir(faction); DiaOption diaOption = new DiaOption((heir != null) ? "RequestChangeRoyalHeir".Translate(negotiator.Named("HOLDER"), currentTitle.GetLabelCapFor(negotiator).Named("TITLE"), heir.Named("HEIR")) : "RequestSetRoyalHeir".Translate(negotiator.Named("HOLDER"), currentTitle.GetLabelCapFor(negotiator).Named("TITLE"))); bool num = Find.QuestManager.QuestsListForReading.Any((Quest q) => q.root == QuestScriptDefOf.ChangeRoyalHeir && q.State == QuestState.Ongoing && q.PartsListForReading.Any(delegate(QuestPart p) { QuestPart_ChangeHeir questPart_ChangeHeir = p as QuestPart_ChangeHeir; return(questPart_ChangeHeir != null && !questPart_ChangeHeir.done && questPart_ChangeHeir.holder == negotiator); })); diaOption.link = RoyalHeirChangeCandidates(faction, factionRepresentative, negotiator); if (num) { diaOption.Disable("RequestChangeRoyalHeirAlreadyInProgress".Translate(negotiator.Named("PAWN"))); } return(diaOption); }
public DiaOption GetAirSupportDiaOption(Building_OrbitalRelay orbitalRelay, DiaNode parentDiaNode) { DiaOption airSupportDiaOption = new DiaOption("Request air support"); if (Find.TickManager.TicksGame >= Util_Misc.Partnership.nextAirstrikeMinTick[this.Map]) { // Air support granted. DiaNode airSupportGrantedDiaNode = GetAirSupportGrantedDiaNode(parentDiaNode); airSupportDiaOption.link = airSupportGrantedDiaNode; } else { // Air support denied. DiaNode airSupporDeniedDiaNode = GetAirSupporDeniedDiaNode(parentDiaNode); airSupportDiaOption.link = airSupporDeniedDiaNode; } return(airSupportDiaOption); }
public void ShowHint() { if (HintShown) { return; } DiaNode node = new DiaNode(Translator.Translate("DefusingInfo")); DiaOption option = new DiaOption("OK"); node.options.Add(option); option.resolveTree = true; var dialog = new Dialog_NodeTree(node); Find.WindowStack.Add(dialog); HintShown = true; }
// Open the dialog box that will ask the player if the wedding should start static void CheckIfShouldStartWedding(Pawn p1, Pawn p2) { // The dialog window is modeled after RW.IncidentWorker_CaravanDemand // (caravan ambushed, demand XYZ, give and leave, refuse and fight, etc) DiaNode diaNode = new DiaNode("" + p1 + " and " + p2 + " want to get married - is today the day?"); DiaOption optionYes = new DiaOption("\"Ding dang dong\" go the wedding bells!"); optionYes.action = delegate() { p1.Map.lordsStarter.TryStartMarriageCeremony(p1, p2); }; optionYes.resolveTree = true; DiaOption optionNo = new DiaOption("Now is not the best time, come to think of it..."); optionNo.resolveTree = true; diaNode.options.Add(optionYes); diaNode.options.Add(optionNo); Find.WindowStack.Add(new Dialog_NodeTree(diaNode, false, false, null /*title*/)); }
public static void TenantWantToJoin(Pawn pawn) { Tenant tenantComp = pawn.GetTenantComponent(); if (tenantComp.MayJoin && Rand.Value < 0.02f && tenantComp.HappyMoodCount > 7) { string text = "RequestTenantWantToJoin".Translate(pawn.Named("PAWN")); DiaNode diaNode = new DiaNode(text); DiaOption diaOption = new DiaOption("ContractAgree".Translate()) { action = delegate { Utility.MakePayment(pawn); tenantComp.IsTenant = false; Messages.Message("ContractDone".Translate(pawn.Name.ToStringFull, tenantComp.Payment * tenantComp.ContractLength / 60000, pawn.Named("PAWN")), MessageTypeDefOf.PositiveEvent); Find.ColonistBar.MarkColonistsDirty(); }, resolveTree = true, }; diaNode.options.Add(diaOption); //Denied offer string text2 = "RequestTenantWantToJoinRejected".Translate(pawn.Named("PAWN")); DiaNode diaNode2 = new DiaNode(text2); DiaOption diaOption2 = new DiaOption("OK".Translate()) { resolveTree = true }; diaNode2.options.Add(diaOption2); DiaOption diaOption3 = new DiaOption("ContractReject".Translate()) { action = delegate { }, link = diaNode2 }; diaNode.options.Add(diaOption3); string title = "RequestTenantWantToJoinTitle".Translate(pawn.Map.Parent.Label); Find.WindowStack.Add(new Dialog_NodeTree(diaNode, delayInteractivity: true, radioMode: true, title)); Find.Archive.Add(new ArchivedDialog(diaNode.text, title)); } if (tenantComp.HiddenFaction != null && tenantComp.HiddenFaction.HostileTo(Find.FactionManager.OfPlayer)) { tenantComp.HiddenFaction = null; } }
public static DiaNode RoyalHeirChangeCandidates(Faction faction, Pawn factionRepresentative, Pawn negotiator) { DiaNode diaNode = new DiaNode("ChooseHeir".Translate(negotiator.Named("HOLDER"))); RoyalTitleDef title = negotiator.royalty.GetCurrentTitle(faction); Pawn heir2 = negotiator.royalty.GetHeir(faction); foreach (Pawn item in PawnsFinder.AllMaps_FreeColonistsAndPrisonersSpawned) { DiaOption diaOption = new DiaOption(item.Name.ToStringFull); if (item != negotiator && item != heir2) { if (item.royalty != null) { RoyalTitleDef currentTitle = item.royalty.GetCurrentTitle(faction); if (currentTitle != null && currentTitle.seniority >= title.seniority) { continue; } } if (!item.IsQuestLodger()) { Pawn heir = item; Action confirmedAct = delegate { QuestScriptDef changeRoyalHeir = QuestScriptDefOf.ChangeRoyalHeir; Slate slate = new Slate(); slate.Set("points", title.changeHeirQuestPoints); slate.Set("asker", factionRepresentative); slate.Set("titleHolder", negotiator); slate.Set("titleHeir", heir); slate.Set("titlePreviousHeir", negotiator.royalty.GetHeir(faction)); QuestUtility.SendLetterQuestAvailable(QuestUtility.GenerateQuestAndMakeAvailable(changeRoyalHeir, slate)); }; diaOption.link = RoyalHeirChangeConfirm(faction, negotiator, heir2, confirmedAct); diaNode.options.Add(diaOption); } } } DiaOption diaOption2 = new DiaOption("GoBack".Translate()); diaOption2.linkLateBind = ResetToRoot(faction, negotiator); diaNode.options.Add(diaOption2); return(diaNode); }
public void ExposeData() { if (Scribe.mode == LoadSaveMode.Saving) { Scribe_Values.Look(ref opt.text, "text"); Scribe_Values.Look(ref opt.resolveTree, "resolveTree"); ScribeUtil.LookValue(parent.saveNodes.FindIndex(n => n.node == opt.link), "linkIndex", true); Scribe_Values.Look(ref opt.disabled, "disabled"); Scribe_Values.Look(ref opt.disabledReason, "disabledReason"); Scribe_Defs.Look(ref opt.clickSound, "clickSound"); ScribeUtil.LookValue(parent.fieldValues.FindIndex(f => Equals(f.value, opt.action)), "actionIndex", true); ScribeUtil.LookValue(parent.fieldValues.FindIndex(f => Equals(f.value, opt.linkLateBind)), "linkLateBindIndex", true); } if (Scribe.mode == LoadSaveMode.LoadingVars) { Scribe_Values.Look(ref text, "text"); Scribe_Values.Look(ref resolveTree, "resolveTree"); Scribe_Values.Look(ref linkIndex, "linkIndex", -1); Scribe_Values.Look(ref disabled, "disabled"); Scribe_Values.Look(ref disabledReason, "disabledReason"); Scribe_Defs.Look(ref clickSound, "clickSound"); Scribe_Values.Look(ref actionIndex, "actionIndex"); Scribe_Values.Look(ref linkLateBindIndex, "linkLateBindIndex"); opt = new DiaOption() { text = text, resolveTree = resolveTree, disabled = disabled, disabledReason = disabledReason, clickSound = clickSound }; } if (Scribe.mode == LoadSaveMode.PostLoadInit) { opt.link = parent.saveNodes.ElementAtOrDefault(linkIndex)?.node; opt.action = (Action)parent.fieldValues.ElementAtOrDefault(actionIndex)?.value; opt.linkLateBind = (Func <DiaNode>)parent.fieldValues.ElementAtOrDefault(linkLateBindIndex)?.value; } }
protected override bool TryExecuteWorker(IncidentParms parms) { Caravan caravan = (Caravan)parms.target; if (!PawnGroupMakerUtility.TryGetRandomFactionForNormalPawnGroup(parms.points, out parms.faction, (Predicate <Faction>)null, false, false, false, true)) { return(false); } PawnGroupMakerParms defaultPawnGroupMakerParms = IncidentParmsUtility.GetDefaultPawnGroupMakerParms(parms, false); defaultPawnGroupMakerParms.generateFightersOnly = true; List <Pawn> attackers = PawnGroupMakerUtility.GeneratePawns(PawnGroupKindDefOf.Normal, defaultPawnGroupMakerParms, true).ToList(); List <Thing> demands = this.GenerateDemands(caravan); if (demands.Count == 0) { return(false); } CameraJumper.TryJumpAndSelect(caravan); DiaNode diaNode = new DiaNode(this.GenerateMessageText(parms.faction, attackers.Count, demands)); DiaOption diaOption = new DiaOption("CaravanDemand_Give".Translate()); diaOption.action = delegate { this.ActionGive(caravan, demands, attackers); }; diaOption.resolveTree = true; diaNode.options.Add(diaOption); DiaOption diaOption2 = new DiaOption("CaravanDemand_Fight".Translate()); diaOption2.action = delegate { this.ActionFight(caravan, attackers); }; diaOption2.resolveTree = true; diaNode.options.Add(diaOption2); WindowStack windowStack = Find.WindowStack; DiaNode nodeRoot = diaNode; bool delayInteractivity = true; string title = "CaravanDemandTitle".Translate(parms.faction.Name); windowStack.Add(new Dialog_NodeTree(nodeRoot, delayInteractivity, false, title)); return(true); }
public override void PostMapGenerate(Map map) { base.PostMapGenerate(map); MapGeneratorHandler.GenerateMap(MapDefOfLocal.BaseX1, map, out List <Pawn> pawns, true, true, true, false, true, true, true, Find.FactionManager.FirstFactionOfDef(MoreEvents.FactionDefOfLocal.Pirate)); var mutantsFaction = Find.FactionManager.FirstFactionOfDef(MoreEvents.FactionDefOfLocal.Mutants); if (mutantsFaction == null) { Log.Warning("Mutants is null."); } foreach (var p in pawns) { if (p.RaceProps.Animal) { p.GetLord()?.Notify_PawnLost(p, PawnLostCondition.Undefined, null); p.SetFaction(mutantsFaction); LordJob_AnimalDefendPointAggresive lordJob = new LordJob_AnimalDefendPointAggresive(p.Faction, p.Position); Lord lord = LordMaker.MakeNewLord(p.Faction, lordJob, map); lord.numPawnsLostViolently = int.MaxValue; lord.AddPawn(p); } } DiaNode node = new DiaNode("Quest_Laboratory_Info1".Translate()); DiaOption option = new DiaOption("OK"); node.options.Add(option); option.resolveTree = true; var dialog = new Dialog_NodeTree(node); Find.WindowStack.Add(dialog); UnlimitedTime = true; DoDestroyDestroyable(); }
public static void AddOption(DiaNode __instance, ref DiaNode __result, Pawn negotiator, Faction faction) { if (faction.PlayerRelationKind == FactionRelationKind.Ally || faction.PlayerRelationKind == FactionRelationKind.Neutral) { Map map = negotiator.Map; DiaOption 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). int insertAtIndex = DefDatabase <ResearchProjectDef> .AllDefsListForReading.Any((ResearchProjectDef rp) => rp.HasTag(ResearchProjectTagDefOf.ShipRelated) && rp.IsFinished) ? 3 : 2; __result.options.Insert(insertAtIndex, newOption); } }
private void DoCompletionDialog(ResearchProjectDef proj, Pawn researcher) { string text = "ResearchFinished".Translate(new object[] { this.currentProj.LabelCap }) + "\n\n" + this.currentProj.DescriptionDiscovered; DiaNode diaNode = new DiaNode(text); diaNode.options.Add(DiaOption.DefaultOK); DiaOption diaOption = new DiaOption("ResearchScreen".Translate()); diaOption.resolveTree = true; diaOption.action = delegate() { Find.MainTabsRoot.SetCurrentTab(MainButtonDefOf.Research, true); }; diaNode.options.Add(diaOption); Find.WindowStack.Add(new Dialog_NodeTree(diaNode, true, false, null)); }
public static DiaNode MechanoidAnswers() { int no = new IntRange(1, 2).RandomInRange; DiaNode diaNode1 = new DiaNode(("PES_Mechanoid_Outcome_" + no.ToString()).Translate()); DiaNode diaNode2 = new DiaNode(("PES_MechanoidAnswer_" + no.ToString()).Translate()); DiaOption option2 = new DiaOption("PES_trembling".Translate()); option2.resolveTree = true; option2.action = () => { DialogUtilities.tempCaravan.Communicable = false; }; diaNode2.options.Add(option2); DiaOption option1 = new DiaOption("PES_Mechanoid_Choice".Translate()); option1.link = diaNode2; diaNode1.options.Add(option1); return(diaNode1); }
public override void DoAction() { var diaNode = new DiaNode(nextDialog.text); foreach (var option in nextDialog.options) { var diaOption = new DiaOption(option.text); diaOption.action = delegate() { foreach (var action in option.actions) { action.window = window; action.DoAction(); } }; diaNode.options.Add(diaOption); } window.GotoNode(diaNode); }
public override IEnumerable <DiaOption> BargainChoices() { List <int> nums = new List <int> { Mathf.CeilToInt(needSilver * 0.75f), Mathf.CeilToInt(needSilver * 0.5f), Mathf.CeilToInt(needSilver * 0.25f) }; for (int i = 0; i < 3; ++i) { if (i > 0 && nums[i] == nums[i - 1]) { continue; } DiaOption option = new DiaOption(String.Format("{0}x {1}", nums[i].ToString(), ThingDefOf.Silver.label)); int cur = nums[i];//Fix: Lambda expression works wrong in for-loop before C# 5.0!!! option.link = DialogMaker_RaidNegotiation.BargainDetailNode(0.75f - i * 0.25f, () => { needSilver = cur; }); yield return(option); } yield break; }
public static IEnumerable <Gizmo> ShipStartupGizmos(Building building) { if (!HasHibernatingParts(building)) { yield break; } Command_Action command_Action = new Command_Action(); command_Action.action = delegate { string text = "HibernateWarning"; if (building.Map.info.parent.GetComponent <EscapeShipComp>() == null) { text += "Standalone"; } if (!Find.Storyteller.difficultyValues.allowBigThreats) { text += "Pacifist"; } DiaNode diaNode = new DiaNode(text.Translate()); DiaOption item = new DiaOption("Confirm".Translate()) { action = delegate { StartupHibernatingParts(building); }, resolveTree = true }; diaNode.options.Add(item); DiaOption item2 = new DiaOption("GoBack".Translate()) { resolveTree = true }; diaNode.options.Add(item2); Find.WindowStack.Add(new Dialog_NodeTree(diaNode, delayInteractivity: true)); }; command_Action.defaultLabel = "CommandShipStartup".Translate(); command_Action.defaultDesc = "CommandShipStartupDesc".Translate(); command_Action.hotKey = KeyBindingDefOf.Misc1; command_Action.icon = ContentFinder <Texture2D> .Get("UI/Commands/DesirePower"); yield return(command_Action); }
public void SendFirstMeetingDialog(Pawn imperial) { Settlement playerSettlement = imperial.Map.info.parent as Settlement; string text = "PJ_ImperialGreeting".Translate(new object[] { imperial.Name.ToStringFull, imperial.kindDef.label, playerSettlement.Label, empireLandRightsTax.ToString(), empireTaxRate.ToStringPercent() }); DiaNode diaNode = new DiaNode(text); DiaOption diaOption = new DiaOption("PJ_ImperialGreeting_Accept".Translate()); diaOption.action = delegate { taxedColony = true; }; diaOption.resolveTree = true; diaNode.options.Add(diaOption); string text2 = "PJ_ImperialGreeting_Rejected".Translate(new object[] { imperial.NameStringShort }); DiaNode diaNode2 = new DiaNode(text2); DiaOption diaOption2 = new DiaOption("OK".Translate()); diaOption2.resolveTree = true; diaNode2.options.Add(diaOption2); DiaOption diaOption3 = new DiaOption("PJ_ImperialGreeting_Reject".Translate()); diaOption3.action = delegate { ResolveDeclarationOfHostility(imperial); }; diaOption3.link = diaNode2; diaNode.options.Add(diaOption3); string title = "PJ_ImperialGreeting_Title".Translate(); Find.WindowStack.Add(new Dialog_NodeTree(diaNode, true, true, title)); }
private static DiaOption RequestMilitaryAidOption(Map map) { string text = "RequestMilitaryAid".Translate(-25f); if (!FactionDialogMaker.faction.def.allowedArrivalTemperatureRange.ExpandedBy(-4f).Includes(map.mapTemperature.SeasonalTemp)) { DiaOption diaOption = new DiaOption(text); diaOption.Disable("BadTemperature".Translate()); return(diaOption); } DiaOption diaOption2 = new DiaOption(text); if (map.attackTargetsCache.TargetsHostileToColony.Any(GenHostility.IsActiveThreatToPlayer) && !map.attackTargetsCache.TargetsHostileToColony.Any((IAttackTarget p) => ((Thing)p).Faction != null && ((Thing)p).Faction.HostileTo(FactionDialogMaker.faction))) { IEnumerable <Faction> source = (from pa in map.attackTargetsCache.TargetsHostileToColony.Where(GenHostility.IsActiveThreatToPlayer) select((Thing)pa).Faction into fa where fa != null && !fa.HostileTo(FactionDialogMaker.faction) select fa).Distinct(); DiaNode diaNode = new DiaNode("MilitaryAidConfirmMutualEnemy".Translate(FactionDialogMaker.faction.Name, GenText.ToCommaList(from fa in source select fa.Name, true))); DiaOption diaOption3 = new DiaOption("CallConfirm".Translate()); diaOption3.action = delegate { FactionDialogMaker.CallForAid(map); }; diaOption3.link = FactionDialogMaker.FightersSent(); DiaOption diaOption4 = new DiaOption("CallCancel".Translate()); diaOption4.linkLateBind = FactionDialogMaker.ResetToRoot(); diaNode.options.Add(diaOption3); diaNode.options.Add(diaOption4); diaOption2.link = diaNode; } else { diaOption2.action = delegate { FactionDialogMaker.CallForAid(map); }; diaOption2.link = FactionDialogMaker.FightersSent(); } return(diaOption2); }
public static void ShowDialodOKCancel(string title , string text , Action ActOK , Action ActCancel , GlobalTargetInfo?target = null) { DiaNode diaNode = new DiaNode(text); if (target != null) { var diaOptionT = new DiaOption("JumpToLocation".Translate()); //"Перейти к месту" diaOptionT.action = () => { CameraJumper.TryJumpAndSelect(target.Value); }; diaNode.options.Add(diaOptionT); } DiaOption diaOption = new DiaOption("OK".NeedTranslate()); //OK -> Принять передачу diaOption.action = ActOK; /*{ спавн пешки бегущей "на помощь" * GenSpawn.Spawn(refugee, spawnSpot, map, WipeMode.Vanish); * refugee.SetFaction(Faction.OfPlayer, null); * CameraJumper.TryJump(refugee); * QueuedIncident qi = new QueuedIncident(new FiringIncident(IncidentDefOf.RaidEnemy, null, raidParms), Find.TickManager.TicksGame + IncidentWorker_RefugeeChased.RaidDelay.RandomInRange, 0); * Find.Storyteller.incidentQueue.Add(qi); * * };*/ diaOption.resolveTree = true; diaNode.options.Add(diaOption); diaOption = new DiaOption("RejectLetter".Translate()); //RansomDemand_Reject это "Отказаться" //RejectLetter это Отклонить diaOption.action = ActCancel; diaOption.resolveTree = true; diaNode.options.Add(diaOption); Find.WindowStack.Add(new Dialog_NodeTreeWithFactionInfo(diaNode, null, true, true, title)); }
public static DiaNode PrologueNode() { TravelingIncidentCaravan caravan = DialogUtilities.tempCaravan; Pawn pawn = DialogUtilities.tempPawn; if (!(caravan.incident is InterceptedIncident_HumanCrowd incident)) { return(null); } if (caravan.broadcastMessageCoolDownTick > 0) { return(ContactCoolDownNode()); } string prologue; string key; if (incident.IntelLevel == IncidentIntelLevel.Unknown) { key = "PES_TryContactPrologue_Unknown"; } else if (incident.IntelLevel == IncidentIntelLevel.Danger) { key = "PES_TryContactPrologue_Hostile"; } else { key = "PES_TryContactPrologue_Neutral"; } prologue = key.Translate(caravan.CaravanTitle, pawn.Name.ToStringShort); DiaNode dianode = new DiaNode(prologue); DiaOption option; option = new DiaOption("PES_ConfirmChoice".Translate()); option.link = BroadCastMessageChoiceNode(); dianode.options.Add(option); dianode.options.Add(DialogUtilities.NormalCancelOption()); return(dianode); }
private static IEnumerable <DiaOption> DebugOptions(Faction faction) { DiaOption opt = new DiaOption("(Debug) Goodwill +10"); opt.action = delegate { CorruptionStoryTrackerUtilities.AffectGoodwillWithSpacerFaction(Faction.OfPlayer, faction, 10f); }; opt.linkLateBind = (() => FactionDialogMaker_IoM.FactionDialogFor(FactionDialogMaker_IoM.negotiator, FactionDialogMaker_IoM.faction)); yield return(opt); DiaOption opt2 = new DiaOption("(Debug) Goodwill -10"); opt2.action = delegate { CorruptionStoryTrackerUtilities.AffectGoodwillWithSpacerFaction(Faction.OfPlayer, faction, -10f); }; opt2.linkLateBind = (() => FactionDialogMaker_IoM.FactionDialogFor(FactionDialogMaker_IoM.negotiator, FactionDialogMaker_IoM.faction)); yield return(opt2); }
public DiaNode GetAirSupportGrantedDiaNode(DiaNode parentDiaNode) { DiaNode airSupportGrantedDiaNode = new DiaNode("\"Your air support request has been approved by my hierarchy.\n" + "What kind of strike should we launch?\""); foreach (AirStrikeDef strikeDef in DefDatabase <AirStrikeDef> .AllDefsListForReading) { // Air strike option. DiaOption airStrikeDiaOption = new DiaOption(strikeDef.LabelCap + " (" + strikeDef.costInSilver + " silvers)"); DiaNode airStrikeDetailsDiaNode = GetAirStrikeDetailsDiaNode(airSupportGrantedDiaNode, strikeDef); airStrikeDiaOption.link = airStrikeDetailsDiaNode; airSupportGrantedDiaNode.options.Add(airStrikeDiaOption); } // Back option. DiaOption airSupportBackDiaOption = new DiaOption("Back"); airSupportBackDiaOption.link = parentDiaNode; airSupportGrantedDiaNode.options.Add(airSupportBackDiaOption); return(airSupportGrantedDiaNode); }
private static IEnumerable <DiaOption> DebugOptions() { DiaOption opt = new DiaOption("(Debug) Goodwill +10"); opt.action = delegate { FactionDialogMaker.faction.AffectGoodwillWith(Faction.OfPlayer, 10f); }; opt.linkLateBind = (() => FactionDialogMaker.FactionDialogFor(FactionDialogMaker.negotiator, FactionDialogMaker.faction)); yield return(opt); DiaOption opt2 = new DiaOption("(Debug) Goodwill -10"); opt2.action = delegate { FactionDialogMaker.faction.AffectGoodwillWith(Faction.OfPlayer, -10f); }; opt2.linkLateBind = (() => FactionDialogMaker.FactionDialogFor(FactionDialogMaker.negotiator, FactionDialogMaker.faction)); yield return(opt2); }
private static bool PreSyncDialog(DiaOption __instance) { // Just in case check for MP if (!MP.IsInMultiplayer || !isDialogOpen || !(__instance.dialog is Dialog_NodeTree)) { isDialogOpen = false; return(true); } // Get the current node, find the index of the option on it, and call a (synced) method var currentNode = (DiaNode)dialogNodeTreeCurrent.GetValue(__instance.dialog); int index = currentNode.options.FindIndex(x => x == __instance); if (index >= 0) { SyncDialogOptionByIndex(__instance.dialog.optionalTitle ?? string.Empty, index); } return(false); }