Esempio n. 1
0
        public static MeteorShowerGlobalData.MeteorSizes GetMeteorSize(
            App game,
            int designID)
        {
            if (game.Game.ScriptModules.MeteorShower == null)
            {
                return(MeteorShowerGlobalData.MeteorSizes.Small);
            }
            DesignInfo designInfo = game.GameDatabase.GetDesignInfo(designID);

            if (designInfo != null)
            {
                DesignSectionInfo designSectionInfo = ((IEnumerable <DesignSectionInfo>)designInfo.DesignSections).FirstOrDefault <DesignSectionInfo>();
                if (designSectionInfo != null)
                {
                    if (designSectionInfo.ShipSectionAsset.FileName.Contains("Medium"))
                    {
                        return(MeteorShowerGlobalData.MeteorSizes.Medium);
                    }
                    if (designSectionInfo.ShipSectionAsset.FileName.Contains("Large"))
                    {
                        return(MeteorShowerGlobalData.MeteorSizes.Large);
                    }
                }
            }
            return(MeteorShowerGlobalData.MeteorSizes.Small);
        }
Esempio n. 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);
                 }
             }
         }
     }
 }
Esempio n. 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);
        }
Esempio n. 4
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);
        }
Esempio n. 5
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;
        }
Esempio n. 6
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);
        }
Esempio n. 7
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;
                        }
                    }
                }
            }
        }
Esempio n. 8
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);
 }
        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)))
            });
        }