Esempio n. 1
0
        public static int GetNumRidersPerSquad(
            WeaponEnums.TurretClasses mountType,
            ShipClass carrierClass,
            int totalMounts)
        {
            int val1;

            switch (carrierClass)
            {
            case ShipClass.Cruiser:
            case ShipClass.Dreadnought:
                val1 = 3;
                break;

            case ShipClass.Leviathan:
                val1 = mountType != WeaponEnums.TurretClasses.DestroyerRider ? 3 : 6;
                break;

            default:
                val1 = totalMounts;
                break;
            }
            if (WeaponEnums.IsWeaponBattleRider(mountType))
            {
                val1 = totalMounts;
            }
            return(Math.Min(val1, totalMounts));
        }
Esempio n. 2
0
        public static IEnumerable <int> GetBattleriderIndexes(App app, ShipInfo ship)
        {
            List <SectionInstanceInfo> list1    = app.GameDatabase.GetShipSectionInstances(ship.ID).ToList <SectionInstanceInfo>();
            List <DesignSectionInfo>   sections = ((IEnumerable <DesignSectionInfo>)app.GameDatabase.GetShipInfo(ship.ID, true).DesignInfo.DesignSections).ToList <DesignSectionInfo>();
            List <int> intList = new List <int>();
            int        num     = 0;

            for (int j = 0; j < sections.Count; ++j)
            {
                SectionInstanceInfo       sectionInstanceInfo = list1.First <SectionInstanceInfo>((Func <SectionInstanceInfo, bool>)(x => x.SectionID == sections[j].ID));
                List <ModuleInstanceInfo> list2 = app.GameDatabase.GetModuleInstances(sectionInstanceInfo.ID).ToList <ModuleInstanceInfo>();
                foreach (LogicalMount mount in app.AssetDatabase.GetShipSectionAsset(sections[j].FilePath).Mounts)
                {
                    if (WeaponEnums.IsWeaponBattleRider(mount.Bank.TurretClass))
                    {
                        ++num;
                    }
                    else if (WeaponEnums.IsBattleRider(mount.Bank.TurretClass))
                    {
                        intList.Add(num);
                        ++num;
                    }
                }
                if (list2.Count > 0)
                {
                    foreach (ModuleInstanceInfo moduleInstanceInfo in list2)
                    {
                        ModuleInstanceInfo mii = moduleInstanceInfo;
                        DesignModuleInfo   designModuleInfo = sections[j].Modules.First <DesignModuleInfo>((Func <DesignModuleInfo, bool>)(x => x.MountNodeName == mii.ModuleNodeID));
                        if (designModuleInfo.DesignID.HasValue)
                        {
                            string modAsset = app.GameDatabase.GetModuleAsset(designModuleInfo.ModuleID);
                            foreach (LogicalMount mount in app.AssetDatabase.Modules.Where <LogicalModule>((Func <LogicalModule, bool>)(x => x.ModulePath == modAsset)).First <LogicalModule>().Mounts)
                            {
                                if (WeaponEnums.IsWeaponBattleRider(mount.Bank.TurretClass))
                                {
                                    ++num;
                                }
                                else if (WeaponEnums.IsBattleRider(mount.Bank.TurretClass))
                                {
                                    intList.Add(num);
                                    ++num;
                                }
                            }
                        }
                    }
                }
            }
            return((IEnumerable <int>)intList);
        }
