Example #1
0
        private static DiaOption ConfirmPurchase(Map map, ResearchProjectDef def)
        {
            DiaOption option = new DiaOption("Confirm".Translate())
            {
                linkLateBind = FactionDialogMaker_IoM.ResetToRoot()
            };

            option.action = delegate
            {
                TradeUtility.LaunchThingsOfType(ThingDefOf.Silver, (int)def.baseCost, map, null);
                FactionDialogMaker_IoM.GrantMecResearch(def);
            };
            return(option);
        }
Example #2
0
        private static DiaOption OfferGiftOption(Map map)
        {
            // TODO: Compare with vanilla method
            int cost = GetCost(Hospitality_MapComponent.Instance(map).GetBribeCount(faction));
            //Log.Message(faction.name + ": " + Hospitality_MapComponent.Instance.GetBribeCount(faction) + " = " + cost);
            int silver = TradeUtility.AllLaunchableThings(map).Where(t => t.def == ThingDefOf.Silver).Sum(t => t.stackCount);

            if (silver < cost)
            {
                var diaOption = new DiaOption("OfferGift".Translate() + " (" + "NeedSilverLaunchable".Translate(new object[]
                {
                    cost
                }) + ")");
                diaOption.Disable("NotEnoughSilver".Translate());
                return(diaOption);
            }
            float goodwillDelta = 12f * negotiator.GetStatValue(StatDefOf.GiftImpact);
            var   diaOption2    = new DiaOption("OfferGift".Translate() + " (" + "SilverForGoodwill".Translate(new object[]
            {
                cost,
                goodwillDelta.ToString("#####0")
            }) + ")");

            diaOption2.action = delegate
            {
                TradeUtility.LaunchThingsOfType(ThingDefOf.Silver, cost, map, null);
                faction.AffectGoodwillWith(Faction.OfPlayer, goodwillDelta);
                Hospitality_MapComponent.Instance(map).Bribe(faction);
            };
            string text = "SilverGiftSent".Translate(new object[]
            {
                faction.Name,
                Mathf.RoundToInt(goodwillDelta)
            });

            diaOption2.link = new DiaNode(text)
            {
                options =
                {
                    new DiaOption("OK".Translate())
                    {
                        linkLateBind = () => Source.FactionDialogFor(negotiator, faction)
                    }
                }
            };
            return(diaOption2);
        }
        private static DiaOption OfferGiftOption(Map map)
        {
            if (AmountSendableSilver(map) < 300)
            {
                var diaOption = new DiaOption("OfferGift".Translate());
                diaOption.Disable("NeedSilverLaunchable".Translate(new object[]
                {
                    300
                }));
                return(diaOption);
            }
            var goodwillDelta = 12f * negotiator.GetStatValue(StatDefOf.DiplomacyPower, true);
            var diaOption2    = new DiaOption("OfferGift".Translate() + " (" + "SilverForGoodwill".Translate(new object[]
            {
                300,
                goodwillDelta.ToString("#####0")
            }) + ")");

            diaOption2.action = delegate
            {
                TradeUtility.LaunchThingsOfType(ThingDefOf.Silver, 300, map, null);
                faction.TryAffectGoodwillWith(Faction.OfPlayer, (int)goodwillDelta);
                PlaySoundFor(faction);
            };
            var text = "SilverGiftSent".Translate(new object[]
            {
                faction.leader.LabelIndefinite(),
                Mathf.RoundToInt(goodwillDelta)
            }).CapitalizeFirst();

            diaOption2.link = new DiaNode(text)
            {
                options =
                {
                    OKToRoot()
                }
            };
            return(diaOption2);
        }
