Пример #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
 private void SyncFleetShipModels(int systemID)
 {
     foreach (FleetInfo fleetInfo in this.App.GameDatabase.GetFleetInfoBySystemID(systemID, FleetType.FL_NORMAL | FleetType.FL_RESERVE))
     {
         if (fleetInfo.PlayerID == this.App.LocalPlayer.ID)
         {
             foreach (ShipInfo shipInfo in this.App.GameDatabase.GetShipInfoByFleetID(fleetInfo.ID, true))
             {
                 DesignSectionInfo designSectionInfo = ((IEnumerable <DesignSectionInfo>)shipInfo.DesignInfo.DesignSections).FirstOrDefault <DesignSectionInfo>((Func <DesignSectionInfo, bool>)(x => x.ShipSectionAsset.Type == ShipSectionType.Mission));
                 if ((designSectionInfo == null || !ShipSectionAsset.IsBattleRiderClass(designSectionInfo.ShipSectionAsset.RealClass)) && !shipInfo.DesignInfo.IsLoaCube())
                 {
                     List <object> objectList = new List <object>();
                     objectList.Add((object)0);
                     ShipDummy state = new ShipDummy(this.App, CreateShipDummyParams.ObtainShipDummyParams(this.App, shipInfo));
                     this.App.AddExistingObject((IGameObject)state, objectList.ToArray());
                     this._manager.PostObjectAddObjects((IGameObject)state);
                     Vector3?shipFleetPosition = this.App.GameDatabase.GetShipFleetPosition(shipInfo.ID);
                     state.PostSetProp("SetShipID", shipInfo.ID);
                     state.PostSetProp("SetDesignID", shipInfo.DesignID);
                     int commandPointCost = this.App.GameDatabase.GetShipCommandPointCost(shipInfo.ID, true);
                     state.PostSetProp("SetShipCommandCost", commandPointCost);
                     state.FleetID = fleetInfo.ID;
                     state.PostSetProp("SetShipName", shipInfo.ShipName);
                     if (shipFleetPosition.HasValue)
                     {
                         state.PostSetProp("SetFleetPosition", (object)shipFleetPosition.Value.X, (object)shipFleetPosition.Value.Y, (object)shipFleetPosition.Value.Z);
                     }
                     this._shipDummies.Add(state);
                 }
             }
         }
     }
 }
Пример #3
0
        public static int GetNumRiderSlots(App game, DesignSectionInfo info)
        {
            ShipSectionAsset shipSectionAsset = game.AssetDatabase.GetShipSectionAsset(info.FilePath);
            int num = 0;

            foreach (LogicalMount mount in shipSectionAsset.Mounts)
            {
                if (RiderManager.IsRiderMount(mount))
                {
                    ++num;
                }
            }
            foreach (DesignModuleInfo module in info.Modules)
            {
                string path = game.GameDatabase.GetModuleAsset(module.ModuleID);
                foreach (LogicalMount mount in game.AssetDatabase.Modules.FirstOrDefault <LogicalModule>((Func <LogicalModule, bool>)(x => x.ModulePath == path)).Mounts)
                {
                    if (RiderManager.IsRiderMount(mount))
                    {
                        ++num;
                    }
                }
            }
            return(num);
        }
Пример #4
0
        public FleetWidget.FilterShips FleetWidgetShipFilter(
            ShipInfo ship,
            DesignInfo design)
        {
            int num1 = 0;

            foreach (DesignSectionInfo designSection in design.DesignSections)
            {
                ShipSectionAsset shipSectionAsset = this.App.AssetDatabase.GetShipSectionAsset(designSection.FilePath);
                if (shipSectionAsset.BattleRiderType != BattleRiderTypes.Unspecified)
                {
                    int battleRiderType = (int)shipSectionAsset.BattleRiderType;
                }
                num1 += RiderManager.GetNumRiderSlots(this.App, designSection);
            }
            int num2 = 0;

            foreach (DesignSectionInfo designSection in design.DesignSections)
            {
                num2 += this.App.AssetDatabase.GetShipSectionAsset(designSection.FilePath).ReserveSize;
            }
            if (num2 > 0 || num1 > 0)
            {
                return(FleetWidget.FilterShips.Enable);
            }
            return(design.Class == ShipClass.BattleRider ? FleetWidget.FilterShips.Ignore : FleetWidget.FilterShips.Ignore);
        }
Пример #5
0
        private static void SyncStationDetailsControl(
            GameSession game,
            string panelName,
            StationInfo station)
        {
            ShipSectionAsset shipSectionAsset = game.AssetDatabase.ShipSections.First <ShipSectionAsset>((Func <ShipSectionAsset, bool>)(x => x.FileName == station.DesignInfo.DesignSections[0].FilePath));
            int   crew                 = shipSectionAsset.Crew;
            float structure            = station.DesignInfo.Structure;
            int   stationUpkeepCost    = GameSession.CalculateStationUpkeepCost(game.GameDatabase, game.AssetDatabase, station);
            float tacticalSensorRange  = shipSectionAsset.TacticalSensorRange;
            float strategicSensorRange = shipSectionAsset.StrategicSensorRange;

            foreach (DesignModuleInfo module in station.DesignInfo.DesignSections[0].Modules)
            {
                DesignModuleInfo dmi           = module;
                LogicalModule    logicalModule = game.AssetDatabase.Modules.First <LogicalModule>((Func <LogicalModule, bool>)(x => x.ModulePath == game.GameDatabase.GetModuleAsset(dmi.ModuleID)));
                crew += logicalModule.Crew;
                tacticalSensorRange += logicalModule.SensorBonus;
            }
            string propertyValue1 = crew.ToString();
            string propertyValue2 = strategicSensorRange.ToString();
            string propertyValue3 = tacticalSensorRange.ToString();
            string propertyValue4 = stationUpkeepCost.ToString();
            string propertyValue5 = structure.ToString();

            game.UI.SetPropertyString(game.UI.Path(panelName, "popVal"), "text", propertyValue1);
            game.UI.SetPropertyString(game.UI.Path(panelName, "stratVal"), "text", propertyValue2);
            game.UI.SetPropertyString(game.UI.Path(panelName, "tactVal"), "text", propertyValue3);
            game.UI.SetPropertyString(game.UI.Path(panelName, "maintVal"), "text", propertyValue4);
            game.UI.SetPropertyString(game.UI.Path(panelName, "structVal"), "text", propertyValue5);
        }
Пример #6
0
        private void AddTurretsToShipDummy(
            App game,
            string preferredMount,
            Faction faction,
            ShipSectionAsset section,
            ShipDummy.ShipDummyPart sectionPart,
            IEnumerable <WeaponAssignment> assignedWeapons,
            IEnumerable <LogicalWeapon> preferredWeapons,
            IEnumerable <LogicalWeapon> weapons,
            IEnumerable <LogicalTurretHousing> turretHousings,
            LogicalModule module,
            ShipDummy.ShipDummyPart modulePart,
            LogicalBank bank)
        {
            int                designID          = 0;
            int                targetFilter      = 0;
            int                fireMode          = 0;
            string             moduleNodeName    = modulePart != null ? modulePart.AttachedNodeName : "";
            LogicalWeapon      weapon            = ShipDummy.SelectWeapon(section, bank, assignedWeapons, preferredWeapons, weapons, moduleNodeName, out designID, out targetFilter, out fireMode);
            LogicalTurretClass weaponTurretClass = weapon.GetLogicalTurretClassForMount(bank.TurretSize, bank.TurretClass);

            if (weaponTurretClass == null)
            {
                App.Log.Warn(string.Format("Ship Dummy - did not find weapon turret class for: Bank Size [" + bank.TurretSize.ToString() + "], Bank Class [" + bank.TurretClass.ToString() + "] in section [" + section.FileName + "]"), "design");
            }
            else
            {
                LogicalTurretHousing housing = turretHousings.First <LogicalTurretHousing>((Func <LogicalTurretHousing, bool>)(housingCandidate =>
                {
                    if (weaponTurretClass.TurretClass == housingCandidate.Class && weapon.DefaultWeaponSize == housingCandidate.WeaponSize)
                    {
                        return(bank.TurretSize == housingCandidate.MountSize);
                    }
                    return(false);
                }));
                new MountObject.WeaponModels().FillOutModelFilesWithWeapon(weapon, faction, weapons);
                LogicalBank localBank = bank;
                foreach (LogicalMount mount in ((IEnumerable <LogicalMount>)section.Mounts).Where <LogicalMount>((Func <LogicalMount, bool>)(x => x.Bank == localBank)))
                {
                    string baseModel       = Ship.FixAssetNameForDLC(weaponTurretClass.GetBaseModel(faction, mount, housing), preferredMount);
                    string turretModelName = Ship.FixAssetNameForDLC(weaponTurretClass.GetTurretModelName(faction, mount, housing), preferredMount);
                    string barrelModelName = Ship.FixAssetNameForDLC(weaponTurretClass.GetBarrelModelName(faction, mount), preferredMount);
                    this.AddTurretModels(game, baseModel, turretModelName, barrelModelName, mount.NodeName, sectionPart);
                }
                if (modulePart == null || module == null)
                {
                    return;
                }
                foreach (LogicalMount mount in ((IEnumerable <LogicalMount>)module.Mounts).Where <LogicalMount>((Func <LogicalMount, bool>)(x => x.Bank == localBank)))
                {
                    string baseModel       = Ship.FixAssetNameForDLC(weaponTurretClass.GetBaseModel(faction, mount, housing), preferredMount);
                    string turretModelName = Ship.FixAssetNameForDLC(weaponTurretClass.GetTurretModelName(faction, mount, housing), preferredMount);
                    string barrelModelName = Ship.FixAssetNameForDLC(weaponTurretClass.GetBarrelModelName(faction, mount), preferredMount);
                    this.AddTurretModels(game, baseModel, turretModelName, barrelModelName, mount.NodeName, modulePart);
                }
            }
        }
