Exemplo n.º 1
0
        public static IEnumerable <CarrierWingData> GetDesignBattleriderWingData(
            App App,
            DesignInfo des)
        {
            int num1 = 0;
            int num2 = 0;
            List <CarrierWingData> source = new List <CarrierWingData>();

            foreach (DesignSectionInfo designSection in des.DesignSections)
            {
                ShipSectionAsset shipSectionAsset = App.AssetDatabase.GetShipSectionAsset(designSection.FilePath);
                if (shipSectionAsset.Type == ShipSectionType.Mission)
                {
                    int battleRiderType = (int)shipSectionAsset.BattleRiderType;
                }
                num1 += RiderManager.GetNumRiderSlots(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 count = list.Count;
                        int riderSlotsPerSquad = BattleRiderSquad.GetMinRiderSlotsPerSquad(mountClass, des.Class);
                        int numRidersPerSquad  = BattleRiderSquad.GetNumRidersPerSquad(mountClass, des.Class, Math.Max(count, riderSlotsPerSquad));
                        int num3 = numRidersPerSquad > count ? 1 : count / numRidersPerSquad;
                        for (int index1 = 0; index1 < num3; ++index1)
                        {
                            int        num4    = Math.Min(count, numRidersPerSquad);
                            List <int> intList = new List <int>();
                            for (int index2 = 0; index2 < num4; ++index2)
                            {
                                intList.Add(num2);
                                ++num2;
                            }
                            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
                                });
                            }
                        }
                    }
                    else if (WeaponEnums.IsWeaponBattleRider(bank.TurretClass))
                    {
                        num2 += ((IEnumerable <LogicalMount>)shipSectionAsset.Mounts).Count <LogicalMount>((Func <LogicalMount, bool>)(x => x.Bank == bank));
                    }
                }
                foreach (DesignModuleInfo module in designSection.Modules)
                {
                    string        path          = App.GameDatabase.GetModuleAsset(module.ModuleID);
                    LogicalModule logicalModule = 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))
                        {
                            int        count   = ((IEnumerable <LogicalMount>)logicalModule.Mounts).Where <LogicalMount>((Func <LogicalMount, bool>)(x => x.Bank == bank)).ToList <LogicalMount>().Count;
                            List <int> intList = new List <int>();
                            for (int index = 0; index < count; ++index)
                            {
                                intList.Add(num2);
                                ++num2;
                            }
                            source.Add(new CarrierWingData()
                            {
                                SlotIndexes = intList,
                                Class       = bank.TurretClass,
                                DefaultType = logicalModule.AbilityType == ModuleEnums.ModuleAbilities.KingfisherRider ? BattleRiderTypes.scout : BattleRiderTypes.Unspecified
                            });
                        }
                        else if (WeaponEnums.IsWeaponBattleRider(bank.TurretClass))
                        {
                            num2 += ((IEnumerable <LogicalMount>)logicalModule.Mounts).Count <LogicalMount>((Func <LogicalMount, bool>)(x => x.Bank == bank));
                        }
                    }
                }
            }
            return((IEnumerable <CarrierWingData>)source);
        }
Exemplo n.º 2
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());
        }
Exemplo n.º 3
0
 public static bool IsRiderMount(LogicalMount mount)
 {
     return(RiderManager.IsRiderBank(mount.Bank));
 }