protected override bool FactionCanBeGroupSource(Faction f, Map map, bool desperate = false)
        {
            IEnumerable <Faction> source = (from x in map.attackTargetsCache.TargetsHostileToColony
                                            where GenHostility.IsActiveThreatToPlayer(x)
                                            select x into p
                                            select((Thing)p).Faction).Distinct();

            if (base.FactionCanBeGroupSource(f, map, desperate) && !f.Hidden && f.PlayerRelationKind == FactionRelationKind.Ally)
            {
                if (source.Any())
                {
                    return(source.Any((Faction hf) => hf.HostileTo(f)));
                }
                return(true);
            }
            return(false);
        }
Example #2
0
        private bool AffectsStoryDanger(IAttackTarget t)
        {
            Pawn pawn = t.Thing as Pawn;

            if (pawn != null)
            {
                Lord lord = pawn.GetLord();
                if (lord != null && (lord.LordJob is LordJob_DefendPoint || lord.LordJob is LordJob_MechanoidDefendBase) && pawn.CurJobDef != JobDefOf.AttackMelee && pawn.CurJobDef != JobDefOf.AttackStatic)
                {
                    return(false);
                }
                CompCanBeDormant comp = pawn.GetComp <CompCanBeDormant>();
                if (comp != null && !comp.Awake)
                {
                    return(false);
                }
            }
            return(GenHostility.IsActiveThreatToPlayer(t));
        }
        private StoryDanger CalculateDangerRating()
        {
            float num = (from x in this.map.attackTargetsCache.TargetsHostileToColony
                         where GenHostility.IsActiveThreatToPlayer(x)
                         select x).Sum((IAttackTarget t) => (!(t is Pawn)) ? 0f : ((Pawn)t).kindDef.combatPower);
            StoryDanger result;

            if (num == 0f)
            {
                result = StoryDanger.None;
            }
            else
            {
                int num2 = (from p in this.map.mapPawns.FreeColonistsSpawned
                            where !p.Downed
                            select p).Count <Pawn>();
                if (num < 150f && num <= (float)num2 * 18f)
                {
                    result = StoryDanger.Low;
                }
                else if (num > 400f)
                {
                    result = StoryDanger.High;
                }
                else if (this.lastColonistHarmedTick > Find.TickManager.TicksGame - 900)
                {
                    result = StoryDanger.High;
                }
                else
                {
                    foreach (Lord lord in this.map.lordManager.lords)
                    {
                        if (lord.faction.HostileTo(Faction.OfPlayer) && lord.CurLordToil.ForceHighStoryDanger && lord.AnyActivePawn)
                        {
                            return(StoryDanger.High);
                        }
                    }
                    result = StoryDanger.Low;
                }
            }
            return(result);
        }
Example #4
0
 protected override bool CanFireNowSub(IncidentParms parms)
 {
     if (!base.CanFireNowSub(parms))
     {
         return(false);
     }
     return(((Map)parms.target).attackTargetsCache.TargetsHostileToColony.Where((IAttackTarget p) => GenHostility.IsActiveThreatToPlayer(p)).Sum((IAttackTarget p) => (p as Pawn)?.kindDef.combatPower ?? 0f) > 120f);
 }
 private static bool <CanNameAnythingNow> m__0(IAttackTarget x)
 {
     return(GenHostility.IsActiveThreatToPlayer(x));
 }
        private static bool CanNameAnythingNow()
        {
            bool result;

            if (Find.AnyPlayerHomeMap == null || Find.CurrentMap == null || !Find.CurrentMap.IsPlayerHome || Find.GameEnder.gameEnding)
            {
                result = false;
            }
            else
            {
                bool       flag  = false;
                bool       flag2 = false;
                List <Map> maps  = Find.Maps;
                for (int i = 0; i < maps.Count; i++)
                {
                    if (maps[i].IsPlayerHome)
                    {
                        if (maps[i].mapPawns.FreeColonistsSpawnedCount >= 2)
                        {
                            flag = true;
                        }
                        if (!maps[i].attackTargetsCache.TargetsHostileToColony.Any((IAttackTarget x) => GenHostility.IsActiveThreatToPlayer(x)))
                        {
                            flag2 = true;
                        }
                    }
                }
                result = (flag && flag2);
            }
            return(result);
        }
 private static bool <RequestMilitaryAidOption> m__4(IAttackTarget x)
 {
     return(GenHostility.IsActiveThreatToPlayer(x));
 }
        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);
        }
 private static bool <CalculateDangerRating> m__0(IAttackTarget x)
 {
     return(GenHostility.IsActiveThreatToPlayer(x));
 }
Example #10
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);
        }
 private static bool <CanFireNowSub> m__1(IAttackTarget p)
 {
     return(GenHostility.IsActiveThreatToPlayer(p));
 }