Esempio n. 3
0
        public int SpawnPirateFleet(GameSession game, int targetSystem, int numShips)
        {
            Random random  = new Random();
            int    fleetID = game.GameDatabase.InsertFleet(this.PlayerID, 0, targetSystem, 0, "Pirate Raiders", FleetType.FL_NORMAL);
            Dictionary <LogicalWeapon, int> dictionary1 = new Dictionary <LogicalWeapon, int>();
            List <PlayerInfo> list1          = game.GameDatabase.GetStandardPlayerInfos().ToList <PlayerInfo>();
            List <PlayerInfo> playerInfoList = new List <PlayerInfo>();

            foreach (PlayerInfo playerInfo in list1)
            {
                Faction faction = game.AssetDatabase.GetFaction(playerInfo.FactionID);
                if (faction.Name != "liir_zuul" && faction.Name != "hiver" && faction.Name != "loa")
                {
                    playerInfoList.Add(playerInfo);
                }
                foreach (LogicalWeapon key in game.GameDatabase.GetAvailableWeapons(game.AssetDatabase, playerInfo.ID).ToList <LogicalWeapon>())
                {
                    if (!dictionary1.ContainsKey(key))
                    {
                        dictionary1.Add(key, 1);
                    }
                    else
                    {
                        Dictionary <LogicalWeapon, int> dictionary2;
                        LogicalWeapon index;
                        (dictionary2 = dictionary1)[index = key] = dictionary2[index] + 1;
                    }
                }
            }
            if (playerInfoList.Count > 0)
            {
                List <LogicalWeapon> availableWeapons = new List <LogicalWeapon>();
                foreach (LogicalWeapon logicalWeapon in game.AssetDatabase.Weapons.ToList <LogicalWeapon>())
                {
                    if (((IEnumerable <LogicalTurretClass>)logicalWeapon.TurretClasses).Count <LogicalTurretClass>() > 0 && WeaponEnums.IsBattleRider(logicalWeapon.DefaultWeaponClass))
                    {
                        availableWeapons.Add(logicalWeapon);
                    }
                }
                foreach (KeyValuePair <LogicalWeapon, int> keyValuePair in dictionary1)
                {
                    if (keyValuePair.Value > 1 && !availableWeapons.Contains(keyValuePair.Key))
                    {
                        availableWeapons.Add(keyValuePair.Key);
                    }
                }
                for (int index1 = 0; index1 < numShips + 1; ++index1)
                {
                    PlayerInfo playerInfo = random.Choose <PlayerInfo>((IList <PlayerInfo>)playerInfoList);
                    Faction    faction    = game.AssetDatabase.GetFaction(playerInfo.FactionID);
                    DesignInfo design1    = DesignLab.DesignShip(game, ShipClass.BattleRider, ShipRole.BOARDINGPOD, WeaponRole.PLANET_ATTACK, playerInfo.ID);
                    DesignInfo design2    = DesignLab.DesignShip(game, ShipClass.BattleRider, ShipRole.DRONE, WeaponRole.UNDEFINED, playerInfo.ID);
                    design1.PlayerID = this.PlayerID;
                    design2.PlayerID = this.PlayerID;
                    game.GameDatabase.InsertDesignByDesignInfo(design1);
                    game.GameDatabase.InsertDesignByDesignInfo(design2);
                    DesignInfo designInfo1;
                    if (index1 == 0)
                    {
                        DesignInfo designInfo2 = DesignLab.DesignShip(game, ShipClass.Cruiser, ShipRole.COMMAND, WeaponRole.UNDEFINED, playerInfo.ID);
                        designInfo1 = new DesignInfo(playerInfo.ID, "", new string[3]
                        {
                            ((IEnumerable <DesignSectionInfo>)designInfo2.DesignSections).First <DesignSectionInfo>((Func <DesignSectionInfo, bool>)(x => x.ShipSectionAsset.Type == ShipSectionType.Command)).FilePath,
                            ((IEnumerable <DesignSectionInfo>)designInfo2.DesignSections).First <DesignSectionInfo>((Func <DesignSectionInfo, bool>)(x => x.ShipSectionAsset.Type == ShipSectionType.Mission)).FilePath,
                            ((IEnumerable <DesignSectionInfo>)designInfo2.DesignSections).First <DesignSectionInfo>((Func <DesignSectionInfo, bool>)(x => x.ShipSectionAsset.Type == ShipSectionType.Engine)).FilePath
                        });
                    }
                    else
                    {
                        List <ShipSectionAsset> availableSections = game.GetAvailableShipSections(playerInfo.ID).ToList <ShipSectionAsset>();
                        List <string>           list2             = ((IEnumerable <string>)Pirates.availableCommandSections).ToList <string>();
                        List <string>           list3             = ((IEnumerable <string>)Pirates.availableMissionSections).ToList <string>();
                        List <string>           list4             = ((IEnumerable <string>)Pirates.availableEngineSections).ToList <string>();
                        for (int index2 = 0; index2 < list2.Count <string>(); ++index2)
                        {
                            list2[index2] = string.Format("factions\\{0}\\sections\\{1}", (object)faction.Name, (object)list2[index2]);
                        }
                        for (int index2 = 0; index2 < list3.Count <string>(); ++index2)
                        {
                            list3[index2] = string.Format("factions\\{0}\\sections\\{1}", (object)faction.Name, (object)list3[index2]);
                        }
                        for (int index2 = 0; index2 < list4.Count <string>(); ++index2)
                        {
                            list4[index2] = string.Format("factions\\{0}\\sections\\{1}", (object)faction.Name, (object)list4[index2]);
                        }
                        list2.RemoveAll((Predicate <string>)(x => !availableSections.Any <ShipSectionAsset>((Func <ShipSectionAsset, bool>)(y => y.FileName == x))));
                        list3.RemoveAll((Predicate <string>)(x => !availableSections.Any <ShipSectionAsset>((Func <ShipSectionAsset, bool>)(y => y.FileName == x))));
                        list4.RemoveAll((Predicate <string>)(x => !availableSections.Any <ShipSectionAsset>((Func <ShipSectionAsset, bool>)(y => y.FileName == x))));
                        designInfo1 = new DesignInfo(playerInfo.ID, "", new string[3]
                        {
                            random.Choose <string>((IList <string>)list2),
                            random.Choose <string>((IList <string>)list3),
                            random.Choose <string>((IList <string>)list4)
                        });
                    }
                    designInfo1.Name = DesignLab.GenerateDesignName(game.AssetDatabase, game.GameDatabase, (DesignInfo)null, designInfo1, DesignLab.NameGenerators.FactionRandom);
                    DesignLab.SummarizeDesign(game.AssetDatabase, game.GameDatabase, designInfo1);
                    DesignInfo design3 = DesignLab.AssignWeaponsToDesign(game, designInfo1, availableWeapons, this.PlayerId, WeaponRole.BRAWLER, (AITechStyles)null);
                    design3.PlayerID = this.PlayerID;
                    int designID  = game.GameDatabase.InsertDesignByDesignInfo(design3);
                    int carrierID = game.GameDatabase.InsertShip(fleetID, designID, null, (ShipParams)0, new int?(), 0);
                    game.AddDefaultStartingRiders(fleetID, designID, carrierID);
                }
            }
            return(fleetID);
        }