Пример #7
0
        private static LogicalWeapon SelectWeapon(
            ShipSectionAsset section,
            LogicalBank bank,
            IEnumerable <WeaponAssignment> assignedWeapons,
            IEnumerable <LogicalWeapon> preferredWeapons,
            IEnumerable <LogicalWeapon> weapons,
            string moduleNodeName,
            out int designID,
            out int targetFilter,
            out int fireMode)
        {
            LogicalWeapon logicalWeapon = (LogicalWeapon)null;

            designID     = 0;
            targetFilter = 0;
            fireMode     = 0;
            if (assignedWeapons != null)
            {
                WeaponAssignment weaponAssignment = assignedWeapons.FirstOrDefault <WeaponAssignment>((Func <WeaponAssignment, bool>)(x =>
                {
                    if (x.Bank != bank)
                    {
                        return(false);
                    }
                    if (x.ModuleNode != null)
                    {
                        return(x.ModuleNode == moduleNodeName);
                    }
                    return(true);
                }));
                if (weaponAssignment != null)
                {
                    logicalWeapon = weaponAssignment.Weapon;
                    designID      = weaponAssignment.DesignID;
                    targetFilter  = weaponAssignment.InitialTargetFilter ?? 0;
                    fireMode      = weaponAssignment.InitialFireMode ?? 0;
                }
            }
            if (logicalWeapon == null && !string.IsNullOrEmpty(bank.DefaultWeaponName))
            {
                logicalWeapon = weapons.FirstOrDefault <LogicalWeapon>((Func <LogicalWeapon, bool>)(x => string.Equals(x.WeaponName, bank.DefaultWeaponName, StringComparison.InvariantCultureIgnoreCase)));
            }
            if (logicalWeapon == null && preferredWeapons != null)
            {
                logicalWeapon = LogicalWeapon.EnumerateWeaponFits(section.Faction, section.SectionName, preferredWeapons, bank.TurretSize, bank.TurretClass).FirstOrDefault <LogicalWeapon>();
            }
            if (logicalWeapon == null)
            {
                logicalWeapon = LogicalWeapon.EnumerateWeaponFits(section.Faction, section.SectionName, weapons, bank.TurretSize, bank.TurretClass).FirstOrDefault <LogicalWeapon>();
            }
            if (logicalWeapon == null)
            {
                logicalWeapon = weapons.First <LogicalWeapon>();
            }
            return(logicalWeapon);
        }
Пример #8
0
        public string GetCurrentSectionAssetName(ShipSectionType sectionType)
        {
            ShipSectionAsset currentSection = this.GetCurrentSection(sectionType);

            if (currentSection != null)
            {
                return(currentSection.FileName);
            }
            return(string.Empty);
        }
Пример #9
0
        public string GetCurrentSectionName(ShipSectionType sectionType)
        {
            ShipSectionAsset currentSection = this.GetCurrentSection(sectionType);

            if (currentSection != null)
            {
                return(App.Localize(currentSection.Title));
            }
            return("unknown");
        }
Пример #10
0
        public float GetBaseStratSensorRange()
        {
            ShipSectionAsset shipSectionAsset = this.DesignInfo.DesignSections[0].ShipSectionAsset;

            if (shipSectionAsset != null)
            {
                return(shipSectionAsset.StrategicSensorRange);
            }
            return(0.0f);
        }
Пример #11
0
        public int GetCommandPoints()
        {
            ShipSectionAsset missionSectionAsset = this.GetMissionSectionAsset();

            if (missionSectionAsset == null)
            {
                return(0);
            }
            return(missionSectionAsset.CommandPoints);
        }
Пример #12
0
 public ShipSectionAsset GetCommandSectionAsset(AssetDatabase assetdb)
 {
     foreach (DesignSectionInfo designSection in this.DesignSections)
     {
         ShipSectionAsset shipSectionAsset = assetdb.GetShipSectionAsset(designSection.FilePath);
         if (shipSectionAsset.Type == ShipSectionType.Command)
         {
             return(shipSectionAsset);
         }
     }
     return((ShipSectionAsset)null);
 }
Пример #13
0
        public static void SyncSpeed(App game, DesignInfo design)
        {
            double mass         = (double)design.Mass;
            float  acceleration = design.Acceleration;
            float  topSpeed     = design.TopSpeed;
            float  num1         = topSpeed / acceleration;
            float  num2         = 0.0f;
            float  num3         = 0.0f;

            foreach (DesignSectionInfo designSection in design.DesignSections)
            {
                ShipSectionAsset shipSectionAsset = designSection.ShipSectionAsset;
                if (shipSectionAsset != null)
                {
                    if ((double)shipSectionAsset.NodeSpeed > 0.0)
                    {
                        num3 = shipSectionAsset.NodeSpeed;
                    }
                    if ((double)shipSectionAsset.FtlSpeed > 0.0)
                    {
                        num2 = shipSectionAsset.FtlSpeed;
                    }
                }
            }
            float num4 = 0.0f;

            foreach (DesignSectionInfo designSection in design.DesignSections)
            {
                DesignSectionInfo sectionInfo      = designSection;
                ShipSectionAsset  shipSectionAsset = game.AssetDatabase.ShipSections.First <ShipSectionAsset>((Func <ShipSectionAsset, bool>)(x => x.FileName == sectionInfo.FilePath));
                num4 += shipSectionAsset.Maneuvering.RotationSpeed;
            }
            string     text1      = string.Format("{0} kg", (object)design.Mass);
            string     text2      = string.Format("{0} km/s\x00B2", (object)design.Acceleration);
            string     text3      = string.Format("{0} deg/s", (object)num4);
            string     text4      = string.Format("{0} km/s (in {1}s)", (object)topSpeed, (object)Math.Max(1, (int)num1));
            PlayerInfo playerInfo = game.GameDatabase.GetPlayerInfo(design.PlayerID);

            if (game.AssetDatabase.GetFaction(playerInfo.FactionID).CanUseNodeLine(new bool?()))
            {
                game.UI.SetText("gameShipFTLSpeed", string.Format("{0} ly", (object)num3));
            }
            else
            {
                game.UI.SetText("gameShipFTLSpeed", string.Format("{0} ly", (object)num2));
            }
            game.UI.SetText("gameShipTopSpeedTime", text4);
            game.UI.SetText("gameShipTurnSpeed", text3);
            game.UI.SetText("gameShipThrust", text2);
            game.UI.SetText("gameShipMass", text1);
            game.UI.SetPropertyFloat("gameSpeedGraph", "accel", acceleration);
            game.UI.SetPropertyFloat("gameSpeedGraph", "max_speed", topSpeed);
        }
Пример #14
0
        public ModuleShipData GetCurrentModuleMount(
            ShipSectionAsset section,
            string mountNodeName)
        {
            SectionShipData sectionShipData = this.GetCurrentSections().FirstOrDefault <SectionShipData>((Func <SectionShipData, bool>)(x => x.Section == section));

            if (sectionShipData == null)
            {
                return((ModuleShipData)null);
            }
            return(sectionShipData.Modules.FirstOrDefault <ModuleShipData>((Func <ModuleShipData, bool>)(x => x.ModuleMount.NodeName == mountNodeName)));
        }