Example #4
0
        private static DiaOption OfferGiftOption(Map map)
        {
            if (FactionDialogMaker_IoM.AmountSendableSilver(map) < 300)
            {
                DiaOption diaOption = new DiaOption("OfferGift".Translate());
                diaOption.Disable("NeedSilverLaunchable".Translate(new object[]
                {
                    300
                }));
                return(diaOption);
            }
            float     goodwillDelta = 5f * FactionDialogMaker_IoM.negotiator.GetStatValue(StatDefOf.GiftImpact, true);
            DiaOption diaOption2    = new DiaOption("OfferGift".Translate() + " (" + "SilverForGoodwill".Translate(new object[]
            {
                300,
                goodwillDelta.ToString("#####0")
            }) + ")");

            diaOption2.action = delegate
            {
                TradeUtility.LaunchThingsOfType(ThingDefOf.Silver, 300, map, null);
                CorruptionStoryTrackerUtilities.AffectGoodwillWithSpacerFaction(Faction.OfPlayer, faction, goodwillDelta);
            };
            string text = "SilverGiftSent".Translate(new object[]
            {
                FactionDialogMaker_IoM.faction.leader.LabelIndefinite(),
                Mathf.RoundToInt(goodwillDelta)
            }).CapitalizeFirst();

            diaOption2.link = new DiaNode(text)
            {
                options =
                {
                    FactionDialogMaker_IoM.OKToRoot()
                }
            };
            return(diaOption2);
        }
            public static bool Replacement(ref DiaOption __result, Map map)
            {
                int cost = GetCost(Hospitality_MapComponent.Instance(map).GetBribeCount(faction));
                //Log.Message(faction.name + ": " + Hospitality_MapComponent.Instance.GetBribeCount(faction) + " = " + cost);
                int silver = TradeUtility.AllLaunchableThings(map).Where(t => t.def == ThingDefOf.Silver).Sum(t => t.stackCount);

                if (silver < cost)
                {
                    var diaOption = new DiaOption("OfferGift".Translate());
                    diaOption.Disable("NeedSilverLaunchable".Translate(cost));
                    __result = diaOption;
                    return(false);
                }
                float goodwillDelta = 12f * negotiator.GetStatValue(StatDefOf.GiftImpact);
                var   diaOption2    = new DiaOption("OfferGift".Translate() + " (" + "SilverForGoodwill".Translate(cost, goodwillDelta.ToString("#####0")) + ")");

                diaOption2.action = delegate {
                    TradeUtility.LaunchThingsOfType(ThingDefOf.Silver, cost, map, null);
                    faction.AffectGoodwillWith(Faction.OfPlayer, goodwillDelta);
                    Hospitality_MapComponent.Instance(map).Bribe(faction);
                };
                string text = "SilverGiftSent".Translate(faction.leader.LabelIndefinite(), Mathf.RoundToInt(goodwillDelta)).CapitalizeFirst();

                diaOption2.link = new DiaNode(text)
                {
                    options =
                    {
                        new DiaOption("OK".Translate())
                        {
                            linkLateBind = () => FactionDialogMaker.FactionDialogFor(negotiator, faction)
                        }
                    }
                };
                __result = diaOption2;
                return(false);
            }
        private static DiaOption RequestTraderOption(Map map, int silverCost)
        {
            var text = "RequestTrader".Translate(new object[]
            {
                silverCost.ToString()
            });

            if (AmountSendableSilver(map) < silverCost)
            {
                var diaOption = new DiaOption(text);
                diaOption.Disable("NeedSilverLaunchable".Translate(new object[]
                {
                    silverCost
                }));
                return(diaOption);
            }
            if (!faction.def.allowedArrivalTemperatureRange.ExpandedBy(-4f).Includes(map.mapTemperature.SeasonalTemp))
            {
                var diaOption2 = new DiaOption(text);
                diaOption2.Disable("BadTemperature".Translate());
                return(diaOption2);
            }
            var num = faction.lastTraderRequestTick + 240000 - Find.TickManager.TicksGame;

            if (num > 0)
            {
                var diaOption3 = new DiaOption(text);
                diaOption3.Disable("WaitTime".Translate(new object[]
                {
                    num.ToStringTicksToPeriod()
                }));
                return(diaOption3);
            }
            var diaOption4 = new DiaOption(text);
            var diaNode    = new DiaNode("TraderSent".Translate(new object[]
            {
                faction.leader.LabelIndefinite()
            }).CapitalizeFirst());

            diaNode.options.Add(OKToRoot());
            var diaNode2 = new DiaNode("ChooseTraderKind".Translate(new object[]
            {
                faction.leader.LabelIndefinite()
            }));

            foreach (var localTk2 in faction.def.caravanTraderKinds)
            {
                var localTk    = localTk2;
                var diaOption5 = new DiaOption(localTk.LabelCap);
                diaOption5.action = delegate
                {
                    var incidentParms = new IncidentParms();
                    incidentParms.target     = map;
                    incidentParms.faction    = faction;
                    incidentParms.traderKind = localTk;
                    incidentParms.forced     = true;
                    Find.Storyteller.incidentQueue.Add(IncidentDefOf.TraderCaravanArrival, Find.TickManager.TicksGame + 120000, incidentParms);
                    faction.lastTraderRequestTick = Find.TickManager.TicksGame;
                    TradeUtility.LaunchThingsOfType(ThingDefOf.Silver, silverCost, map, null);
                    PlaySoundFor(faction);
                };
                diaOption5.link = diaNode;
                diaNode2.options.Add(diaOption5);
            }
            var diaOption6 = new DiaOption("GoBack".Translate());

            diaOption6.linkLateBind = ResetToRoot();
            diaNode2.options.Add(diaOption6);
            diaOption4.link = diaNode2;
            return(diaOption4);
        }
        public static DiaOption RequestStrongQuickReactionReinforcements(Map map, Faction faction, Pawn negotiator)
        {
            int       silverToPay    = 900;
            int       goodWillNeeded = 25;
            string    text           = "RequestHeavyPaidMilitaryAidRH".Translate(silverToPay);
            DiaOption result;

            if (faction.PlayerRelationKind != FactionRelationKind.Ally && faction.PlayerGoodwill < goodWillNeeded)
            {
                DiaOption diaOption = new DiaOption(text);
                diaOption.Disable("NeedGoodwill".Translate(goodWillNeeded.ToString("F0")));
                result = diaOption;
            }
            else if (ReinforcementDialogMakerRC.AmountSendableSilver(map) < silverToPay)
            {
                DiaOption diaOption3 = new DiaOption(text);
                diaOption3.Disable("NeedSilverLaunchable".Translate(silverToPay.ToString()));
                result = diaOption3;
            }
            else if (!faction.def.allowedArrivalTemperatureRange.ExpandedBy(-4f).Includes(map.mapTemperature.SeasonalTemp))
            {
                DiaOption diaOption2 = new DiaOption(text);
                diaOption2.Disable("BadTemperature".Translate());
                result = diaOption2;
            }
            else
            {
                int num = faction.lastMilitaryAidRequestTick + 90000 - Find.TickManager.TicksGame;
                if (num > 0)
                {
                    DiaOption diaOption3 = new DiaOption(text);
                    diaOption3.Disable("WaitTime".Translate(num.ToStringTicksToPeriod()));
                    result = diaOption3;
                }
                else if (NeutralGroupIncidentUtility.AnyBlockingHostileLord(map, faction))
                {
                    DiaOption diaOption4 = new DiaOption(text);
                    diaOption4.Disable("HostileVisitorsPresent".Translate());
                    result = diaOption4;
                }
                else
                {
                    DiaOption             diaOption5 = new DiaOption(text);
                    IEnumerable <Faction> source     = (from x in map.attackTargetsCache.TargetsHostileToColony
                                                        where GenHostility.IsActiveThreatToPlayer(x)
                                                        select((Thing)x).Faction into x
                                                        where x != null && !x.HostileTo(faction)
                                                        select x).Distinct <Faction>();
                    if (source.Any <Faction>())
                    {
                        DiaNode diaNode = new DiaNode("MilitaryAidConfirmMutualEnemy".Translate(faction.Name, (from fa in source
                                                                                                               select fa.Name).ToCommaList(true)));
                        DiaOption diaOption6 = new DiaOption("CallConfirm".Translate())
                        {
                            action = delegate()
                            {
                                ReinforcementDialogMakerRC.CallForStrongAid(map, faction);
                            },
                            resolveTree = true
                        };
                        DiaOption diaOption7 = new DiaOption("CallCancel".Translate())
                        {
                            linkLateBind = ReinforcementDialogMakerRC.ResetToRoot(faction, negotiator)
                        };
                        diaNode.options.Add(diaOption6);
                        diaNode.options.Add(diaOption7);
                        diaOption5.link = diaNode;
                    }
                    else
                    {
                        diaOption5.action = delegate()
                        {
                            TradeUtility.LaunchThingsOfType(ThingDefOf.Silver, silverToPay, map, null);
                            ReinforcementDialogMakerRC.CallForStrongAid(map, faction);
                        };
                        diaOption5.resolveTree = true;
                    }
                    result = diaOption5;
                }
            }
            return(result);
        }
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            if (!TryFindAdjcentSettlemet(out Settlement bomber))
            {
                return(false);
            }
            float        silver = silverCurve.Evaluate(1 - (1 / Find.AnyPlayerHomeMap.wealthWatcher.WealthTotal));
            List <Thing> demand = new List <Thing>();

            GenerateDemands(demand, silver);

            silver = GenThing.GetMarketValue(demand);

            int    countdown = countDown.RandomInRange * Global.DayInTicks;
            string text      = TranslatorFormattedStringExtensions.Translate("BombardmentThreat", bomber.Faction.leader, bomber.Faction.def.leaderTitle, bomber.Name, silver.ToStringMoney(null), GenLabel.ThingsLabel(demand, string.Empty), countdown.ToStringTicksToPeriod());

            GenThing.TryAppendSingleRewardInfo(ref text, demand);

            DiaNode nodeRoot = new DiaNode(text);

            nodeRoot.options.Add(new DiaOption("BombardmentThreat_AcceptThings".Translate())
            {
                action = () =>
                {
                    foreach (Thing t in demand)
                    {
                        TradeUtility.LaunchThingsOfType(t.def, t.stackCount, Find.AnyPlayerHomeMap, null);
                    }
                },
                link = new DiaNode(TranslatorFormattedStringExtensions.Translate("BombardmentThreatAcceptThings", bomber.Faction.leader))
                {
                    options =
                    {
                        new DiaOption("OK".Translate())
                        {
                            resolveTree = true
                        }
                    }
                }
            });
            if (TradeUtility.ColonyHasEnoughSilver(TradeUtility.PlayerHomeMapWithMostLaunchableSilver(), (int)silver * 2))
            {
                nodeRoot.options.Add(new DiaOption("BombardmentThreat_AcceptSilver".Translate((silver * 2).ToStringMoney()))
                {
                    action = () =>
                    {
                        TradeUtility.LaunchSilver(Find.AnyPlayerHomeMap, (int)silver * 2);
                    },
                    link = new DiaNode(TranslatorFormattedStringExtensions.Translate("BombardmentThreatAcceptThings", bomber.Faction.leader))
                    {
                        options =
                        {
                            new DiaOption("OK".Translate())
                            {
                                resolveTree = true
                            }
                        }
                    }
                });
            }
            else
            {
                nodeRoot.options.Add(new DiaOption("BombardmentThreat_AcceptSilver".Translate(((float)silver * 2).ToStringMoney()))
                {
                    disabled       = true,
                    disabledReason = "BombardmentThreat_AcceptSilverDisabled".Translate()
                });
            }
            nodeRoot.options.Add(new DiaOption("BombardmentThreat_Refusal".Translate())
            {
                action = () =>
                {
                    Find.AnyPlayerHomeMap.GetComponent <FE_MapComponent_Bombardment>().StartComp(def.durationDays.RandomInRange * Global.DayInTicks, bomber, countdown);
                },
                link = new DiaNode("BombardmentThreatRefusal".Translate(bomber.Faction.leader))
                {
                    options =
                    {
                        new DiaOption("OK".Translate())
                        {
                            resolveTree = true
                        }
                    }
                }
            });
            string title = "LetterLabelBombardmentTitle".Translate();

            Find.WindowStack.Add(new Dialog_NodeTreeWithFactionInfo(nodeRoot, bomber.Faction, true, true, title));
            Find.Archive.Add(new ArchivedDialog(nodeRoot.text, title, bomber.Faction));
            return(true);
        }