Esempio n. 4
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());
        }
Esempio n. 5
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);
        }
Esempio n. 6
0
        public void LoadFromXml(
            AssetDatabase assetdb,
            string filename,
            string faction,
            ShipSectionType sectionType,
            ShipClass sectionClass)
        {
            ShipSection ss = new ShipSection();

            ShipXmlUtility.LoadShipSectionFromXml(filename, ref ss);
            this.Type        = sectionType;
            this.Class       = sectionClass;
            this.Faction     = faction;
            this.SectionName = Path.GetFileNameWithoutExtension(filename);
            string str1 = "";

            switch (this.Class)
            {
            case ShipClass.Cruiser:
                str1 = "CR";
                break;

            case ShipClass.Dreadnought:
                str1 = "DN";
                break;

            case ShipClass.Leviathan:
                str1 = "LV";
                break;

            case ShipClass.BattleRider:
                str1 = "BR";
                break;

            case ShipClass.Station:
                str1 = "SN";
                break;
            }
            this.ModelName = FileSystemHelpers.StripMountName(ss.ModelPath);
            string str2 = Path.Combine(Path.GetDirectoryName(this.ModelName), "Damage_" + str1 + "_" + this.Type.ToString() + "_Default.scene");

            this.DestroyedModelName = string.IsNullOrEmpty(ss.DestroyedModelPath) ? str2 : ss.DestroyedModelPath;
            this.DamagedModelName   = ss.DamageModelPath;
            this.AmbientSound       = ss.AmbientSound;
            this.EngineSound        = ss.EngineSound;
            string str3 = string.Format("COMBAT_023-01_{0}_GeneralShipsBeingAttacked", (object)faction);
            string str4 = "";

            switch (this.Class)
            {
            case ShipClass.Cruiser:
                str4 = string.Format("COMBAT_029-01_{0}_CruiserDestroyed", (object)faction);
                break;

            case ShipClass.Dreadnought:
                str4 = string.Format("COMBAT_030-01_{0}_DreadnoughtDestroyed", (object)faction);
                break;

            case ShipClass.Leviathan:
                str4 = string.Format("COMBAT_031-01_{0}_LeviathanDestroyed", (object)faction);
                break;

            case ShipClass.BattleRider:
                str4 = string.Format("COMBAT_020-01_{0}_BattleRiderDestroyed", (object)faction);
                break;

            case ShipClass.Station:
                switch (this.StationType)
                {
                case StationType.NAVAL:
                    str3 = string.Format("COMBAT_067-01_{0}_NavalStationUnderAttack", (object)faction);
                    str4 = string.Format("COMBAT_066-01_{0}_NavalStationDestroyed", (object)faction);
                    break;

                case StationType.SCIENCE:
                    str3 = string.Format("COMBAT_069-01_{0}_ScienceStationUnderAttack", (object)faction);
                    str4 = string.Format("COMBAT_068-01_{0}_ScienceStationDestroyed", (object)faction);
                    break;

                case StationType.CIVILIAN:
                    str3 = string.Format("COMBAT_071-01_{0}_CivilianStationUnderAttack", (object)faction);
                    str4 = string.Format("COMBAT_072-01_{0}_CivilianStationDestroyed", (object)faction);
                    break;

                case StationType.DIPLOMATIC:
                    str3 = string.Format("COMBAT_070a-01_{0}_DiplomaticStationUnderAttack", (object)faction);
                    str4 = string.Format("COMBAT_070-01_{0}_DiplomaticStationDestroyed", (object)faction);
                    break;
                }
                break;
            }
            this.UnderAttackSound = string.IsNullOrEmpty(ss.UnderAttackSound) ? str3 : ss.UnderAttackSound;
            this.DestroyedSound   = string.IsNullOrEmpty(ss.DestroyedSound) ? str4 : ss.DestroyedSound;
            this.Title            = ss.Title;
            this.Description      = ss.Description;
            if (string.IsNullOrWhiteSpace(this.Title))
            {
                this.Title = Path.GetFileNameWithoutExtension(filename);
            }
            string withoutExtension = Path.GetFileNameWithoutExtension(filename);

            this.CombatAIType = !string.IsNullOrEmpty(ss.CombatAiType) ? (SectionEnumerations.CombatAiType)Enum.Parse(typeof(SectionEnumerations.CombatAiType), ss.CombatAiType) : SectionEnumerations.CombatAiType.Normal;
            switch (this.CombatAIType)
            {
            case SectionEnumerations.CombatAiType.Drone:
                this.SetBattleRiderType(BattleRiderTypes.drone);
                break;

            case SectionEnumerations.CombatAiType.AssaultShuttle:
                this.SetBattleRiderType(BattleRiderTypes.assaultshuttle);
                break;

            case SectionEnumerations.CombatAiType.NodeFighter:
                this.SetBattleRiderType(BattleRiderTypes.nodefighter);
                break;

            case SectionEnumerations.CombatAiType.Swarmer:
            case SectionEnumerations.CombatAiType.SwarmerGuardian:
            case SectionEnumerations.CombatAiType.VonNeumannPyramid:
            case SectionEnumerations.CombatAiType.LocustFighter:
            case SectionEnumerations.CombatAiType.MorrigiCrow:
                this.SetBattleRiderType(BattleRiderTypes.battlerider);
                break;

            case SectionEnumerations.CombatAiType.VonNeumannSeekerProbe:
                this.SetBattleRiderType(BattleRiderTypes.assaultshuttle);
                break;

            default:
                this.SetBattleRiderType(ObtainShipClassTypes.GetBattleRiderTypeByName(this.Class, withoutExtension));
                break;
            }
            if (withoutExtension.Contains("protectorate"))
            {
                this.ShipFleetAbilityType = ShipFleetAbilityType.Protectorate;
            }
            else if (withoutExtension.Contains("suulka_the_hidden"))
            {
                this.ShipFleetAbilityType = ShipFleetAbilityType.Hidden;
            }
            else if (withoutExtension.Contains("suulka_the_deaf"))
            {
                this.ShipFleetAbilityType = ShipFleetAbilityType.Deaf;
            }
            this.IsSuperTransport  = this.SectionName.StartsWith("lv_supertransport", StringComparison.InvariantCultureIgnoreCase);
            this.IsBoreShip        = this.SectionName.EndsWith("bore", StringComparison.InvariantCultureIgnoreCase);
            this.IsSupplyShip      = this.SectionName.Contains("_supply");
            this.IsGateShip        = this.SectionName.StartsWith("cr_mis_gate", StringComparison.InvariantCultureIgnoreCase);
            this.IsTrapShip        = this.SectionName.StartsWith("cr_mis_colonytrickster", StringComparison.InvariantCultureIgnoreCase);
            this.IsGravBoat        = this.SectionName.StartsWith("cr_mis_gravboat", StringComparison.InvariantCultureIgnoreCase);
            this.IsAbsorberSection = this.SectionName.Contains("_absorber") || this.SectionName.Contains("_absorbtion");
            this.IsListener        = this.SectionName.Contains("_listener");
            this.IsFireControl     = this.Title.Contains("CR_CMD_FIRECONTROL") || this.Title.Contains("CR_CMD_FIRE_CONTROL");
            this.IsAIControl       = this.Title.Contains("CR_CMD_AI") || this.Title.Contains("DN_CMD_AI");
            this.SuulkaType        = this.GetSuulkaType(this.SectionName);
            this.IsFreighter       = ss.isFreighter;
            this.FreighterSpace    = ss.FreighterSpace;
            this.isPolice          = ss.isPolice;
            this.SlaveCapacity     = ss.SlaveCapacity;
            this.isPropaganda      = this.SectionName.StartsWith("cr_mis_propaganda", StringComparison.InvariantCultureIgnoreCase);
            this.IsAccelerator     = this.SectionName.StartsWith("cr_mis_ngp", StringComparison.InvariantCultureIgnoreCase);
            this.IsLoaCube         = this.SectionName.StartsWith("cr_mis_cube", StringComparison.InvariantCultureIgnoreCase);
            this.IsScavenger       = this.FileName.Contains("mis_scavenger") || this.FileName.Contains("dn_mis_subjugator");
            this.IsWraithAbductor  = this.FileName.Contains("wraith_abductor");
            this.Armor[1]          = new Kerberos.Sots.Framework.Size()
            {
                X = ss.TopArmor.X,
                Y = ss.TopArmor.Y
            };
            this.Armor[3] = new Kerberos.Sots.Framework.Size()
            {
                X = ss.BottomArmor.X,
                Y = ss.BottomArmor.Y
            };
            this.Armor[2] = this.Armor[0] = new Kerberos.Sots.Framework.Size()
            {
                X = ss.SideArmor.X,
                Y = ss.SideArmor.Y
            };
            this.Structure          = ss.Struct;
            this.LowStruct          = ss.StructDamageAmount;
            this.Mass               = (float)ss.Mass;
            this.SavingsCost        = ss.SavingsCost;
            this.ProductionCost     = ss.ProductionCost;
            this.ColonizationSpace  = ss.ColonizerSpace;
            this.TerraformingSpace  = ss.TerraformingPoints;
            this.ConstructionPoints = ss.ConstructionPoints;
            this.ReserveSize        = ss.BattleRiderReserveSize;
            this.RepairPoints       = ss.RepairPoints;
            this.FtlSpeed           = ss.FtlSpeed;
            this.NodeSpeed          = ss.NodeSpeed;
            this.MissionTime        = ss.MissionTime;
            this.LaunchDelay        = ss.LaunchDelay;
            this.DockingDelay       = ss.DockingDelay;
            this.Crew               = ss.Crew;
            this.CrewRequired       = ss.CrewRequired;
            this.Power              = ss.Power;
            this.Supply             = ss.Supply;
            this.ECM                 = ss.ECM;
            this.ECCM                = ss.ECCM;
            this.CommandPoints       = ss.CommandPoints;
            this.Signature           = ss.Signature;
            this.TacticalSensorRange = ss.TacticalSensorRange;
            this.ShipExplosiveDamage = ss.DeathDamage;
            this.ShipExplosiveRange  = ss.ExplosionRadius;
            this.PsionicPowerLevel   = ss.PsionicPowerLevel;
            if ((double)this.TacticalSensorRange <= 0.0)
            {
                this.TacticalSensorRange = 20000f;
            }
            this.DamageEffect = new LogicalEffect()
            {
                Name = !string.IsNullOrEmpty(ss.DamageEffectPath) ? ss.DamageEffectPath : ShipSectionAsset.GetShipDefaultDeathEffect(this.Class, this.BattleRiderType)
            };
            this.DeathEffect = new LogicalEffect()
            {
                Name = !string.IsNullOrEmpty(ss.DestroyedEffectPath) ? ss.DestroyedEffectPath : ShipSectionAsset.GetShipDefaultDeathEffect(this.Class, this.BattleRiderType)
            };
            this.ReactorFailureDeathEffect = new LogicalEffect()
            {
                Name = ShipSectionAsset.GetReactorShieldFailureDeathEffect(this.Class, this.Type)
            };
            this.ReactorCriticalDeathEffect = new LogicalEffect()
            {
                Name = ShipSectionAsset.GetReactorCriticalDeathEffect(this.Class, this.Type, withoutExtension)
            };
            this.AbsorbedDeathEffect = new LogicalEffect()
            {
                Name = ShipSectionAsset.GetAbsorbedDeathEffect(this.Class, this.Type)
            };
            this.StrategicSensorRange = ss.StrategicSensorRange;
            this.FleetSpeedModifier   = ss.FleetSpeedModifier;
            if ((double)this.StrategicSensorRange <= 0.0)
            {
                this.StrategicSensorRange = assetdb.DefaultStratSensorRange;
            }
            this.StationType                = ss.StationType != null ? SectionEnumerations.StationTypesWithInvalid[ss.StationType] : StationType.INVALID_TYPE;
            this.StationLevel               = ss.StationLevel;
            this.isConstructor              = ss.isConstructor;
            this.Maneuvering.LinearAccel    = ss.Acceleration;
            this.Maneuvering.RotAccel.X     = ss.RotationalAccelerationYaw;
            this.Maneuvering.RotAccel.Y     = ss.RotationalAccelerationPitch;
            this.Maneuvering.RotAccel.Z     = ss.RotationalAccelerationRoll;
            this.Maneuvering.Deacceleration = ss.Decceleration;
            this.Maneuvering.LinearSpeed    = ss.LinearSpeed;
            this.Maneuvering.RotationSpeed  = ss.RotationSpeed;
            HashSet <string> source1 = new HashSet <string>();

            foreach (Kerberos.Sots.Data.ShipFramework.Tech tech in ss.Techs)
            {
                source1.Add(tech.Name);
                this.isDeepScan = this.isDeepScan || tech.Name == "CCC_Advanced_Sensors";
                this.hasJammer  = this.hasJammer || tech.Name == "CCC_Sensor_Jammer";
                if (this.cloakingType == CloakingType.None)
                {
                    switch (tech.Name)
                    {
                    case "SLD_Cloaking":
                        this.cloakingType = CloakingType.Cloaking;
                        continue;

                    case "SLD_Improved_Cloaking":
                        this.cloakingType = CloakingType.ImprovedCloaking;
                        continue;

                    default:
                        continue;
                    }
                }
            }
            List <HashSet <string> > stringSetList = new List <HashSet <string> >();

            foreach (ShipOptionGroup shipOptionGroup in ss.ShipOptionGroups)
            {
                HashSet <string> stringSet = new HashSet <string>();
                foreach (ShipOption shipOption in shipOptionGroup.ShipOptions)
                {
                    stringSet.Add(shipOption.Name);
                }
                stringSetList.Add(stringSet);
            }
            switch (sectionClass)
            {
            case ShipClass.Cruiser:
                source1.Add("ENG_Cruiser_Construction");
                break;

            case ShipClass.Dreadnought:
                source1.Add("ENG_Dreadnought_Construction");
                break;

            case ShipClass.Leviathan:
                source1.Add("ENG_Leviathian_Construction");
                break;
            }
            List <LogicalModuleMount> logicalModuleMountList = new List <LogicalModuleMount>();

            foreach (ModuleMount module in ss.Modules)
            {
                LogicalModuleMount logicalModuleMount = new LogicalModuleMount()
                {
                    Section = this
                };
                logicalModuleMount.AssignedModuleName = module.AssignedModuleName;
                logicalModuleMount.ModuleType         = module.Type;
                logicalModuleMount.NodeName           = module.NodeName;
                logicalModuleMount.FrameX             = module.FrameX;
                logicalModuleMount.FrameY             = module.FrameY;
                logicalModuleMountList.Add(logicalModuleMount);
            }
            List <LogicalBank>  banks            = new List <LogicalBank>();
            List <LogicalMount> logicalMountList = new List <LogicalMount>();

            foreach (Bank bank in ss.Banks)
            {
                LogicalBank logicalBank = new LogicalBank()
                {
                    TurretSize        = (WeaponEnums.WeaponSizes)Enum.Parse(typeof(WeaponEnums.WeaponSizes), bank.Size),
                    Section           = this,
                    Module            = (LogicalModule)null,
                    GUID              = Guid.Parse(bank.Id),
                    DefaultWeaponName = bank.DefaultWeapon
                };
                logicalBank.TurretClass = (WeaponEnums.TurretClasses)Enum.Parse(typeof(WeaponEnums.TurretClasses), bank.Class);
                logicalBank.FrameX      = bank.FrameX;
                logicalBank.FrameY      = bank.FrameY;
                this.IsCarrier          = this.IsCarrier || WeaponEnums.IsBattleRider(logicalBank.TurretClass);
                this.isMineLayer        = this.isMineLayer || logicalBank.TurretClass == WeaponEnums.TurretClasses.Minelayer;
                banks.Add(logicalBank);
                foreach (Mount mount in bank.Mounts)
                {
                    LogicalMount logicalMount = new LogicalMount()
                    {
                        Bank           = logicalBank,
                        NodeName       = mount.NodeName,
                        TurretOverload = mount.TurretOverload,
                        BarrelOverload = mount.BarrelOverload,
                        BaseOverload   = mount.BaseOverload,
                        FireAnimName   = mount.SectionFireAnimation != null ? mount.SectionFireAnimation : "",
                        ReloadAnimName = mount.SectionReloadAnimation != null ? mount.SectionReloadAnimation : "",
                        Yaw            =
                        {
                            Min = mount.YawMin,
                            Max = mount.YawMax
                        },
                        Pitch =
                        {
                            Min = mount.PitchMin,
                            Max = mount.PitchMax
                        }
                    };
                    logicalMount.Pitch.Min = Math.Max(-90f, logicalMount.Pitch.Min);
                    logicalMount.Pitch.Max = Math.Min(90f, logicalMount.Pitch.Max);
                    logicalMountList.Add(logicalMount);
                }
            }
            if (this.IsCarrier)
            {
                this.CarrierType = ShipSectionAsset.GetCarrierType(banks);
            }
            List <string>          stringList          = new List <string>();
            List <ShipSectionType> shipSectionTypeList = new List <ShipSectionType>();

            foreach (ExcludedSection excludedSection in ss.ExcludedSections)
            {
                stringList.Add(excludedSection.Name);
            }
            foreach (ExcludedType excludedType in ss.ExcludedTypes)
            {
                ShipSectionType shipSectionType = ShipSectionType.Command;
                if (excludedType.Name == "Engine")
                {
                    shipSectionType = ShipSectionType.Engine;
                }
                else if (excludedType.Name == "Mission")
                {
                    shipSectionType = ShipSectionType.Mission;
                }
                shipSectionTypeList.Add(shipSectionType);
            }
            List <SectionEnumerations.PsionicAbility> psionicAbilityList = new List <SectionEnumerations.PsionicAbility>();

            foreach (AvailablePsionicAbility psionicAbility in ss.PsionicAbilities)
            {
                psionicAbilityList.Add((SectionEnumerations.PsionicAbility)Enum.Parse(typeof(SectionEnumerations.PsionicAbility), psionicAbility.Name));
            }
            foreach (IEnumerable <string> source2 in stringSetList)
            {
                this.ShipOptions.Add(source2.ToArray <string>());
            }
            this.RequiredTechs       = source1.ToArray <string>();
            this.Banks               = banks.ToArray();
            this.Mounts              = logicalMountList.ToArray();
            this.Modules             = logicalModuleMountList.ToArray();
            this.ExcludeSections     = stringList.ToArray();
            this.ExcludeSectionTypes = shipSectionTypeList.ToArray();
            this.PsionicAbilities    = psionicAbilityList.ToArray();
            if (!ss.RealShipClass.HasValue)
            {
                if (this.RealClass != RealShipClasses.BattleCruiser && this.RealClass != RealShipClasses.BattleShip)
                {
                    this.RealClass = ObtainShipClassTypes.GetRealShipClass(this.Class, this.BattleRiderType, filename);
                }
            }
            else
            {
                this.RealClass = ss.RealShipClass.Value;
            }
            if (this.CombatAIType != SectionEnumerations.CombatAiType.VonNeumannDisc)
            {
                return;
            }
            this.cloakingType = CloakingType.ImprovedCloaking;
        }