Пример #15
0
        public static void SyncSectionArmor(
            App game,
            string panelId,
            ShipSectionAsset sectionAsset,
            DesignInfo design)
        {
            string panelId1 = game.UI.Path(panelId, "partArmor");
            string panelId2 = game.UI.Path(panelId, "partArmorTop");
            string panelId3 = game.UI.Path(panelId, "partArmorBtm");
            string panelId4 = game.UI.Path(panelId, "partArmorSide");
            string panelId5 = game.UI.Path(panelId, "partStruct");
            string panelId6 = game.UI.Path(panelId, "partStructBar");
            int    num1     = 0;
            int    num2     = sectionAsset.Structure;

            if (design != null)
            {
                DesignSectionInfo designSectionInfo = ((IEnumerable <DesignSectionInfo>)design.DesignSections).FirstOrDefault <DesignSectionInfo>((Func <DesignSectionInfo, bool>)(x => x.FilePath == sectionAsset.FileName));
                List <string>     list = designSectionInfo.Techs.Select <int, string>((Func <int, string>)(x => game.GameDatabase.GetTechFileID(x))).ToList <string>();
                num1 = Ship.GetArmorBonusFromTech(game.AssetDatabase, list);
                num2 = Ship.GetStructureWithTech(game.AssetDatabase, list, num2);
                foreach (DesignModuleInfo module in designSectionInfo.Modules)
                {
                    string        moduleAsset   = game.GameDatabase.GetModuleAsset(module.ModuleID);
                    LogicalModule logicalModule = game.AssetDatabase.Modules.FirstOrDefault <LogicalModule>((Func <LogicalModule, bool>)(x => x.ModulePath == moduleAsset));
                    if (logicalModule != null)
                    {
                        num2 += (int)logicalModule.StructureBonus;
                    }
                }
            }
            int    propertyValue1 = sectionAsset.Armor[1].Y + num1;
            int    propertyValue2 = sectionAsset.Armor[3].Y + num1;
            int    propertyValue3 = Math.Max(sectionAsset.Armor[2].Y, sectionAsset.Armor[0].Y) + num1;
            int    num3           = sectionAsset.Armor[1].X * (sectionAsset.Armor[1].Y + num1) + sectionAsset.Armor[3].X * (sectionAsset.Armor[3].Y + num1) + sectionAsset.Armor[0].X * (sectionAsset.Armor[0].Y + num1) + sectionAsset.Armor[2].X * (sectionAsset.Armor[2].Y + num1);
            int    propertyValue4 = 10;
            int    propertyValue5 = 10000;
            string text1          = num3.ToString("N0");
            string text2          = num2.ToString("N0");

            game.UI.SetText(panelId1, text1);
            game.UI.SetPropertyInt(panelId2, "value", propertyValue1);
            game.UI.SetPropertyInt(panelId3, "value", propertyValue2);
            game.UI.SetPropertyInt(panelId4, "value", propertyValue3);
            game.UI.SetPropertyInt(panelId2, "max_value", propertyValue4);
            game.UI.SetPropertyInt(panelId3, "max_value", propertyValue4);
            game.UI.SetPropertyInt(panelId4, "max_value", propertyValue4);
            game.UI.SetText(panelId5, text2);
            game.UI.SetPropertyInt(panelId6, "value", num2);
            game.UI.SetPropertyInt(panelId6, "max_value", propertyValue5);
        }
Пример #16
0
        public void New(
            Player player,
            IEnumerable <ShipSectionAsset> sections,
            IEnumerable <LogicalTurretHousing> turretHousings,
            IEnumerable <LogicalWeapon> weapons,
            IEnumerable <LogicalWeapon> preferredWeapons,
            IEnumerable <WeaponAssignment> assignedWeapons,
            IEnumerable <LogicalModule> modules,
            IEnumerable <LogicalModule> preferredModules,
            IEnumerable <ModuleAssignment> assignedModules,
            IEnumerable <LogicalPsionic> psionics,
            DesignSectionInfo[] techs,
            Faction faction,
            string shipName,
            string priorityWeapon)
        {
            this.Clear();
            this._sections = sections.ToArray <ShipSectionAsset>();
            CreateShipParams createShipParams = new CreateShipParams();

            createShipParams.player              = player;
            createShipParams.sections            = sections;
            createShipParams.turretHousings      = turretHousings;
            createShipParams.weapons             = weapons;
            createShipParams.preferredWeapons    = preferredWeapons;
            createShipParams.assignedWeapons     = assignedWeapons;
            createShipParams.modules             = modules;
            createShipParams.preferredModules    = preferredModules;
            createShipParams.addPsionics         = false;
            createShipParams.defenceBoatIsActive = true;
            createShipParams.priorityWeapon      = priorityWeapon;
            createShipParams.assignedModules     = assignedModules;
            createShipParams.psionics            = psionics;
            createShipParams.faction             = faction;
            createShipParams.shipName            = shipName;
            foreach (DesignSectionInfo tech1 in techs)
            {
                DesignSectionInfo dsi = tech1;
                ShipSectionAsset  shipSectionAsset = dsi.ShipSectionAsset ?? this._game.AssetDatabase.ShipSections.First <ShipSectionAsset>((Func <ShipSectionAsset, bool>)(x => x.FileName == dsi.FilePath));
                foreach (int tech2 in dsi.Techs)
                {
                    createShipParams.assignedTechs[(int)shipSectionAsset.Type].Techs.Add(tech2);
                }
            }
            createShipParams.isKillable = false;
            createShipParams.enableAI   = false;
            this._ship[this._loadShip]  = Ship.CreateShip(this._game, createShipParams);
            this.PostNewShip(player);
            this._ready   = false;
            this._loading = true;
        }
Пример #17
0
        private void UpdateStationDesignInfo(DesignInfo di)
        {
            int num = 0;

            foreach (DesignSectionInfo designSection in di.DesignSections)
            {
                DesignSectionInfo dsi = designSection;
                if (dsi.WeaponBanks != null)
                {
                    dsi.WeaponBanks.Clear();
                }
                ShipSectionAsset section = this.App.AssetDatabase.ShipSections.First <ShipSectionAsset>((Func <ShipSectionAsset, bool>)(x => x.FileName == dsi.FilePath));
                if (dsi.Modules != null)
                {
                    foreach (DesignModuleInfo module in dsi.Modules)
                    {
                        string        moduleass     = this.App.GameDatabase.GetModuleAsset(module.ModuleID);
                        LogicalModule logicalModule = this.App.AssetDatabase.Modules.First <LogicalModule>((Func <LogicalModule, bool>)(x => x.ModulePath == moduleass));
                        if (logicalModule != null && ((IEnumerable <LogicalBank>)logicalModule.Banks).Count <LogicalBank>() > 0)
                        {
                            int fireMode = 0;
                            ShipSectionAsset            shipSectionAsset = this._ship.DesignInfo.DesignSections[0].ShipSectionAsset;
                            IEnumerable <LogicalWeapon> preferredWeapons = LogicalWeapon.EnumerateWeaponFits(shipSectionAsset.Faction, shipSectionAsset.SectionName, this.App.GameDatabase.GetAvailableWeapons(this.App.AssetDatabase, this.App.LocalPlayer.ID).Where <LogicalWeapon>((Func <LogicalWeapon, bool>)(weapona => weapona.IsVisible)), logicalModule.Banks[0].TurretSize, logicalModule.Banks[0].TurretClass).Where <LogicalWeapon>((Func <LogicalWeapon, bool>)(x =>
                            {
                                if ((double)x.Range <= 1500.0)
                                {
                                    return(x.DefaultWeaponSize == WeaponEnums.WeaponSizes.VeryLight);
                                }
                                return(true);
                            }));
                            int           designID;
                            int           targetFilter;
                            LogicalWeapon logicalWeapon = Ship.SelectWeapon(section, logicalModule.Banks[0], (IEnumerable <WeaponAssignment>)null, preferredWeapons, this.App.GameDatabase.GetAvailableWeapons(this.App.AssetDatabase, this.App.LocalPlayer.ID), module.MountNodeName, out designID, out targetFilter, out fireMode);
                            int?          nullable      = new int?();
                            if (logicalWeapon != null && !module.WeaponID.HasValue)
                            {
                                nullable = this.App.GameDatabase.GetWeaponID(logicalWeapon.FileName, this.App.LocalPlayer.ID);
                            }
                            else if (module.WeaponID.HasValue)
                            {
                                nullable = module.WeaponID;
                            }
                            this.ModuleBankdict[module.ID] = module.MountNodeName;
                            ++num;
                            module.WeaponID = nullable;
                        }
                    }
                }
            }
        }
