Пример #1
0
        public List <int> GetSyncedShips()
        {
            List <int> intList = new List <int>();

            foreach (int syncedFleet in this._syncedFleets)
            {
                this.App.GameDatabase.GetFleetInfo(syncedFleet);
                foreach (ShipInfo shipInfo in this.App.GameDatabase.GetShipInfoByFleetID(syncedFleet, false))
                {
                    DesignInfo       designInfo = shipInfo.DesignInfo;
                    int              num1       = 0;
                    BattleRiderTypes type       = BattleRiderTypes.Unspecified;
                    foreach (DesignSectionInfo designSection in designInfo.DesignSections)
                    {
                        ShipSectionAsset shipSectionAsset = designSection.ShipSectionAsset;
                        if (shipSectionAsset.BattleRiderType != BattleRiderTypes.Unspecified)
                        {
                            type = shipSectionAsset.BattleRiderType;
                        }
                        num1 += RiderManager.GetNumRiderSlots(this.App, designSection);
                    }
                    int num2 = 0;
                    foreach (DesignSectionInfo designSection in designInfo.DesignSections)
                    {
                        ShipSectionAsset shipSectionAsset = designSection.ShipSectionAsset;
                        num2 += shipSectionAsset.ReserveSize;
                    }
                    if (num2 > 0 || num1 > 0 || type.IsBattleRiderType())
                    {
                        intList.Add(shipInfo.ID);
                    }
                }
            }
            return(intList);
        }
Пример #2
0
        public static bool CanBattleRiderConnect(
            WeaponEnums.TurretClasses mountType,
            BattleRiderTypes brct,
            ShipClass sc)
        {
            switch (mountType)
            {
            case WeaponEnums.TurretClasses.Biomissile:
                return(brct == BattleRiderTypes.biomissile);

            case WeaponEnums.TurretClasses.Drone:
                return(brct == BattleRiderTypes.drone);

            case WeaponEnums.TurretClasses.AssaultShuttle:
                return(brct == BattleRiderTypes.assaultshuttle);

            case WeaponEnums.TurretClasses.DestroyerRider:
                if (brct.IsBattleRiderType())
                {
                    return(sc == ShipClass.BattleRider);
                }
                return(false);

            case WeaponEnums.TurretClasses.CruiserRider:
                if (brct.IsControllableBattleRider())
                {
                    return(sc == ShipClass.Cruiser);
                }
                return(false);

            case WeaponEnums.TurretClasses.DreadnoughtRider:
                if (brct.IsControllableBattleRider())
                {
                    return(sc == ShipClass.Dreadnought);
                }
                return(false);

            case WeaponEnums.TurretClasses.BoardingPod:
                return(brct == BattleRiderTypes.boardingpod);

            case WeaponEnums.TurretClasses.EscapePod:
                return(brct == BattleRiderTypes.escapepod);

            default:
                return(false);
            }
        }
