Esempio n. 1
0
        // For mods like RA (number of RearmActors must match the number of aircraft)
        bool HasAdequateAirUnitReloadBuildings(ActorInfo actorInfo)
        {
            var aircraftInfo = actorInfo.TraitInfoOrDefault <AircraftInfo>();

            if (aircraftInfo == null)
            {
                return(true);
            }

            // If actor isn't Rearmable, it doesn't need a RearmActor to reload
            var rearmableInfo = actorInfo.TraitInfoOrDefault <RearmableInfo>();

            if (rearmableInfo == null)
            {
                return(true);
            }

            var countOwnAir    = AIUtils.CountActorsWithTrait <IPositionable>(actorInfo.Name, player);
            var countBuildings = rearmableInfo.RearmActors.Sum(b => AIUtils.CountActorsWithTrait <Building>(b, player));

            if (countOwnAir >= countBuildings)
            {
                return(false);
            }

            return(true);
        }