Пример #18
0
 public static ShipSectionAsset GetSectionAsset(
     App game,
     DesignInfo design,
     ShipSectionType sectionType)
 {
     foreach (DesignSectionInfo designSection1 in design.DesignSections)
     {
         DesignSectionInfo designSection    = designSection1;
         ShipSectionAsset  shipSectionAsset = game.AssetDatabase.ShipSections.First <ShipSectionAsset>((Func <ShipSectionAsset, bool>)(x => x.FileName == designSection.FilePath));
         if (shipSectionAsset.Type == sectionType)
         {
             return(shipSectionAsset);
         }
     }
     return((ShipSectionAsset)null);
 }
Пример #19
0
        public FleetWidget.FilterShips LeftListFilter(ShipInfo ship, DesignInfo design)
        {
            FleetInfo fleetInfo = this._app.GameDatabase.GetFleetInfo(ship.FleetID);

            if ((fleetInfo != null ? fleetInfo.PlayerID : design.PlayerID) != this._app.LocalPlayer.ID)
            {
                return(FleetWidget.FilterShips.Ignore);
            }
            int num = 0;

            foreach (DesignSectionInfo designSection in design.DesignSections)
            {
                ShipSectionAsset shipSectionAsset = this._app.AssetDatabase.GetShipSectionAsset(designSection.FilePath);
                num += shipSectionAsset.RepairPoints;
            }
            return(num > 0 ? FleetWidget.FilterShips.Enable : FleetWidget.FilterShips.Ignore);
        }
Пример #20
0
 public void ResetTargets()
 {
     this._targetObjects.Clear(true);
     this._targetsLoaded = false;
     this._section       = new ShipSectionAsset()
     {
         Banks           = new LogicalBank[0],
         Modules         = new LogicalModuleMount[0],
         ExcludeSections = new string[0],
         Class           = ShipClass.BattleRider,
         Faction         = this._faction,
         FileName        = string.Empty,
         Structure       = 100,
         Maneuvering     = new ShipManeuveringInfo()
         {
             LinearAccel   = 200f,
             LinearSpeed   = 400f,
             RotationSpeed = 300f,
             RotAccel      = new Vector3(100f, 100f, 100f)
         },
         ManeuveringType            = "Fast",
         Mass                       = 15000f,
         ModelName                  = this._modelFile,
         DestroyedModelName         = this._modelFile,
         DamageEffect               = new LogicalEffect(),
         DeathEffect                = new LogicalEffect(),
         ReactorFailureDeathEffect  = new LogicalEffect(),
         ReactorCriticalDeathEffect = new LogicalEffect(),
         AbsorbedDeathEffect        = new LogicalEffect(),
         Mounts                     = new LogicalMount[0],
         PsionicAbilities           = new SectionEnumerations.PsionicAbility[0],
         Type                       = ShipSectionType.Mission
     };
     Matrix[] targetTransforms = this.GetTargetTransforms(this._goalDist);
     for (int index = 0; index < targetTransforms.Length; ++index)
     {
         this._targets[index] = this.AddTarget(targetTransforms[index].Position, targetTransforms[index].EulerAngles);
     }
 }
Пример #21
0
        private static Dictionary <FleetInfo, List <ShipInfo> > GetShipsInFleets(
            GameSession game,
            List <FleetInfo> playerFleets)
        {
            Dictionary <FleetInfo, List <ShipInfo> > dictionary = new Dictionary <FleetInfo, List <ShipInfo> >();

            foreach (FleetInfo playerFleet in playerFleets)
            {
                if (playerFleet.Type == FleetType.FL_NORMAL || (playerFleet.Type & FleetType.FL_ALL_COMBAT) != (FleetType)0)
                {
                    dictionary.Add(playerFleet, new List <ShipInfo>());
                    foreach (ShipInfo shipInfo in game.GameDatabase.GetShipInfoByFleetID(playerFleet.ID, true).ToList <ShipInfo>())
                    {
                        if (!ShipSectionAsset.IsBattleRiderClass(shipInfo.DesignInfo.GetRealShipClass().Value))
                        {
                            dictionary[playerFleet].Add(shipInfo);
                        }
                    }
                }
            }
            return(dictionary);
        }
Пример #22
0
        protected override void OnPanelMessage(string panelName, string msgType, string[] msgParams)
        {
            if (!(msgType == "button_clicked"))
            {
                return;
            }
            if (panelName == "cancelButton")
            {
                this._app.UI.CloseDialog((Dialog)this, true);
                this.HideWeaponSelector();
            }
            if (panelName == "okButton")
            {
                this.RetrofitShips();
                this._app.UI.CloseDialog((Dialog)this, true);
                this.HideWeaponSelector();
            }
            if (!this.BankDict.ContainsKey(panelName))
            {
                return;
            }
            this.SelectBank(this.BankDict[panelName]);
            string           asset            = this.App.GameDatabase.GetWeaponAsset(this._selectedModule.WeaponID.Value);
            LogicalWeapon    selected         = this.App.AssetDatabase.Weapons.First <LogicalWeapon>((Func <LogicalWeapon, bool>)(x => x.FileName == asset));
            ShipSectionAsset shipSectionAsset = this._ship.DesignInfo.DesignSections[0].ShipSectionAsset;
            string           moduleass        = this.App.GameDatabase.GetModuleAsset(this._selectedModule.ModuleID);
            LogicalModule    logicalModule    = this.App.AssetDatabase.Modules.First <LogicalModule>((Func <LogicalModule, bool>)(x => x.ModulePath == moduleass));

            this.PopulateWeaponSelector(LogicalWeapon.EnumerateWeaponFits(shipSectionAsset.Faction, shipSectionAsset.SectionName, this.App.GameDatabase.GetAvailableWeapons(this.App.AssetDatabase, this.App.LocalPlayer.ID).Where <LogicalWeapon>((Func <LogicalWeapon, bool>)(weapon => weapon.IsVisible)), logicalModule.Banks[0].TurretSize, logicalModule.Banks[0].TurretClass).Where <LogicalWeapon>((Func <LogicalWeapon, bool>)(x =>
            {
                if ((double)x.Range <= 1500.0)
                {
                    return(x.DefaultWeaponSize == WeaponEnums.WeaponSizes.VeryLight);
                }
                return(true);
            })).ToList <LogicalWeapon>(), selected);
            this.selecteditem = this.ItemIDDict[panelName];
        }
