Beispiel #1
0
    public bool IsVisibleFor(global::Empire empire)
    {
        IGameService service = Services.GetService <IGameService>();

        if (service != null)
        {
            IVisibilityService service2 = service.Game.Services.GetService <IVisibilityService>();
            if (service != null)
            {
                if (this.isVisibleInFogOfWar)
                {
                    return(service2.IsWorldPositionExploredFor(this.WorldPosition, empire) || service2.IsWorldPositionVisibleFor(this.WorldPosition, empire));
                }
                return(service2.IsWorldPositionVisibleFor(this.WorldPosition, empire));
            }
        }
        return(false);
    }
Beispiel #2
0
    public static bool HasSaveAttackableTargetsNearby(Garrison Attacker, int size, DepartmentOfForeignAffairs departmentOfForeignAffairs, out List <IGarrison> Targets, bool NavalOnly = false)
    {
        IIntelligenceAIHelper service  = AIScheduler.Services.GetService <IIntelligenceAIHelper>();
        IVisibilityService    service2 = Services.GetService <IGameService>().Game.Services.GetService <IVisibilityService>();

        Targets = new List <IGarrison>();
        if (size < 1 || Attacker == null || !(Attacker is IWorldPositionable))
        {
            return(false);
        }
        List <global::Empire> list = new List <global::Empire>(Array.FindAll <global::Empire>((Services.GetService <IGameService>().Game as global::Game).Empires, (global::Empire match) => match is MajorEmpire && departmentOfForeignAffairs.IsAtWarWith(match)));

        if (list.Count < 1)
        {
            return(false);
        }
        bool result = true;
        IWorldPositionningService service3 = Services.GetService <IGameService>().Game.Services.GetService <IWorldPositionningService>();

        foreach (global::Empire empire in list)
        {
            List <Garrison>         list2   = new List <Garrison>();
            DepartmentOfDefense     agency  = empire.GetAgency <DepartmentOfDefense>();
            DepartmentOfTheInterior agency2 = empire.GetAgency <DepartmentOfTheInterior>();
            if (!NavalOnly)
            {
                list2.AddRange(agency.Armies.ToList <Army>().FindAll((Army match) => !match.IsSeafaring && !match.IsSettler).Cast <Garrison>());
                list2.AddRange(agency2.Cities.Cast <Garrison>());
                list2.AddRange(agency2.Camps.Cast <Garrison>());
                list2.AddRange(agency2.ConvertedVillages.Cast <Garrison>());
            }
            if (NavalOnly)
            {
                list2.AddRange(agency.Armies.ToList <Army>().FindAll((Army match) => match.IsNaval && !match.IsSettler).Cast <Garrison>());
                list2.AddRange(agency2.OccupiedFortresses.Cast <Garrison>());
            }
            foreach (Garrison garrison in list2)
            {
                if (garrison.UnitsCount > 0 && garrison is IWorldPositionable && (float)service3.GetDistance((garrison as IWorldPositionable).WorldPosition, (Attacker as IWorldPositionable).WorldPosition) <= (float)size && departmentOfForeignAffairs.CanAttack(garrison) && (!garrison.SimulationObject.Tags.Contains(Army.TagCamouflaged) || service2.IsWorldPositionDetectedFor((garrison as IWorldPositionable).WorldPosition, Attacker.Empire)) && service2.IsWorldPositionVisibleFor((garrison as IWorldPositionable).WorldPosition, Attacker.Empire))
                {
                    float num  = 0f;
                    float num2 = 0f;
                    if (!NavalOnly)
                    {
                        service.EstimateMPInBattleground(Attacker, garrison, ref num, ref num2);
                    }
                    else
                    {
                        num  += Attacker.GetPropertyValue(SimulationProperties.MilitaryPower);
                        num2 += garrison.GetPropertyValue(SimulationProperties.MilitaryPower);
                        if (Attacker is Army && (Attacker as Army).IsSeafaring && garrison is Army && !(garrison as Army).IsSeafaring)
                        {
                            num2 *= 0.2f;
                        }
                    }
                    if (num > num2 * 1.5f)
                    {
                        Targets.Add(garrison);
                    }
                    else
                    {
                        result = false;
                    }
                }
            }
        }
        if (Targets.Count == 0)
        {
            result = false;
        }
        return(result);
    }