Пример #3
0
        private void SyncFleet(int fleetID)
        {
            this.App.GameDatabase.GetFleetInfo(fleetID);
            IEnumerable <ShipInfo> shipInfoByFleetId = this.App.GameDatabase.GetShipInfoByFleetID(fleetID, false);
            List <object>          objectList        = new List <object>();
            int num1 = 0;

            foreach (ShipInfo shipInfo in shipInfoByFleetId)
            {
                DesignInfo             designInfo = shipInfo.DesignInfo;
                int                    num2       = 0;
                int                    count1     = objectList.Count;
                BattleRiderTypes       type       = BattleRiderTypes.Unspecified;
                int                    num3       = 0;
                List <CarrierWingData> source     = new List <CarrierWingData>();
                foreach (DesignSectionInfo designSection in designInfo.DesignSections)
                {
                    ShipSectionAsset shipSectionAsset = this.App.AssetDatabase.GetShipSectionAsset(designSection.FilePath);
                    if (shipSectionAsset.Type == ShipSectionType.Mission)
                    {
                        type = shipSectionAsset.BattleRiderType;
                    }
                    num2 += RiderManager.GetNumRiderSlots(this.App, designSection);
                    foreach (LogicalBank bank1 in shipSectionAsset.Banks)
                    {
                        LogicalBank bank = bank1;
                        if (RiderManager.IsRiderBank(bank))
                        {
                            List <LogicalMount>       list       = ((IEnumerable <LogicalMount>)shipSectionAsset.Mounts).Where <LogicalMount>((Func <LogicalMount, bool>)(x => x.Bank == bank)).ToList <LogicalMount>();
                            WeaponEnums.TurretClasses mountClass = bank.TurretClass;
                            int count2             = list.Count;
                            int riderSlotsPerSquad = BattleRiderSquad.GetMinRiderSlotsPerSquad(mountClass, designInfo.Class);
                            int numRidersPerSquad  = BattleRiderSquad.GetNumRidersPerSquad(mountClass, designInfo.Class, Math.Max(count2, riderSlotsPerSquad));
                            int num4 = numRidersPerSquad > count2 ? 1 : count2 / numRidersPerSquad;
                            for (int index1 = 0; index1 < num4; ++index1)
                            {
                                int        num5    = Math.Min(count2, numRidersPerSquad);
                                List <int> intList = new List <int>();
                                for (int index2 = 0; index2 < num5; ++index2)
                                {
                                    intList.Add(num3);
                                    ++num3;
                                }
                                CarrierWingData carrierWingData = source.FirstOrDefault <CarrierWingData>((Func <CarrierWingData, bool>)(x =>
                                {
                                    if (x.Class == mountClass)
                                    {
                                        return(x.SlotIndexes.Count < numRidersPerSquad);
                                    }
                                    return(false);
                                }));
                                if (carrierWingData != null)
                                {
                                    carrierWingData.SlotIndexes.AddRange((IEnumerable <int>)intList);
                                }
                                else
                                {
                                    source.Add(new CarrierWingData()
                                    {
                                        SlotIndexes = intList,
                                        Class       = mountClass
                                    });
                                }
                            }
                            foreach (LogicalMount logicalMount in list)
                            {
                                objectList.Add((object)(int)bank.TurretClass);
                            }
                        }
                        else if (WeaponEnums.IsWeaponBattleRider(bank.TurretClass))
                        {
                            num3 += ((IEnumerable <LogicalMount>)shipSectionAsset.Mounts).Count <LogicalMount>((Func <LogicalMount, bool>)(x => x.Bank == bank));
                        }
                    }
                    foreach (DesignModuleInfo module in designSection.Modules)
                    {
                        string        path          = this.App.GameDatabase.GetModuleAsset(module.ModuleID);
                        LogicalModule logicalModule = this.App.AssetDatabase.Modules.FirstOrDefault <LogicalModule>((Func <LogicalModule, bool>)(x => x.ModulePath == path));
                        foreach (LogicalBank bank1 in logicalModule.Banks)
                        {
                            LogicalBank bank = bank1;
                            if (RiderManager.IsRiderBank(bank))
                            {
                                List <LogicalMount> list = ((IEnumerable <LogicalMount>)logicalModule.Mounts).Where <LogicalMount>((Func <LogicalMount, bool>)(x => x.Bank == bank)).ToList <LogicalMount>();
                                int        count2        = list.Count;
                                List <int> intList       = new List <int>();
                                for (int index = 0; index < count2; ++index)
                                {
                                    intList.Add(num3);
                                    ++num3;
                                }
                                source.Add(new CarrierWingData()
                                {
                                    SlotIndexes = intList,
                                    Class       = bank.TurretClass,
                                    DefaultType = logicalModule.AbilityType == ModuleEnums.ModuleAbilities.KingfisherRider ? BattleRiderTypes.scout : BattleRiderTypes.Unspecified
                                });
                                foreach (LogicalMount logicalMount in list)
                                {
                                    objectList.Add((object)(int)bank.TurretClass);
                                }
                            }
                            else if (WeaponEnums.IsWeaponBattleRider(bank.TurretClass))
                            {
                                num3 += ((IEnumerable <LogicalMount>)logicalModule.Mounts).Count <LogicalMount>((Func <LogicalMount, bool>)(x => x.Bank == bank));
                            }
                        }
                    }
                }
                objectList.Insert(count1, (object)num2);
                int    num6 = 0;
                string str1 = "";
                string str2 = "";
                foreach (DesignSectionInfo designSection in designInfo.DesignSections)
                {
                    ShipSectionAsset shipSectionAsset = designSection.ShipSectionAsset;
                    num6 += shipSectionAsset.ReserveSize;
                    if (shipSectionAsset.Type == ShipSectionType.Mission)
                    {
                        str1 = App.Localize(shipSectionAsset.Title);
                    }
                    if (shipSectionAsset.Type == ShipSectionType.Engine)
                    {
                        str2 = App.Localize(shipSectionAsset.Title);
                    }
                }
                if (num6 > 0 || num2 > 0 || type.IsBattleRiderType())
                {
                    objectList.Add((object)shipInfo.DesignID);
                    objectList.Add((object)shipInfo.ID);
                    objectList.Add((object)designInfo.Name);
                    objectList.Add((object)shipInfo.ShipName);
                    objectList.Add((object)num6);
                    objectList.Add((object)(int)designInfo.Class);
                    objectList.Add((object)(int)type);
                    objectList.Add((object)shipInfo.ParentID);
                    objectList.Add((object)shipInfo.RiderIndex);
                    objectList.Add((object)str1);
                    objectList.Add((object)str2);
                    if (num2 > 0)
                    {
                        objectList.Add((object)source.Count);
                        foreach (CarrierWingData carrierWingData in source)
                        {
                            objectList.Add((object)carrierWingData.SlotIndexes.Count);
                            foreach (int slotIndex in carrierWingData.SlotIndexes)
                            {
                                objectList.Add((object)slotIndex);
                            }
                            objectList.Add((object)(int)carrierWingData.Class);
                            objectList.Add((object)(int)carrierWingData.DefaultType);
                        }
                    }
                    else if (num6 > 0)
                    {
                        objectList.Add((object)0);
                    }
                    ++num1;
                }
                else
                {
                    objectList.RemoveRange(count1, objectList.Count - count1);
                }
            }
            objectList.Insert(0, (object)num1);
            this.PostSetProp("SyncShips", objectList.ToArray());
        }