Пример #23
0
        public static void Simulate(GameSession game, int systemId, List <FleetInfo> fleets)
        {
            if (ScriptHost.AllowConsole)
            {
                App.Log.Trace(string.Format("Simulating AI combat at: {0}", (object)systemId), "combat");
            }
            List <PlanetCombatInfo> planets = new List <PlanetCombatInfo>();

            PlanetInfo[] systemPlanetInfos = game.GameDatabase.GetStarSystemPlanetInfos(systemId);
            if (systemPlanetInfos != null)
            {
                foreach (PlanetInfo planetInfo in systemPlanetInfos)
                {
                    planets.Add(new PlanetCombatInfo()
                    {
                        planetInfo = planetInfo,
                        colonyInfo = game.GameDatabase.GetColonyInfoForPlanet(planetInfo.ID)
                    });
                }
            }
            Dictionary <FleetInfo, List <ShipCombatInfo> > shipCombatInfo = new Dictionary <FleetInfo, List <ShipCombatInfo> >();

            foreach (FleetInfo fleet in fleets)
            {
                List <ShipCombatInfo> shipCombatInfoList = new List <ShipCombatInfo>();
                foreach (ShipInfo shipInfo in game.GameDatabase.GetShipInfoByFleetID(fleet.ID, true).ToList <ShipInfo>())
                {
                    if (shipInfo.DesignInfo.Class != ShipClass.BattleRider)
                    {
                        ShipCombatInfo sci = new ShipCombatInfo();
                        sci.shipInfo = shipInfo;
                        float num = 1f;
                        if (shipInfo.DesignInfo.Class == ShipClass.Cruiser || shipInfo.DesignInfo.Class == ShipClass.Dreadnought)
                        {
                            num = 3f;
                        }
                        sci.armorFactor     = (float)shipInfo.DesignInfo.Armour / num;
                        sci.structureFactor = shipInfo.DesignInfo.Structure / num;
                        foreach (DesignSectionInfo designSection in shipInfo.DesignInfo.DesignSections)
                        {
                            ShipSectionAsset shipSectionAsset = game.AssetDatabase.GetShipSectionAsset(designSection.FilePath);
                            foreach (WeaponBankInfo weaponBank in designSection.WeaponBanks)
                            {
                                WeaponBankInfo wbi = weaponBank;
                                if (wbi.WeaponID.HasValue)
                                {
                                    string              weaponName = Path.GetFileNameWithoutExtension(game.GameDatabase.GetWeaponAsset(wbi.WeaponID.Value));
                                    LogicalWeapon       lw         = game.AssetDatabase.Weapons.FirstOrDefault <LogicalWeapon>((Func <LogicalWeapon, bool>)(weapon => string.Equals(weapon.WeaponName, weaponName, StringComparison.InvariantCultureIgnoreCase)));
                                    List <LogicalMount> list       = ((IEnumerable <LogicalMount>)shipSectionAsset.Mounts).Where <LogicalMount>((Func <LogicalMount, bool>)(x => x.Bank.GUID == wbi.BankGUID)).ToList <LogicalMount>();
                                    int totalMounts = list.Count <LogicalMount>() <= 0 ? 1 : list.Count <LogicalMount>();
                                    foreach (LogicalMount logicalMount in list)
                                    {
                                        switch (logicalMount.Bank.TurretClass)
                                        {
                                        case WeaponEnums.TurretClasses.Drone:
                                            ++sci.drones;
                                            continue;

                                        case WeaponEnums.TurretClasses.DestroyerRider:
                                        case WeaponEnums.TurretClasses.CruiserRider:
                                        case WeaponEnums.TurretClasses.DreadnoughtRider:
                                            ++sci.battleRiders;
                                            continue;

                                        default:
                                            CombatSimulator.ApplyWeaponStats(sci, lw, totalMounts);
                                            continue;
                                        }
                                    }
                                }
                            }
                            foreach (DesignModuleInfo module in designSection.Modules)
                            {
                                DesignModuleInfo mod           = module;
                                LogicalModule    logicalModule = game.AssetDatabase.Modules.First <LogicalModule>((Func <LogicalModule, bool>)(x => x.ModulePath == game.GameDatabase.GetModuleAsset(mod.ModuleID)));
                                if (logicalModule != null && mod.WeaponID.HasValue)
                                {
                                    foreach (LogicalBank bank in logicalModule.Banks)
                                    {
                                        LogicalBank         lb          = bank;
                                        string              weaponName2 = Path.GetFileNameWithoutExtension(game.GameDatabase.GetWeaponAsset(mod.WeaponID.Value));
                                        LogicalWeapon       lw          = game.AssetDatabase.Weapons.FirstOrDefault <LogicalWeapon>((Func <LogicalWeapon, bool>)(weapon => string.Equals(weapon.WeaponName, weaponName2, StringComparison.InvariantCultureIgnoreCase)));
                                        List <LogicalMount> list        = ((IEnumerable <LogicalMount>)shipSectionAsset.Mounts).Where <LogicalMount>((Func <LogicalMount, bool>)(x => x.Bank.GUID == lb.GUID)).ToList <LogicalMount>();
                                        int totalMounts = list.Count <LogicalMount>() <= 0 ? 1 : list.Count <LogicalMount>();
                                        foreach (LogicalMount logicalMount in list)
                                        {
                                            CombatSimulator.ApplyWeaponStats(sci, lw, totalMounts);
                                        }
                                    }
                                }
                            }
                        }
                        shipCombatInfoList.Add(sci);
                    }
                }
                shipCombatInfo.Add(fleet, shipCombatInfoList);
            }
            if (fleets.Count <FleetInfo>() > 1)
            {
                CombatSimulator.TrackingPhase(shipCombatInfo, 4f);
                CombatSimulator.DirectPhase(shipCombatInfo, 4f);
                CombatSimulator.TrackingPhase(shipCombatInfo, 1f);
                CombatSimulator.DirectPhase(shipCombatInfo, 2f);
                CombatSimulator.BombardmentPhase(game.GameDatabase, shipCombatInfo, planets, 1f);
            }
            else
            {
                CombatSimulator.BombardmentPhase(game.GameDatabase, shipCombatInfo, planets, 2f);
            }
            CombatSimulator.CompleteSimulation(game, systemId, shipCombatInfo, planets);
        }
Пример #24
0
 internal static void AutoFillModules(GameSession game, StationInfo station, Dictionary <ModuleEnums.StationModuleType, int> queuedItemMap)
 {
     if (queuedItemMap.Count > 0)
     {
         ShipSectionAsset shipSectionAsset = game.AssetDatabase.ShipSections.First((ShipSectionAsset x) => x.FileName == station.DesignInfo.DesignSections[0].FilePath);
         shipSectionAsset.Modules.ToList <LogicalModuleMount>();
         List <DesignModuleInfo> modules               = station.DesignInfo.DesignSections[0].Modules;
         List <DesignModuleInfo> source                = game.GameDatabase.GetQueuedStationModules(station.DesignInfo.DesignSections[0]).ToList <DesignModuleInfo>();
         StationInfo             stationInfo           = game.GameDatabase.GetStationInfo(station.OrbitalObjectID);
         StationModuleQueue.ModuleRequirements source2 = new StationModuleQueue.ModuleRequirements(game, stationInfo, queuedItemMap);
         Player playerObject = game.GetPlayerObject(stationInfo.PlayerID);
         foreach (KeyValuePair <ModuleEnums.StationModuleType, KeyValuePair <IEnumerable <ModuleEnums.StationModuleType>, int> > keyValuePair in from x in source2
                  where x.Value.Value > 0
                  select x)
         {
             KeyValuePair <IEnumerable <ModuleEnums.StationModuleType>, int> req = keyValuePair.Value;
             int i = req.Value - source.Where((DesignModuleInfo x) => req.Key.Any((ModuleEnums.StationModuleType y) => y == x.StationModuleType.Value)).Count <DesignModuleInfo>() - queuedItemMap.Where((KeyValuePair <ModuleEnums.StationModuleType, int> x) => req.Key.Any((ModuleEnums.StationModuleType y) => y == x.Key)).Sum((KeyValuePair <ModuleEnums.StationModuleType, int> x) => x.Value);
             while (i > 0)
             {
                 int num = i;
                 List <ModuleEnums.StationModuleType> list = req.Key.ToList <ModuleEnums.StationModuleType>();
                 if (list.Count == 0)
                 {
                     break;
                 }
                 list.Shuffle <ModuleEnums.StationModuleType>();
                 if (keyValuePair.Key == ModuleEnums.StationModuleType.Lab)
                 {
                     int playerResearchingTechID = game.GameDatabase.GetPlayerResearchingTechID(playerObject.ID);
                     if (playerResearchingTechID != 0)
                     {
                         string stringTechId = game.GameDatabase.GetTechFileID(playerResearchingTechID);
                         Tech   tech         = game.AssetDatabase.MasterTechTree.Technologies.First((Tech x) => x.Id == stringTechId);
                         ModuleEnums.StationModuleType item;
                         if (list.ExistsFirst((ModuleEnums.StationModuleType x) => x.ToString().Contains(tech.Family), out item))
                         {
                             list.Remove(item);
                             list.Insert(0, item);
                         }
                     }
                 }
                 using (List <ModuleEnums.StationModuleType> .Enumerator enumerator2 = list.GetEnumerator())
                 {
                     while (enumerator2.MoveNext())
                     {
                         ModuleEnums.StationModuleType moduleType = enumerator2.Current;
                         int num2 = req.Value - source.Where((DesignModuleInfo x) => moduleType == x.StationModuleType.Value).Count <DesignModuleInfo>() - queuedItemMap.Where((KeyValuePair <ModuleEnums.StationModuleType, int> x) => moduleType == x.Key).Sum((KeyValuePair <ModuleEnums.StationModuleType, int> x) => x.Value);
                         if (num2 > 0)
                         {
                             ModuleEnums.StationModuleType moduleType2;
                             queuedItemMap[moduleType2 = moduleType] = queuedItemMap[moduleType2] + 1;
                             i--;
                             if (i <= 0)
                             {
                                 break;
                             }
                         }
                     }
                 }
                 if (i >= num)
                 {
                     break;
                 }
             }
         }
     }
 }
