Пример #1
0
        public override IEnumerable <FloatMenuOption> GetRoyalAidOptions(Map map, Pawn pawn, Faction faction)
        {
            if (AidDisabled(map, pawn, faction, out var reason))
            {
                yield return(new FloatMenuOption(def.LabelCap + ": " + reason, null));

                yield break;
            }
            if (NeutralGroupIncidentUtility.AnyBlockingHostileLord(pawn.MapHeld, faction))
            {
                yield return(new FloatMenuOption(def.LabelCap + ": " + "HostileVisitorsPresent".Translate(), null));

                yield break;
            }
            Action action      = null;
            string description = def.LabelCap + ": ";

            if (FillAidOption(pawn, faction, ref description, out var free))
            {
                action = delegate
                {
                    BeginCallAid(pawn, map, faction, free);
                };
            }
            yield return(new FloatMenuOption(description, action, faction.def.FactionIcon, faction.Color));
        }
 protected override bool FactionCanBeGroupSource(Faction f, Map map, bool desperate = false)
 {
     if (base.FactionCanBeGroupSource(f, map, desperate) && !f.Hidden && !f.HostileTo(Faction.OfPlayer) && f.def.pawnGroupMakers != null && f.def.pawnGroupMakers.Any((PawnGroupMaker x) => x.kindDef == PawnGroupKindDef))
     {
         return(!NeutralGroupIncidentUtility.AnyBlockingHostileLord(map, f));
     }
     return(false);
 }
        protected override bool CanFireNowSub(IncidentParms parms)
        {
            if (!base.CanFireNowSub(parms))
            {
                return(false);
            }
            Map map = (Map)parms.target;

            return(parms.faction == null || !NeutralGroupIncidentUtility.AnyBlockingHostileLord(map, parms.faction));
        }
        public override IEnumerable <FloatMenuOption> GetRoyalAidOptions(Map map, Pawn pawn, Faction faction)
        {
            if (faction.HostileTo(Faction.OfPlayer))
            {
                yield return(new FloatMenuOption(def.LabelCap + ": " + "CommandCallRoyalAidFactionHostile".Translate(faction.Named("FACTION")), null));

                yield break;
            }
            if (!faction.def.allowedArrivalTemperatureRange.ExpandedBy(-4f).Includes(pawn.MapHeld.mapTemperature.SeasonalTemp))
            {
                yield return(new FloatMenuOption(def.LabelCap + ": " + "BadTemperature".Translate(), null));

                yield break;
            }
            if (NeutralGroupIncidentUtility.AnyBlockingHostileLord(pawn.MapHeld, faction))
            {
                yield return(new FloatMenuOption(def.LabelCap + ": " + "HostileVisitorsPresent".Translate(), null));

                yield break;
            }
            int    permitLastUsedTick = pawn.royalty.GetPermitLastUsedTick(def);
            int    num      = Math.Max(GenTicks.TicksGame - permitLastUsedTick, 0);
            Action action   = null;
            bool   num2     = permitLastUsedTick < 0 || num >= def.CooldownTicks;
            int    numTicks = (permitLastUsedTick > 0) ? Math.Max(def.CooldownTicks - num, 0) : 0;
            string t        = def.LabelCap + ": ";

            if (num2)
            {
                t     += "CommandCallRoyalAidFreeOption".Translate();
                action = delegate
                {
                    BeginCallAid(pawn, map, faction, free: true);
                };
            }
            else
            {
                if (pawn.royalty.GetFavor(faction) >= def.royalAid.favorCost)
                {
                    action = delegate
                    {
                        BeginCallAid(pawn, map, faction, free: false);
                    };
                }
                t += "CommandCallRoyalAidFavorOption".Translate(numTicks.TicksToDays().ToString("0.0"), def.royalAid.favorCost, faction.Named("FACTION"));
            }
            yield return(new FloatMenuOption(t, action, faction.def.FactionIcon, faction.Color));
        }
Пример #5
0
 protected override bool FactionCanBeGroupSource(Faction f, Map map, bool desperate = false)
 {
     return(base.FactionCanBeGroupSource(f, map, desperate) && !f.def.hidden && !f.HostileTo(Faction.OfPlayer) && !NeutralGroupIncidentUtility.AnyBlockingHostileLord(map, f));
 }
Пример #6
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);
        }
Пример #7
0
        private static DiaOption RequestMilitaryAidOption(Map map, Faction faction, Pawn negotiator)
        {
            string text = "RequestMilitaryAid".Translate(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(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 ((int)faction.def.techLevel < 4)
            {
                diaOption5.link = 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();
                if (source.Any())
                {
                    DiaNode   diaNode    = new DiaNode("MilitaryAidConfirmMutualEnemy".Translate(faction.Name, source.Select((Faction fa) => fa.Name).ToCommaList(useAnd: true)));
                    DiaOption diaOption6 = new DiaOption("CallConfirm".Translate());
                    diaOption6.action = delegate
                    {
                        CallForAid(map, faction);
                    };
                    diaOption6.link = FightersSent(faction, negotiator);
                    DiaOption diaOption7 = new DiaOption("CallCancel".Translate());
                    diaOption7.linkLateBind = ResetToRoot(faction, negotiator);
                    diaNode.options.Add(diaOption6);
                    diaNode.options.Add(diaOption7);
                    diaOption5.link = diaNode;
                }
                else
                {
                    diaOption5.action = delegate
                    {
                        CallForAid(map, faction);
                    };
                    diaOption5.link = FightersSent(faction, negotiator);
                }
            }
            return(diaOption5);
        }