private static DiaOption RequestMilitaryAidOption(Map map)
        {
            string text = "RequestMilitaryAid".Translate(new object[]
            {
                -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(new Func <IAttackTarget, bool>(GenHostility.IsActiveThreatToPlayer)))
            {
                if (!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(new Func <IAttackTarget, bool>(GenHostility.IsActiveThreatToPlayer))
                                                    select((Thing)pa).Faction into fa
                                                    where fa != null && !fa.HostileTo(FactionDialogMaker.faction)
                                                    select fa).Distinct <Faction>();
                    string   arg_1B2_0 = "MilitaryAidConfirmMutualEnemy";
                    object[] expr_178  = new object[2];
                    expr_178[0] = FactionDialogMaker.faction.Name;
                    expr_178[1] = GenText.ToCommaList(from fa in source
                                                      select fa.Name, true);
                    DiaNode   diaNode    = new DiaNode(arg_1B2_0.Translate(expr_178));
                    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;
                    return(diaOption2);
                }
            }
            diaOption2.action = delegate
            {
                FactionDialogMaker.CallForAid(map);
            };
            diaOption2.link = FactionDialogMaker.FightersSent();
            return(diaOption2);
        }
Example #2
0
        private static DiaOption RequestMilitaryAidOption(Map map, Faction faction, Pawn negotiator)
        {
            string text = "RequestMilitaryAid".Translate(new object[]
            {
                25
            });

            if (faction.PlayerRelationKind != FactionRelationKind.Ally)
            {
                DiaOption diaOption = new DiaOption(text);
                diaOption.Disable("MustBeAlly".Translate());
                return(diaOption);
            }
            if (!faction.def.allowedArrivalTemperatureRange.ExpandedBy(-4f).Includes(map.mapTemperature.SeasonalTemp))
            {
                DiaOption diaOption2 = new DiaOption(text);
                diaOption2.Disable("BadTemperature".Translate());
                return(diaOption2);
            }
            int num = faction.lastMilitaryAidRequestTick + 60000 - Find.TickManager.TicksGame;

            if (num > 0)
            {
                DiaOption diaOption3 = new DiaOption(text);
                diaOption3.Disable("WaitTime".Translate(new object[]
                {
                    num.ToStringTicksToPeriod()
                }));
                return(diaOption3);
            }
            if (NeutralGroupIncidentUtility.AnyBlockingHostileLord(map, faction))
            {
                DiaOption diaOption4 = new DiaOption(text);
                diaOption4.Disable("HostileVisitorsPresent".Translate());
                return(diaOption4);
            }
            DiaOption diaOption5 = new DiaOption(text);

            if (faction.def.techLevel < TechLevel.Industrial)
            {
                diaOption5.link = FactionDialogMaker.CantMakeItInTime(faction, negotiator);
            }
            else
            {
                IEnumerable <Faction> source = (from x in map.attackTargetsCache.TargetsHostileToColony.Where(new Func <IAttackTarget, bool>(GenHostility.IsActiveThreatToPlayer))
                                                select((Thing)x).Faction into x
                                                where x != null && !x.HostileTo(faction)
                                                select x).Distinct <Faction>();
                if (source.Any <Faction>())
                {
                    string   arg_224_0 = "MilitaryAidConfirmMutualEnemy";
                    object[] expr_1E9  = new object[2];
                    expr_1E9[0] = faction.Name;
                    expr_1E9[1] = (from fa in source
                                   select fa.Name).ToCommaList(true);
                    DiaNode   diaNode    = new DiaNode(arg_224_0.Translate(expr_1E9));
                    DiaOption diaOption6 = new DiaOption("CallConfirm".Translate());
                    diaOption6.action = delegate
                    {
                        FactionDialogMaker.CallForAid(map, faction);
                    };
                    diaOption6.link = FactionDialogMaker.FightersSent(faction, negotiator);
                    DiaOption diaOption7 = new DiaOption("CallCancel".Translate());
                    diaOption7.linkLateBind = FactionDialogMaker.ResetToRoot(faction, negotiator);
                    diaNode.options.Add(diaOption6);
                    diaNode.options.Add(diaOption7);
                    diaOption5.link = diaNode;
                }
                else
                {
                    diaOption5.action = delegate
                    {
                        FactionDialogMaker.CallForAid(map, faction);
                    };
                    diaOption5.link = FactionDialogMaker.FightersSent(faction, negotiator);
                }
            }
            return(diaOption5);
        }
        private static DiaOption RequestMilitaryAidOption(Map map, Faction faction, Pawn negotiator)
        {
            string text = "RequestMilitaryAid".Translate(new object[]
            {
                20
            });
            DiaOption result;

            if (faction.PlayerRelationKind != FactionRelationKind.Ally)
            {
                DiaOption diaOption = new DiaOption(text);
                diaOption.Disable("MustBeAlly".Translate());
                result = diaOption;
            }
            else if (!faction.def.allowedArrivalTemperatureRange.ExpandedBy(-4f).Includes(map.mapTemperature.SeasonalTemp))
            {
                DiaOption diaOption2 = new DiaOption(text);
                diaOption2.Disable("BadTemperature".Translate());
                result = diaOption2;
            }
            else
            {
                DiaOption diaOption3 = new DiaOption(text);
                if (faction.def.techLevel < TechLevel.Industrial)
                {
                    diaOption3.link = FactionDialogMaker.CantMakeItInTime(faction, negotiator);
                }
                else
                {
                    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>())
                    {
                        string   key   = "MilitaryAidConfirmMutualEnemy";
                        object[] array = new object[2];
                        array[0] = faction.Name;
                        array[1] = (from fa in source
                                    select fa.Name).ToCommaList(true);
                        DiaNode   diaNode    = new DiaNode(key.Translate(array));
                        DiaOption diaOption4 = new DiaOption("CallConfirm".Translate());
                        diaOption4.action = delegate()
                        {
                            FactionDialogMaker.CallForAid(map, faction);
                        };
                        diaOption4.link = FactionDialogMaker.FightersSent(faction, negotiator);
                        DiaOption diaOption5 = new DiaOption("CallCancel".Translate());
                        diaOption5.linkLateBind = FactionDialogMaker.ResetToRoot(faction, negotiator);
                        diaNode.options.Add(diaOption4);
                        diaNode.options.Add(diaOption5);
                        diaOption3.link = diaNode;
                    }
                    else
                    {
                        diaOption3.action = delegate()
                        {
                            FactionDialogMaker.CallForAid(map, faction);
                        };
                        diaOption3.link = FactionDialogMaker.FightersSent(faction, negotiator);
                    }
                }
                result = diaOption3;
            }
            return(result);
        }