Пример #25
0
 private void SyncFleetShipModels()
 {
     foreach (FleetInfo fleetInfo in this.App.GameDatabase.GetFleetsByPlayerAndSystem(this.App.LocalPlayer.ID, this._targetSystemID, FleetType.FL_ALL))
     {
         if (fleetInfo.PlayerID == this.App.LocalPlayer.ID)
         {
             IEnumerable <ShipInfo> source = this.App.GameDatabase.GetShipInfoByFleetID(fleetInfo.ID, true).Where <ShipInfo>((Func <ShipInfo, bool>)(x => !((IEnumerable <DesignSectionInfo>)x.DesignInfo.DesignSections).Any <DesignSectionInfo>((Func <DesignSectionInfo, bool>)(y => ShipSectionAsset.IsBattleRiderClass(y.ShipSectionAsset.RealClass)))));
             this._manager.PostSetProp("AddFleet", (object)fleetInfo.ID, (object)source.Count <ShipInfo>());
             foreach (ShipInfo shipInfo in source)
             {
                 List <object> objectList = new List <object>();
                 objectList.Add((object)0);
                 ShipDummy state = new ShipDummy(this.App, CreateShipDummyParams.ObtainShipDummyParams(this.App, shipInfo));
                 this.App.AddExistingObject((IGameObject)state, objectList.ToArray());
                 this._manager.PostObjectAddObjects((IGameObject)state);
                 this._pendingObjects.Add((IGameObject)state);
                 Vector3?shipFleetPosition  = this.App.GameDatabase.GetShipFleetPosition(shipInfo.ID);
                 Matrix? shipSystemPosition = this.App.GameDatabase.GetShipSystemPosition(shipInfo.ID);
                 state.PostSetProp("SetShipID", shipInfo.ID);
                 int commandPointCost = this.App.GameDatabase.GetCommandPointCost(shipInfo.DesignID);
                 state.PostSetProp("SetShipCommandCost", commandPointCost);
                 state.PostSetProp("SetFleetID", fleetInfo.ID);
                 state.PostSetProp("SetShipName", shipInfo.ShipName);
                 if (shipFleetPosition.HasValue)
                 {
                     state.PostSetProp("SetFleetPosition", (object)shipFleetPosition.Value.X, (object)shipFleetPosition.Value.Y, (object)shipFleetPosition.Value.Z);
                 }
                 if (shipSystemPosition.HasValue)
                 {
                     state.PostSetProp("SetSystemTransform", shipSystemPosition.Value);
                 }
             }
         }
     }
 }
Пример #26
0
        public static CreateShipDummyParams ObtainShipDummyParams(
            App game,
            ShipInfo shipInfo)
        {
            IEnumerable <string>    modules              = game.AssetDatabase.Modules.Select <LogicalModule, string>((Func <LogicalModule, string>)(x => x.ModuleName));
            IEnumerable <string>    weapons              = game.AssetDatabase.Weapons.Select <LogicalWeapon, string>((Func <LogicalWeapon, string>)(x => x.Name));
            DesignInfo              designInfo           = shipInfo.DesignInfo;
            List <ShipSectionAsset> shipSectionAssetList = new List <ShipSectionAsset>();
            List <ModuleAssignment> moduleAssignmentList = new List <ModuleAssignment>();
            List <WeaponAssignment> weaponAssignmentList = new List <WeaponAssignment>();

            foreach (DesignSectionInfo designSection in designInfo.DesignSections)
            {
                DesignSectionInfo sectionInfo      = designSection;
                ShipSectionAsset  shipSectionAsset = game.AssetDatabase.ShipSections.First <ShipSectionAsset>((Func <ShipSectionAsset, bool>)(x => x.FileName == sectionInfo.FilePath));
                shipSectionAssetList.Add(shipSectionAsset);
                foreach (LogicalBank bank1 in shipSectionAsset.Banks)
                {
                    LogicalBank    bank           = bank1;
                    WeaponBankInfo weaponBankInfo = sectionInfo.WeaponBanks.FirstOrDefault <WeaponBankInfo>((Func <WeaponBankInfo, bool>)(x => x.BankGUID == bank.GUID));
                    bool           flag           = false;
                    if (weaponBankInfo != null && weaponBankInfo.WeaponID.HasValue)
                    {
                        string           weaponName       = Path.GetFileNameWithoutExtension(game.GameDatabase.GetWeaponAsset(weaponBankInfo.WeaponID.Value));
                        WeaponAssignment weaponAssignment = new WeaponAssignment()
                        {
                            ModuleNode          = "",
                            Bank                = bank,
                            Weapon              = game.AssetDatabase.Weapons.First <LogicalWeapon>((Func <LogicalWeapon, bool>)(weapon => string.Equals(weapon.WeaponName, weaponName, StringComparison.InvariantCultureIgnoreCase))),
                            DesignID            = weaponBankInfo == null || !weaponBankInfo.DesignID.HasValue ? 0 : weaponBankInfo.DesignID.Value,
                            InitialTargetFilter = new int?(weaponBankInfo.FilterMode ?? 0),
                            InitialFireMode     = new int?(weaponBankInfo.FiringMode ?? 0)
                        };
                        weaponAssignmentList.Add(weaponAssignment);
                        flag = true;
                    }
                    if (!flag && !string.IsNullOrEmpty(bank.DefaultWeaponName))
                    {
                        WeaponAssignment weaponAssignment = new WeaponAssignment()
                        {
                            ModuleNode = "",
                            Bank       = bank,
                            Weapon     = game.AssetDatabase.Weapons.First <LogicalWeapon>((Func <LogicalWeapon, bool>)(weapon => string.Equals(weapon.WeaponName, bank.DefaultWeaponName, StringComparison.InvariantCultureIgnoreCase))),
                            DesignID   = weaponBankInfo == null || !weaponBankInfo.DesignID.HasValue ? 0 : weaponBankInfo.DesignID.Value
                        };
                        weaponAssignmentList.Add(weaponAssignment);
                    }
                }
                foreach (LogicalModuleMount module in shipSectionAsset.Modules)
                {
                    LogicalModuleMount sectionModule    = module;
                    DesignModuleInfo   designModuleInfo = sectionInfo.Modules.FirstOrDefault <DesignModuleInfo>((Func <DesignModuleInfo, bool>)(x => x.MountNodeName == sectionModule.NodeName));
                    if (designModuleInfo != null)
                    {
                        string        path          = game.GameDatabase.GetModuleAsset(designModuleInfo.ModuleID);
                        LogicalModule logicalModule = game.AssetDatabase.Modules.FirstOrDefault <LogicalModule>((Func <LogicalModule, bool>)(x => x.ModulePath == path));
                        moduleAssignmentList.Add(new ModuleAssignment()
                        {
                            ModuleMount = sectionModule,
                            Module      = logicalModule
                        });
                        if (designModuleInfo.WeaponID.HasValue)
                        {
                            string           weaponPath       = game.GameDatabase.GetWeaponAsset(designModuleInfo.WeaponID.Value);
                            WeaponAssignment weaponAssignment = new WeaponAssignment()
                            {
                                ModuleNode = designModuleInfo.MountNodeName,
                                Bank       = logicalModule.Banks[0],
                                Weapon     = game.AssetDatabase.Weapons.First <LogicalWeapon>((Func <LogicalWeapon, bool>)(x => x.FileName == weaponPath)),
                                DesignID   = 0
                            };
                            weaponAssignmentList.Add(weaponAssignment);
                        }
                    }
                }
            }
            ShipSectionAsset missionSection = shipSectionAssetList.FirstOrDefault <ShipSectionAsset>((Func <ShipSectionAsset, bool>)(x => x.Type == ShipSectionType.Mission));
            Faction          faction        = game.AssetDatabase.Factions.First <Faction>((Func <Faction, bool>)(x => missionSection.Faction == x.Name));
            Player           playerObject   = game.Game.GetPlayerObject(designInfo.PlayerID);
            Subfaction       subfaction     = faction.Subfactions[Math.Min(playerObject.SubfactionIndex, faction.Subfactions.Length - 1)];

            return(new CreateShipDummyParams()
            {
                ShipID = shipInfo.ID,
                PreferredMount = Ship.GetPreferredMount(game, playerObject, faction, shipSectionAssetList),
                ShipFaction = faction,
                Sections = (IEnumerable <ShipSectionAsset>)shipSectionAssetList.ToArray(),
                AssignedModules = (IEnumerable <ModuleAssignment>)moduleAssignmentList.ToArray(),
                PreferredModules = game.AssetDatabase.Modules.Where <LogicalModule>((Func <LogicalModule, bool>)(x => modules.Contains <string>(x.ModuleName))),
                AssignedWeapons = (IEnumerable <WeaponAssignment>)weaponAssignmentList.ToArray(),
                PreferredWeapons = game.AssetDatabase.Weapons.Where <LogicalWeapon>((Func <LogicalWeapon, bool>)(x => weapons.Contains <string>(x.Name)))
            });
        }
Пример #27
0
        private static IGameObject CreateShipCompound(
            App game,
            CombatConfig.DataContext context,
            XmlElement node)
        {
            XmlElement xmlElement1 = node["ShipName"];
            XmlElement xmlElement2 = node["ShipDesign"];
            XmlElement source1     = xmlElement2["Weapons"];
            XmlElement source2     = xmlElement2["Modules"];
            XmlElement xmlElement3 = xmlElement2["WeaponAssignments"];
            XmlElement xmlElement4 = xmlElement2["ModuleAssignments"];
            XmlElement source3     = xmlElement2["Sections"];
            List <WeaponAssignment> weaponAssignmentList = new List <WeaponAssignment>();
            List <ModuleAssignment> moduleAssignmentList = new List <ModuleAssignment>();
            List <ShipSectionAsset> sectionAssets        = new List <ShipSectionAsset>();
            List <LogicalModule>    logicalModuleList    = new List <LogicalModule>();

            if (source3 != null)
            {
                List <XmlElement> list = source3.OfType <XmlElement>().Where <XmlElement>((Func <XmlElement, bool>)(x => x.Name.Equals("Section", StringComparison.InvariantCulture))).ToList <XmlElement>();
                list.Select <XmlElement, string>((Func <XmlElement, string>)(x => x["SectionFile"].InnerText));
                foreach (XmlElement source4 in list)
                {
                    string           sectionFile      = source4["SectionFile"].InnerText;
                    ShipSectionAsset shipSectionAsset = game.AssetDatabase.ShipSections.FirstOrDefault <ShipSectionAsset>((Func <ShipSectionAsset, bool>)(x => x.FileName == sectionFile));
                    sectionAssets.Add(shipSectionAsset);
                    List <LogicalModule> source5 = new List <LogicalModule>();
                    foreach (XmlElement xmlElement5 in source4.OfType <XmlElement>().Where <XmlElement>((Func <XmlElement, bool>)(x => x.Name.Equals("Module", StringComparison.InvariantCulture))))
                    {
                        string        moduleNodeName = xmlElement5["Mount"].InnerText;
                        string        modulePath     = xmlElement5["ModuleId"].InnerText;
                        LogicalModule logicalModule  = game.AssetDatabase.Modules.First <LogicalModule>((Func <LogicalModule, bool>)(x => x.ModulePath == modulePath));
                        if (!source5.Contains(logicalModule))
                        {
                            source5.Add(logicalModule);
                        }
                        moduleAssignmentList.Add(new ModuleAssignment()
                        {
                            ModuleMount      = ((IEnumerable <LogicalModuleMount>)shipSectionAsset.Modules).First <LogicalModuleMount>((Func <LogicalModuleMount, bool>)(x => x.NodeName == moduleNodeName)),
                            Module           = logicalModule,
                            PsionicAbilities = (SectionEnumerations.PsionicAbility[])null
                        });
                    }
                    IEnumerable <LogicalBank> source6 = ((IEnumerable <LogicalBank>)shipSectionAsset.Banks).Concat <LogicalBank>(source5.SelectMany <LogicalModule, LogicalBank>((Func <LogicalModule, IEnumerable <LogicalBank> >)(x => (IEnumerable <LogicalBank>)x.Banks)));
                    foreach (XmlElement xmlElement5 in source4.OfType <XmlElement>().Where <XmlElement>((Func <XmlElement, bool>)(x => x.Name.Equals("Bank", StringComparison.InvariantCulture))))
                    {
                        Guid   bankGuid   = Guid.Parse(xmlElement5["Id"].InnerText);
                        string weaponName = xmlElement5["Weapon"].InnerText;
                        weaponAssignmentList.Add(new WeaponAssignment()
                        {
                            Bank   = source6.First <LogicalBank>((Func <LogicalBank, bool>)(x => x.GUID == bankGuid)),
                            Weapon = game.AssetDatabase.Weapons.First <LogicalWeapon>((Func <LogicalWeapon, bool>)(x => x.WeaponName == weaponName))
                        });
                    }
                }
            }
            IEnumerable <string> weapons = source1 == null ? (IEnumerable <string>) new string[0] : source1.OfType <XmlElement>().Where <XmlElement>((Func <XmlElement, bool>)(x => x.Name.Equals("string", StringComparison.InvariantCulture))).Select <XmlElement, string>((Func <XmlElement, string>)(x => x.InnerText));
            IEnumerable <string> modules = source2 == null ? (IEnumerable <string>) new string[0] : source2.OfType <XmlElement>().Where <XmlElement>((Func <XmlElement, bool>)(x => x.Name.Equals("string", StringComparison.InvariantCulture))).Select <XmlElement, string>((Func <XmlElement, string>)(x => x.InnerText));
            string str = xmlElement1 == null ? "USS Placeholder" : xmlElement1.InnerText;
            int    integerOrDefault = node["PlayerID"].ExtractIntegerOrDefault(0);
            Player player           = game.GetPlayer(integerOrDefault);
            Ship   ship             = Ship.CreateShip(game, new CreateShipParams()
            {
                player           = player,
                sections         = (IEnumerable <ShipSectionAsset>)sectionAssets,
                turretHousings   = game.AssetDatabase.TurretHousings,
                weapons          = game.AssetDatabase.Weapons,
                preferredWeapons = game.AssetDatabase.Weapons.Where <LogicalWeapon>((Func <LogicalWeapon, bool>)(x => weapons.Contains <string>(x.Name))),
                assignedWeapons  = (IEnumerable <WeaponAssignment>)weaponAssignmentList,
                modules          = game.AssetDatabase.Modules,
                preferredModules = game.AssetDatabase.Modules.Where <LogicalModule>((Func <LogicalModule, bool>)(x => modules.Contains <string>(x.ModuleName))),
                assignedModules  = (IEnumerable <ModuleAssignment>)moduleAssignmentList,
                psionics         = game.AssetDatabase.Psionics,
                faction          = game.AssetDatabase.Factions.First <Faction>((Func <Faction, bool>)(x => sectionAssets.First <ShipSectionAsset>().Faction == x.Name)),
                shipName         = str,
                inputID          = context.InputID
            });
            Vector3 vector3OrDefault1 = node["Position"].ExtractVector3OrDefault(Vector3.Zero);
            Vector3 vector3OrDefault2 = node["Rotation"].ExtractVector3OrDefault(Vector3.Zero);

            context.TransformPositionAndRotation(ref vector3OrDefault1, ref vector3OrDefault2);
            ship.Position = vector3OrDefault1;
            ship.Rotation = vector3OrDefault2;
            return((IGameObject)ship);
        }
Пример #28
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());
        }
Пример #29
0
        public Vector3 CreateRandomShip(Vector3 off, string Faction = "", bool ForceDread = false)
        {
            Vector3 zero = Vector3.Zero;
            List <WeaponEnums.PayloadTypes> weaponTypes = new List <WeaponEnums.PayloadTypes>();

            weaponTypes.Add(WeaponEnums.PayloadTypes.Beam);
            weaponTypes.Add(WeaponEnums.PayloadTypes.Bolt);
            weaponTypes.Add(WeaponEnums.PayloadTypes.Emitter);
            weaponTypes.Add(WeaponEnums.PayloadTypes.Missile);
            weaponTypes.Add(WeaponEnums.PayloadTypes.Torpedo);
            IEnumerable <LogicalWeapon>   logicalWeapons = this._app.AssetDatabase.Weapons.Where <LogicalWeapon>((Func <LogicalWeapon, bool>)(x => x.PayloadType == weaponTypes[new Random().Next(weaponTypes.Count <WeaponEnums.PayloadTypes>() - 1)]));
            KeyValuePair <string, Player> chosenPlayer   = this._rand.Choose <KeyValuePair <string, Player> >((IEnumerable <KeyValuePair <string, Player> >) this._players);

            if (Faction != string.Empty && this._players.ContainsKey(Faction))
            {
                chosenPlayer = this._players.FirstOrDefault <KeyValuePair <string, Player> >((Func <KeyValuePair <string, Player>, bool>)(x => x.Key == Faction));
            }
            List <ShipSectionAsset> shipSectionAssetList1 = new List <ShipSectionAsset>()
            {
                this._app.AssetDatabase.ShipSections.First <ShipSectionAsset>((Func <ShipSectionAsset, bool>)(x => x.FileName == string.Format("factions\\{0}\\sections\\dn_cmd_assault.section", (object)chosenPlayer.Key)))
            };
            List <ShipSectionAsset> shipSectionAssetList2 = new List <ShipSectionAsset>()
            {
                this._app.AssetDatabase.ShipSections.First <ShipSectionAsset>((Func <ShipSectionAsset, bool>)(x => x.FileName == string.Format("factions\\{0}\\sections\\dn_mis_armor.section", (object)chosenPlayer.Key)))
            };
            List <ShipSectionAsset> shipSectionAssetList3 = new List <ShipSectionAsset>()
            {
                this._app.AssetDatabase.ShipSections.First <ShipSectionAsset>((Func <ShipSectionAsset, bool>)(x => x.FileName == string.Format("factions\\{0}\\sections\\dn_eng_fusion.section", (object)chosenPlayer.Key)))
            };
            List <ShipSectionAsset> shipSectionAssetList4 = new List <ShipSectionAsset>()
            {
                this._app.AssetDatabase.ShipSections.First <ShipSectionAsset>((Func <ShipSectionAsset, bool>)(x => x.FileName == string.Format("factions\\{0}\\sections\\cr_cmd.section", (object)chosenPlayer.Key))),
                this._app.AssetDatabase.ShipSections.First <ShipSectionAsset>((Func <ShipSectionAsset, bool>)(x => x.FileName == string.Format("factions\\{0}\\sections\\cr_cmd_assault.section", (object)chosenPlayer.Key))),
                this._app.AssetDatabase.ShipSections.First <ShipSectionAsset>((Func <ShipSectionAsset, bool>)(x => x.FileName == string.Format("factions\\{0}\\sections\\cr_cmd_hammerhead.section", (object)chosenPlayer.Key)))
            };
            List <ShipSectionAsset> shipSectionAssetList5 = new List <ShipSectionAsset>()
            {
                this._app.AssetDatabase.ShipSections.First <ShipSectionAsset>((Func <ShipSectionAsset, bool>)(x => x.FileName == string.Format("factions\\{0}\\sections\\cr_mis_armor.section", (object)chosenPlayer.Key))),
                this._app.AssetDatabase.ShipSections.First <ShipSectionAsset>((Func <ShipSectionAsset, bool>)(x => x.FileName == string.Format("factions\\{0}\\sections\\cr_mis_blazer.section", (object)chosenPlayer.Key))),
                this._app.AssetDatabase.ShipSections.First <ShipSectionAsset>((Func <ShipSectionAsset, bool>)(x => x.FileName == string.Format("factions\\{0}\\sections\\cr_mis_cnc.section", (object)chosenPlayer.Key))),
                this._app.AssetDatabase.ShipSections.First <ShipSectionAsset>((Func <ShipSectionAsset, bool>)(x => x.FileName == string.Format("factions\\{0}\\sections\\cr_mis_barrage.section", (object)chosenPlayer.Key))),
                this._app.AssetDatabase.ShipSections.First <ShipSectionAsset>((Func <ShipSectionAsset, bool>)(x => x.FileName == string.Format("factions\\{0}\\sections\\cr_mis_projector.section", (object)chosenPlayer.Key)))
            };
            List <ShipSectionAsset> shipSectionAssetList6 = new List <ShipSectionAsset>()
            {
                this._app.AssetDatabase.ShipSections.First <ShipSectionAsset>((Func <ShipSectionAsset, bool>)(x => x.FileName == string.Format("factions\\{0}\\sections\\cr_eng_fusion.section", (object)chosenPlayer.Key)))
            };

            ShipSectionAsset[] shipSectionAssetArray = new ShipSectionAsset[3];
            if (this._rand.CoinToss(0.15) || ForceDread)
            {
                shipSectionAssetArray[0] = this._rand.Choose <ShipSectionAsset>((IList <ShipSectionAsset>)shipSectionAssetList2);
                shipSectionAssetArray[1] = this._rand.Choose <ShipSectionAsset>((IList <ShipSectionAsset>)shipSectionAssetList1);
                shipSectionAssetArray[2] = this._rand.Choose <ShipSectionAsset>((IList <ShipSectionAsset>)shipSectionAssetList3);
            }
            else
            {
                shipSectionAssetArray[0] = this._rand.Choose <ShipSectionAsset>((IList <ShipSectionAsset>)shipSectionAssetList4);
                shipSectionAssetArray[1] = this._rand.Choose <ShipSectionAsset>((IList <ShipSectionAsset>)shipSectionAssetList5);
                shipSectionAssetArray[2] = this._rand.Choose <ShipSectionAsset>((IList <ShipSectionAsset>)shipSectionAssetList6);
            }
            Ship ship = Ship.CreateShip(this._app, new CreateShipParams()
            {
                player           = chosenPlayer.Value,
                sections         = (IEnumerable <ShipSectionAsset>)shipSectionAssetArray,
                turretHousings   = this._app.AssetDatabase.TurretHousings,
                weapons          = this._app.AssetDatabase.Weapons,
                preferredWeapons = logicalWeapons,
                psionics         = this._app.AssetDatabase.Psionics,
                faction          = this._app.AssetDatabase.Factions.First <Faction>((Func <Faction, bool>)(x => x.Name == chosenPlayer.Key))
            });
            Vector3 vector3;

            ship.Position = vector3 = off;
            this._set.Add((IGameObject)ship);
            return(vector3);
        }
Пример #30
0
        public static XmlElement ExportXmlElementFromShipParameters(
            App game,
            XmlDocument owner,
            IEnumerable <string> sectionFileNames,
            IEnumerable <WeaponAssignment> weaponAssignments,
            IEnumerable <ModuleAssignment> moduleAssignments,
            int playerID,
            Vector3 position,
            Vector3 rotation)
        {
            XmlElement element1 = owner.CreateElement("GameObject", null);
            XmlElement element2 = owner.CreateElement("Type", null);

            element2.InnerText = "Ship";
            element1.AppendChild((XmlNode)element2);
            XmlElement element3 = owner.CreateElement("ShipName", null);

            element3.InnerText = sectionFileNames.Any <string>() ? Path.GetFileNameWithoutExtension(sectionFileNames.First <string>()) : "USS Placeholder";
            element1.AppendChild((XmlNode)element3);
            XmlElement element4 = owner.CreateElement("PlayerID", null);

            element4.InnerText = playerID.ToString();
            element1.AppendChild((XmlNode)element4);
            XmlElement element5 = owner.CreateElement("Position", null);

            element5.InnerText = position.ToString();
            element1.AppendChild((XmlNode)element5);
            XmlElement element6 = owner.CreateElement("Rotation", null);

            element6.InnerText = rotation.ToString();
            element1.AppendChild((XmlNode)element6);
            XmlElement element7 = owner.CreateElement("ShipDesign", null);
            XmlElement element8 = owner.CreateElement("Sections", null);

            foreach (string sectionFileName1 in sectionFileNames)
            {
                string           sectionFileName = sectionFileName1;
                ShipSectionAsset section         = game.AssetDatabase.ShipSections.First <ShipSectionAsset>((Func <ShipSectionAsset, bool>)(x => x.FileName == sectionFileName));
                XmlElement       element9        = owner.CreateElement("Section", null);
                XmlElement       element10       = owner.CreateElement("SectionFile", null);
                element10.InnerText = sectionFileName;
                element9.AppendChild((XmlNode)element10);
                List <ModuleAssignment> list = moduleAssignments.Where <ModuleAssignment>((Func <ModuleAssignment, bool>)(x => ((IEnumerable <LogicalModuleMount>)section.Modules).Contains <LogicalModuleMount>(x.ModuleMount))).ToList <ModuleAssignment>();
                foreach (ModuleAssignment moduleAssignment in list)
                {
                    XmlElement element11 = owner.CreateElement("Mount", null);
                    element11.InnerText = moduleAssignment.ModuleMount.NodeName;
                    XmlElement element12 = owner.CreateElement("ModuleId", null);
                    element12.InnerText = moduleAssignment.Module.ModulePath;
                    XmlElement element13 = owner.CreateElement("Module", null);
                    element13.AppendChild((XmlNode)element11);
                    element13.AppendChild((XmlNode)element12);
                    element9.AppendChild((XmlNode)element13);
                }
                List <LogicalBank> sectionBanks = ((IEnumerable <LogicalBank>)section.Banks).Concat <LogicalBank>(list.SelectMany <ModuleAssignment, LogicalBank>((Func <ModuleAssignment, IEnumerable <LogicalBank> >)(x => (IEnumerable <LogicalBank>)x.Module.Banks))).ToList <LogicalBank>();
                foreach (WeaponAssignment weaponAssignment in weaponAssignments.Where <WeaponAssignment>((Func <WeaponAssignment, bool>)(x => sectionBanks.Contains(x.Bank))))
                {
                    XmlElement element11 = owner.CreateElement("Id", null);
                    element11.InnerText = weaponAssignment.Bank.GUID.ToString();
                    XmlElement element12 = owner.CreateElement("Weapon", null);
                    element12.InnerText = weaponAssignment.Weapon.WeaponName;
                    XmlElement element13 = owner.CreateElement("Bank", null);
                    element13.AppendChild((XmlNode)element11);
                    element13.AppendChild((XmlNode)element12);
                    element9.AppendChild((XmlNode)element13);
                }
                element8.AppendChild((XmlNode)element9);
            }
            element7.AppendChild((XmlNode)element8);
            element1.AppendChild((XmlNode)element7);
            return(element1);
        }