public void SetTech(App app, int TechID) { this._techID = TechID; string techid = app.GameDatabase.GetTechFileID(this._techID); int techId = this._techID; app.GameDatabase.GetPlayerTechInfo(app.LocalPlayer.ID, techId); Kerberos.Sots.Data.TechnologyFramework.Tech tech = app.AssetDatabase.MasterTechTree.Technologies.First <Kerberos.Sots.Data.TechnologyFramework.Tech>((Func <Kerberos.Sots.Data.TechnologyFramework.Tech, bool>)(x => x.Id == techid)); string spriteName1 = ResearchInfoPanel.IconTextureToSpriteName(tech.Icon); string spriteName2 = ResearchInfoPanel.IconTextureToSpriteName(app.AssetDatabase.MasterTechTree.TechFamilies.First <TechFamily>((Func <TechFamily, bool>)(x => x.Id == tech.Family)).Icon); app.UI.SetPropertyString("tech_title", "text", App.Localize("@TECH_NAME_" + tech.Id)); app.UI.SetPropertyString("techicon", "sprite", spriteName1); app.UI.SetPropertyString("familyicon", "sprite", spriteName2); app.UI.SetText("tech_desc", App.Localize("@TECH_DESC_" + tech.Id)); LogicalWeapon weaponUnlockedByTech = this.GetWeaponUnlockedByTech(app, tech); if (weaponUnlockedByTech != null) { app.UI.SetVisible("TechWeaponDetails", true); this._weaponinfopanel.SetWeapons(weaponUnlockedByTech, (LogicalWeapon)null); } else { app.UI.SetVisible("TechWeaponDetails", false); } }
public TargetArena(App game, string faction) { this._game = game; this._objects = new GameObjectSet(game); this._targetObjects = new GameObjectSet(game); this._faction = faction; this._targetPlayer = new Player(game, (GameSession)null, new PlayerInfo() { AvatarAssetPath = string.Empty, BadgeAssetPath = string.Empty, PrimaryColor = Vector3.One, SecondaryColor = Vector3.One }, Player.ClientTypes.AI); this._objects.Add((IGameObject)this._targetPlayer); Faction faction1 = game.AssetDatabase.Factions.FirstOrDefault <Faction>((Func <Faction, bool>)(x => x.Name == faction)) ?? game.AssetDatabase.Factions.First <Faction>(); LogicalWeapon weapon = game.AssetDatabase.Weapons.FirstOrDefault <LogicalWeapon>((Func <LogicalWeapon, bool>)(x => x.WeaponName == "Mis_Missile")); LogicalWeapon weapon1 = game.AssetDatabase.Weapons.FirstOrDefault <LogicalWeapon>((Func <LogicalWeapon, bool>)(x => x.WeaponName == weapon.SubWeapon)); WeaponModelPaths weaponModelPaths1 = LogicalWeapon.GetWeaponModelPaths(weapon, faction1); WeaponModelPaths weaponModelPaths2 = LogicalWeapon.GetWeaponModelPaths(weapon1, faction1); weapon.AddGameObjectReference(); this._launcher = game.AddObject <WeaponTestWeaponLauncher>(new List <object>() { (object)this._targetPlayer.ObjectID, (object)(weapon.GameObject != null ? weapon.GameObject.ObjectID : 0), (object)weaponModelPaths1.ModelPath, (object)weaponModelPaths2.ModelPath }.ToArray()); this._objects.Add((IGameObject)this._launcher); this.ResetTargets(); }
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); } } }
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); }
public void SetWeapons(LogicalWeapon primary, LogicalWeapon comparative) { WeaponRangeTable rangeTable1 = primary?.RangeTable; WeaponRangeTable rangeTable2 = comparative?.RangeTable; this._damageGraph.SetRangeTables(rangeTable1, rangeTable2); this._deviationGraph.SetRangeTables(rangeTable1, rangeTable2); this._scalarStats.SetWeapons(primary, comparative); this._primaryGroup.SetWeapon(primary); this._comparativeGroup.SetWeapon(comparative); }
private void SelectComparativeItem(string panelID) { LogicalWeapon logicalWeapon = this._selectedItem != null ? this._selectedItem.Weapon : (LogicalWeapon)null; WeaponSelectorItem weaponSelectorItem; if (logicalWeapon != null && !string.IsNullOrEmpty(panelID) && this._items.TryGetValue(panelID, out weaponSelectorItem)) { this._weaponInfo.SetWeapons(weaponSelectorItem.Weapon, logicalWeapon); } else { this._weaponInfo.SetWeapons(logicalWeapon, (LogicalWeapon)null); } }
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; } } } } }
public void FillOutModelFilesWithWeapon( LogicalWeapon weapon, Faction faction, IEnumerable <LogicalWeapon> weapons) { this.WeaponModelPath = LogicalWeapon.GetWeaponModelPaths(weapon, faction); LogicalWeapon subWeapon1 = weapon?.GetSubWeapon(weapons); LogicalWeapon secondaryWeapon = weapon?.GetSecondaryWeapon(weapons); LogicalWeapon subWeapon2 = secondaryWeapon?.GetSubWeapon(weapons); this.SubWeaponModelPath = LogicalWeapon.GetWeaponModelPaths(subWeapon1, faction); this.SecondaryWeaponModelPath = LogicalWeapon.GetWeaponModelPaths(secondaryWeapon, faction); this.SecondarySubWeaponModelPath = LogicalWeapon.GetWeaponModelPaths(subWeapon2, faction); }
private void SyncDesignTooltipByDesign(string panelId, int designID) { DesignInfo designInfo = this._game.GameDatabase.GetDesignInfo(designID); List <SectionEnumerations.DesignAttribute> list = this._game.GameDatabase.GetDesignAttributesForDesign(designInfo.ID).ToList <SectionEnumerations.DesignAttribute>(); List <int> intList = new List <int>(); foreach (DesignSectionInfo designSection in designInfo.DesignSections) { foreach (WeaponBankInfo weaponBank in designSection.WeaponBanks) { if (weaponBank.WeaponID.HasValue && !intList.Contains(weaponBank.WeaponID.Value)) { intList.Add(weaponBank.WeaponID.Value); } } } this.App.UI.SetText(this.App.UI.Path(panelId, "lblDesignName"), designInfo.Name); this.App.UI.SetText(this.App.UI.Path(panelId, "lblShipName"), ""); this.App.UI.SetText(this.App.UI.Path(panelId, "lblFirstSection"), ((IEnumerable <DesignSectionInfo>)designInfo.DesignSections).Count <DesignSectionInfo>() > 0 ? designInfo.DesignSections[0].ShipSectionAsset.Title : ""); this.App.UI.SetText(this.App.UI.Path(panelId, "lblSecondSection"), ((IEnumerable <DesignSectionInfo>)designInfo.DesignSections).Count <DesignSectionInfo>() > 1 ? designInfo.DesignSections[1].ShipSectionAsset.Title : ""); this.App.UI.SetText(this.App.UI.Path(panelId, "lblThirdSection"), ((IEnumerable <DesignSectionInfo>)designInfo.DesignSections).Count <DesignSectionInfo>() > 2 ? designInfo.DesignSections[2].ShipSectionAsset.Title : ""); this.App.UI.SetText(this.App.UI.Path(panelId, "lblAttributeName"), !designInfo.isAttributesDiscovered || list.Count <= 0 ? "" : App.Localize("@UI_" + list.First <SectionEnumerations.DesignAttribute>().ToString())); this.App.UI.SetText(this.App.UI.Path(panelId, "lblUpkeep"), GameSession.CalculateShipUpkeepCost(this._game.AssetDatabase, designInfo, 1f, false).ToString()); this.App.UI.SetText(this.App.UI.Path(panelId, "lblShipAge"), ""); this.App.UI.SetText(this.App.UI.Path(panelId, "lblSupply"), string.Format("{0}/{1}", (object)designInfo.SupplyRequired, (object)designInfo.SupplyAvailable)); this.App.UI.SetText(this.App.UI.Path(panelId, "lblPower"), string.Format("{0}/{1}", (object)designInfo.PowerRequired, (object)designInfo.PowerAvailable)); this.App.UI.SetText(this.App.UI.Path(panelId, "lblCrew"), string.Format("{0}/{1}", (object)designInfo.CrewRequired, (object)designInfo.CrewAvailable)); this.App.UI.SetText(this.App.UI.Path(panelId, "lblEndurance"), designInfo.GetEndurance(this._game.Game).ToString()); this.App.UI.ClearItems("lstWeaponIcons"); foreach (int num in intList) { string asset = this.App.GameDatabase.GetWeaponAsset(num); LogicalWeapon logicalWeapon = this.App.AssetDatabase.Weapons.FirstOrDefault <LogicalWeapon>((Func <LogicalWeapon, bool>)(x => x.FileName == asset)); if (logicalWeapon != null) { this.App.UI.AddItem("lstWeaponIcons", string.Empty, num, ""); this.App.UI.SetPropertyString(this.App.UI.Path(this.App.UI.GetItemGlobalID("lstWeaponIcons", string.Empty, num, ""), "imgWeaponIcon"), "sprite", logicalWeapon.IconSpriteName); } } float num1 = ShipTooltip.ArmorPanelShape.W / 2f; this.App.UI.SetShape("top_armor", 0, 0, (int)ShipTooltip.ArmorPanelShape.W, (int)num1); this.App.UI.SetShape("bottom_armor", 0, (int)num1, (int)ShipTooltip.ArmorPanelShape.W, (int)num1); this.App.UI.SetShape("left_armor", 0, 0, (int)num1, (int)ShipTooltip.ArmorPanelShape.H); this.App.UI.SetShape("right_armor", (int)num1, 0, (int)num1, (int)ShipTooltip.ArmorPanelShape.H); this._builder.New(this.App.GetPlayer(designInfo.PlayerID), designInfo, "The Ship You Wish your Ship was", 0, false); this._ready = false; this._activated = false; }
public void FillOutModelFilesWithWeapon( LogicalWeapon weapon, Faction faction, string preferredMount, IEnumerable <LogicalWeapon> weapons) { this.WeaponModelPath = Ship.GetWeaponModelPathsWithFixAssetNameForDLC(weapon, faction, preferredMount); LogicalWeapon subWeapon1 = weapon?.GetSubWeapon(weapons); LogicalWeapon secondaryWeapon = weapon?.GetSecondaryWeapon(weapons); LogicalWeapon subWeapon2 = secondaryWeapon?.GetSubWeapon(weapons); this.SubWeaponModelPath = Ship.GetWeaponModelPathsWithFixAssetNameForDLC(subWeapon1, faction, preferredMount); this.SecondaryWeaponModelPath = Ship.GetWeaponModelPathsWithFixAssetNameForDLC(secondaryWeapon, faction, preferredMount); this.SecondarySubWeaponModelPath = Ship.GetWeaponModelPathsWithFixAssetNameForDLC(subWeapon2, faction, preferredMount); }
public void SetAvailableWeapons(IEnumerable <LogicalWeapon> weapons, LogicalWeapon selected) { this.SetAvailableWeapons(weapons, true); if (selected != null) { this._weaponInfo.SetWeapons(selected, (LogicalWeapon)null); } WeaponSelectorItem weaponSelectorItem = this._items.Values.FirstOrDefault <WeaponSelectorItem>((Func <WeaponSelectorItem, bool>)(x => x.Weapon == selected)); if (weaponSelectorItem == null) { return; } this.SelectItem(weaponSelectorItem.ID, false, false); }
public override void Initialize() { this.m_Target = (IGameObject)null; this.m_VonNeumannMom = (VonNeumannMomControl)null; this.m_State = VonNeumannChildStates.SEEK; this.m_Vanished = false; this.m_RUStore = 0; this.m_Beam = (VonNeumannDisintegrationBeam)null; this.m_ApproachRange = 1000f; this.m_BeamWeapon = this.m_Game.AssetDatabase.Weapons.FirstOrDefault <LogicalWeapon>((Func <LogicalWeapon, bool>)(x => ((IEnumerable <WeaponEnums.WeaponTraits>)x.Traits).Any <WeaponEnums.WeaponTraits>((Func <WeaponEnums.WeaponTraits, bool>)(k => k == WeaponEnums.WeaponTraits.Disintegrating)))); if (this.m_BeamWeapon == null) { return; } this.m_BeamWeapon.AddGameObjectReference(); }
public void SetWeapon(LogicalWeapon weapon) { if (weapon != null) { this._titleImageLabel.Image.SetTexture(weapon.IconTextureName); this._titleImageLabel.Label.SetText(this._titlePrefix + weapon.Name); this._pointBlankRangeInfo.SetRangeInfo(weapon.RangeTable.PointBlank); this._effectiveRangeInfo.SetRangeInfo(weapon.RangeTable.Effective); this._maximumRangeInfo.SetRangeInfo(weapon.RangeTable.Maximum); } bool flag = weapon != null; this._titleImageLabel.SetVisible(flag); this._pointBlankRangeInfo.SetVisible(flag); this._effectiveRangeInfo.SetVisible(flag); this._maximumRangeInfo.SetVisible(flag); }
private static void ApplyWeaponStats(ShipCombatInfo sci, LogicalWeapon lw, int totalMounts) { if (lw == null || (double)lw.RechargeTime <= 0.0) { return; } float num = (float)(((double)lw.Duration > 0.0 ? (double)lw.Duration : 1.0) / (double)lw.RechargeTime * 60.0) * (float)totalMounts; if (lw.PayloadType == WeaponEnums.PayloadTypes.Missile || lw.PayloadType == WeaponEnums.PayloadTypes.Torpedo) { sci.trackingFireFactor += lw.RangeTable.Effective.Damage * num; } if (((IEnumerable <WeaponEnums.WeaponTraits>)lw.Traits).Contains <WeaponEnums.WeaponTraits>(WeaponEnums.WeaponTraits.PointDefence)) { sci.pdFactor += lw.RangeTable.Effective.Damage * num; } sci.directFireFactor = lw.RangeTable.PointBlank.Damage * num; sci.bombFactorPopulation += lw.PopDamage * num; sci.bombFactorInfrastructure += lw.InfraDamage * num; sci.bombFactorHazard += lw.TerraDamage * num; }
public void SetWeapons(LogicalWeapon primary, LogicalWeapon comparative) { bool flag = primary != null; this._rateOfFireLabel.Label.SetVisible(flag); this._popDamageLabel.Label.SetVisible(flag); this._infraDamageLabel.Label.SetVisible(flag); this._terraDamageLabel.Label.SetVisible(flag); if (primary == null) { return; } float num1 = primary.GetRateOfFire() * 60f; float popDamage1 = primary.PopDamage; float num2 = primary.InfraDamage * 100f; float terraDamage1 = primary.TerraDamage; if (comparative != null) { float num3 = comparative.GetRateOfFire() * 60f; float popDamage2 = comparative.PopDamage; float num4 = comparative.InfraDamage * 100f; float terraDamage2 = comparative.TerraDamage; float delta1 = num1 - num3; float delta2 = popDamage1 - popDamage2; float delta3 = num2 - num4; float delta4 = terraDamage1 - terraDamage2; this._rateOfFireLabel.Label.SetText(num1.ToString("N1") + WeaponScalarStats.GetSignSuffix(delta1)); this._popDamageLabel.Label.SetText(popDamage1.ToString("N0") + WeaponScalarStats.GetSignSuffix(delta2)); this._infraDamageLabel.Label.SetText(num2.ToString("N3") + WeaponScalarStats.GetSignSuffix(delta3)); this._terraDamageLabel.Label.SetText(terraDamage1.ToString("N2") + WeaponScalarStats.GetSignSuffix(delta4)); } else { this._rateOfFireLabel.Label.SetText(num1.ToString("N1")); this._popDamageLabel.Label.SetText(popDamage1.ToString("N0")); this._infraDamageLabel.Label.SetText(num2.ToString("N5")); this._terraDamageLabel.Label.SetText(terraDamage1.ToString("N2")); } }
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]; }
public static int GetWeaponLevelFromTechs(LogicalWeapon weapon, List <PlayerTechInfo> techs) { if (weapon == null || (!((IEnumerable <WeaponEnums.WeaponTraits>)weapon.Traits).Any <WeaponEnums.WeaponTraits>((Func <WeaponEnums.WeaponTraits, bool>)(x => x == WeaponEnums.WeaponTraits.Upgradable)) || techs.Count == 0)) { return(1); } switch (weapon.PayloadType) { case WeaponEnums.PayloadTypes.Missile: case WeaponEnums.PayloadTypes.BattleRider: PlayerTechInfo playerTechInfo1 = techs.FirstOrDefault <PlayerTechInfo>((Func <PlayerTechInfo, bool>)(x => x.TechFileID == "WAR_Anti-Matter_Warheads")); PlayerTechInfo playerTechInfo2 = techs.FirstOrDefault <PlayerTechInfo>((Func <PlayerTechInfo, bool>)(x => x.TechFileID == "WAR_Reflex_Warheads")); if (playerTechInfo2 != null && playerTechInfo2.State == TechStates.Researched) { return(3); } if (playerTechInfo1 != null && playerTechInfo1.State == TechStates.Researched) { return(2); } break; } return(1); }
public override void Initialize() { this.App.UI.HideTooltip(); this.Allshiptog = false; DesignInfo newestRetrofitDesign = Kerberos.Sots.StarFleet.StarFleet.GetNewestRetrofitDesign(this._ship.DesignInfo, this.App.GameDatabase.GetVisibleDesignInfosForPlayer(this.App.LocalPlayer.ID)); this.App.UI.SetText(this.App.UI.Path(this.ID, RetrofitShipDialog.currentnameID), this._ship.DesignInfo.Name); this.App.UI.SetText(this.App.UI.Path(this.ID, RetrofitShipDialog.retrofitnameID), newestRetrofitDesign.Name); this.App.UI.SetText(this.App.UI.Path(this.ID, RetrofitShipDialog.RetrofitCostID), Kerberos.Sots.StarFleet.StarFleet.CalculateRetrofitCost(this.App, this._ship.DesignInfo, newestRetrofitDesign).ToString()); this.App.UI.SetText(this.App.UI.Path(this.ID, RetrofitShipDialog.RetrofitTimeID), Kerberos.Sots.StarFleet.StarFleet.GetTimeRequiredToRetrofit(this.App, this._ship, 1).ToString()); this.App.GameDatabase.GetFleetInfo(this._ship.FleetID); List <ShipInfo> list = this.App.GameDatabase.GetShipInfoByFleetID(this._ship.FleetID, false).ToList <ShipInfo>(); List <int> intList = new List <int>(); foreach (ShipInfo shipInfo in list) { if (shipInfo.DesignID == this._ship.DesignID) { intList.Add(shipInfo.ID); } } if (Kerberos.Sots.StarFleet.StarFleet.FleetCanFunctionWithoutShips(this.App, this._ship.FleetID, (IEnumerable <int>)intList)) { this.App.UI.SetVisible(this.App.UI.Path(this.ID, "allships"), true); } else { this.App.UI.SetVisible(this.App.UI.Path(this.ID, "allships"), false); } if (this._weaponTooltip == null) { this._weaponTooltip = new WeaponHoverPanel(this.App.UI, this.App.UI.Path(this.ID, "WeaponPanel"), "weaponInfo"); } if (this._moduleTooltip == null) { this._moduleTooltip = new ModuleHoverPanel(this.App.UI, this.App.UI.Path(this.ID, "WeaponPanel"), "moduleInfo"); } List <LogicalWeapon> source1 = new List <LogicalWeapon>(); foreach (DesignSectionInfo designSection in newestRetrofitDesign.DesignSections) { foreach (WeaponBankInfo weaponBank in (IEnumerable <WeaponBankInfo>)designSection.WeaponBanks) { if (weaponBank.WeaponID.HasValue) { string weaponPath = this.App.GameDatabase.GetWeaponAsset(weaponBank.WeaponID.Value); LogicalWeapon weapon = this.App.AssetDatabase.Weapons.First <LogicalWeapon>((Func <LogicalWeapon, bool>)(x => x.FileName == weaponPath)); if (weapon != null && source1.Where <LogicalWeapon>((Func <LogicalWeapon, bool>)(x => x.FileName == weapon.FileName)).Count <LogicalWeapon>() == 0) { source1.Add(weapon); } } } } this._weaponTooltip.SetAvailableWeapons((IEnumerable <LogicalWeapon>)source1, true); List <LogicalModule> source2 = new List <LogicalModule>(); foreach (DesignSectionInfo designSection in newestRetrofitDesign.DesignSections) { foreach (DesignModuleInfo module1 in (IEnumerable <DesignModuleInfo>)designSection.Modules) { string modulePath = this.App.GameDatabase.GetModuleAsset(module1.ModuleID); LogicalModule module = this.App.AssetDatabase.Modules.First <LogicalModule>((Func <LogicalModule, bool>)(x => x.ModulePath == modulePath)); if (module != null && source2.Where <LogicalModule>((Func <LogicalModule, bool>)(x => x.ModulePath == module.ModulePath)).Count <LogicalModule>() == 0) { source2.Add(module); } } } this._moduleTooltip.SetAvailableModules((IEnumerable <LogicalModule>)source2, (LogicalModule)null, false); DesignInfo designInfo = this._ship.DesignInfo; if (this._oldweaponTooltip == null) { this._oldweaponTooltip = new WeaponHoverPanel(this.App.UI, this.App.UI.Path(this.ID, "OldWeaponPanel"), "oldweaponInfo"); } if (this._oldmoduleTooltip == null) { this._oldmoduleTooltip = new ModuleHoverPanel(this.App.UI, this.App.UI.Path(this.ID, "OldWeaponPanel"), "oldmoduleInfo"); } List <LogicalWeapon> source3 = new List <LogicalWeapon>(); foreach (DesignSectionInfo designSection in designInfo.DesignSections) { foreach (WeaponBankInfo weaponBank in (IEnumerable <WeaponBankInfo>)designSection.WeaponBanks) { if (weaponBank.WeaponID.HasValue) { string weaponPath = this.App.GameDatabase.GetWeaponAsset(weaponBank.WeaponID.Value); LogicalWeapon weapon = this.App.AssetDatabase.Weapons.First <LogicalWeapon>((Func <LogicalWeapon, bool>)(x => x.FileName == weaponPath)); if (weapon != null && source3.Where <LogicalWeapon>((Func <LogicalWeapon, bool>)(x => x.FileName == weapon.FileName)).Count <LogicalWeapon>() == 0) { source3.Add(weapon); } } } } this._oldweaponTooltip.SetAvailableWeapons((IEnumerable <LogicalWeapon>)source3, true); List <LogicalModule> source4 = new List <LogicalModule>(); foreach (DesignSectionInfo designSection in designInfo.DesignSections) { foreach (DesignModuleInfo module1 in (IEnumerable <DesignModuleInfo>)designSection.Modules) { string modulePath = this.App.GameDatabase.GetModuleAsset(module1.ModuleID); LogicalModule module = this.App.AssetDatabase.Modules.First <LogicalModule>((Func <LogicalModule, bool>)(x => x.ModulePath == modulePath)); if (module != null && source4.Where <LogicalModule>((Func <LogicalModule, bool>)(x => x.ModulePath == module.ModulePath)).Count <LogicalModule>() == 0) { source4.Add(module); } } } this._oldmoduleTooltip.SetAvailableModules((IEnumerable <LogicalModule>)source4, (LogicalModule)null, false); }
public static WeaponTechModifiers ObtainWeaponTechModifiers( AssetDatabase ab, WeaponEnums.TurretClasses tc, LogicalWeapon weapon, IEnumerable <PlayerTechInfo> playerTechs) { WeaponTechModifiers weaponTechModifiers = new WeaponTechModifiers(); weaponTechModifiers.DamageModifier = 0.0f; weaponTechModifiers.SpeedModifier = 0.0f; weaponTechModifiers.AccelModifier = 0.0f; weaponTechModifiers.MassModifier = 0.0f; weaponTechModifiers.ROFModifier = 1f; weaponTechModifiers.RangeModifier = 0.0f; weaponTechModifiers.SmartNanites = false; if (weapon == null || playerTechs == null || playerTechs.Count <PlayerTechInfo>() == 0) { return(weaponTechModifiers); } if (tc != WeaponEnums.TurretClasses.Torpedo && weapon.PayloadType == WeaponEnums.PayloadTypes.Bolt) { PlayerTechInfo playerTechInfo1 = playerTechs.FirstOrDefault <PlayerTechInfo>((Func <PlayerTechInfo, bool>)(x => x.TechFileID == "BAL_Neutronium_Rounds")); PlayerTechInfo playerTechInfo2 = playerTechs.FirstOrDefault <PlayerTechInfo>((Func <PlayerTechInfo, bool>)(x => x.TechFileID == "BAL_Acceleration_Amplification")); if (playerTechInfo1 != null && playerTechInfo1.State == TechStates.Researched) { weaponTechModifiers.DamageModifier += ab.GetTechBonus <float>(playerTechInfo1.TechFileID, "damage"); weaponTechModifiers.MassModifier += ab.GetTechBonus <float>(playerTechInfo1.TechFileID, "mass"); } if (playerTechInfo2 != null && playerTechInfo2.State == TechStates.Researched) { weaponTechModifiers.DamageModifier += ab.GetTechBonus <float>(playerTechInfo2.TechFileID, "damage"); weaponTechModifiers.SpeedModifier += ab.GetTechBonus <float>(playerTechInfo2.TechFileID, "speed"); } } if (weapon.PayloadType == WeaponEnums.PayloadTypes.Missile) { PlayerTechInfo playerTechInfo1 = playerTechs.FirstOrDefault <PlayerTechInfo>((Func <PlayerTechInfo, bool>)(x => x.TechFileID == "WAR_MicroFusion_Drives")); PlayerTechInfo playerTechInfo2 = playerTechs.FirstOrDefault <PlayerTechInfo>((Func <PlayerTechInfo, bool>)(x => x.TechFileID == "NRG_Ionic_Thruster")); if (playerTechInfo1 != null && playerTechInfo1.State == TechStates.Researched) { weaponTechModifiers.SpeedModifier += ab.GetTechBonus <float>(playerTechInfo1.TechFileID, "speed"); weaponTechModifiers.RangeModifier += ab.GetTechBonus <float>(playerTechInfo1.TechFileID, "range"); } if (playerTechInfo2 != null && playerTechInfo2.State == TechStates.Researched) { weaponTechModifiers.SpeedModifier += ab.GetTechBonus <float>(playerTechInfo2.TechFileID, "speed"); weaponTechModifiers.AccelModifier += ab.GetTechBonus <float>(playerTechInfo2.TechFileID, "accel"); } } if (weapon.PayloadType == WeaponEnums.PayloadTypes.Beam) { PlayerTechInfo playerTechInfo = playerTechs.FirstOrDefault <PlayerTechInfo>((Func <PlayerTechInfo, bool>)(x => x.TechFileID == "NRG_Quantum_Capacitors")); if (playerTechInfo != null && playerTechInfo.State == TechStates.Researched) { weaponTechModifiers.ROFModifier += ab.GetTechBonus <float>(playerTechInfo.TechFileID, "rateoffire"); } } if (((IEnumerable <WeaponEnums.WeaponTraits>)weapon.Traits).Contains <WeaponEnums.WeaponTraits>(WeaponEnums.WeaponTraits.Ballistic)) { PlayerTechInfo playerTechInfo = playerTechs.FirstOrDefault <PlayerTechInfo>((Func <PlayerTechInfo, bool>)(x => x.TechFileID == "BAL_VRF_Systems")); if (playerTechInfo != null && playerTechInfo.State == TechStates.Researched) { weaponTechModifiers.ROFModifier += ab.GetTechBonus <float>(playerTechInfo.TechFileID, "rateoffire"); } } if (((IEnumerable <WeaponEnums.WeaponTraits>)weapon.Traits).Contains <WeaponEnums.WeaponTraits>(WeaponEnums.WeaponTraits.Nanite)) { PlayerTechInfo playerTechInfo = playerTechs.FirstOrDefault <PlayerTechInfo>((Func <PlayerTechInfo, bool>)(x => x.TechFileID == "IND_Smart_Nanites")); weaponTechModifiers.SmartNanites = playerTechInfo != null && playerTechInfo.State == TechStates.Researched; } return(weaponTechModifiers); }
public override void Dispose() { base.Dispose(); this._weapon = (LogicalWeapon)null; }
public void FillOutCard() { Faction faction = this.App.AssetDatabase.GetFaction(this.App.GameDatabase.GetPlayerInfo(this.Design.PlayerID).FactionID); this.App.UI.SetText(this.App.UI.Path(this.ID, DesignDetailsCard.UIDesignName), this.Design.Name); this.App.UI.SetVisible(this.App.UI.Path(this.ID, DesignDetailsCard.UICrewPanel), (faction.Name != "loa" ? 1 : 0) != 0); this.App.UI.SetVisible(this.App.UI.Path(this.ID, "constructionBg"), (faction.Name == "loa" ? 1 : 0) != 0); this.App.UI.SetVisible(this.App.UI.Path(this.ID, "standardBg"), (faction.Name != "loa" ? 1 : 0) != 0); int crewAvailable = this.Design.CrewAvailable; int num1 = crewAvailable; int supplyAvailable = this.Design.SupplyAvailable; int num2 = supplyAvailable; int powerAvailable = this.Design.PowerAvailable; int num3 = powerAvailable; float scale = 1f; if (this.Ship != null) { num1 = 0; num2 = 0; foreach (SectionInstanceInfo sectionInstanceInfo in this.App.GameDatabase.GetShipSectionInstances(this.Ship.ID).ToList <SectionInstanceInfo>()) { num1 += sectionInstanceInfo.Crew; num2 += sectionInstanceInfo.Supply; } FleetInfo fleetInfo = this.App.GameDatabase.GetFleetInfo(this.Ship.FleetID); if (fleetInfo != null && this.App.GameDatabase.GetAdmiralTraits(fleetInfo.AdmiralID).Contains <AdmiralInfo.TraitType>(AdmiralInfo.TraitType.Elite)) { scale = this.App.AssetDatabase.EliteUpkeepCostScale; } } double shipUpkeepCost = GameSession.CalculateShipUpkeepCost(this.App.AssetDatabase, this.Design, scale, false); int endurance = this.Design.GetEndurance(this.App.Game); int playerProductionCost = this.Design.GetPlayerProductionCost(this.App.GameDatabase, this.Design.PlayerID, !this.Design.isPrototyped, new float?()); int savingsCost = this.Design.SavingsCost; this.App.UI.SetText(this.App.UI.Path(this.ID, DesignDetailsCard.UIShipCommandLabel), ""); this.App.UI.SetText(this.App.UI.Path(this.ID, DesignDetailsCard.UIShipMissionLabel), ""); this.App.UI.SetText(this.App.UI.Path(this.ID, DesignDetailsCard.UIShipEngineLabel), ""); List <int> intList = new List <int>(); foreach (DesignSectionInfo designSection in this.Design.DesignSections) { if (designSection.ShipSectionAsset.Type == ShipSectionType.Command) { this.App.UI.SetText(this.App.UI.Path(this.ID, DesignDetailsCard.UIShipCommandLabel), App.Localize(designSection.ShipSectionAsset.Title)); } else if (designSection.ShipSectionAsset.Type == ShipSectionType.Mission) { this.App.UI.SetText(this.App.UI.Path(this.ID, DesignDetailsCard.UIShipMissionLabel), App.Localize(designSection.ShipSectionAsset.Title)); } else if (designSection.ShipSectionAsset.Type == ShipSectionType.Engine) { this.App.UI.SetText(this.App.UI.Path(this.ID, DesignDetailsCard.UIShipEngineLabel), App.Localize(designSection.ShipSectionAsset.Title)); } foreach (WeaponBankInfo weaponBank in designSection.WeaponBanks) { if (weaponBank.WeaponID.HasValue && !intList.Contains(weaponBank.WeaponID.Value)) { intList.Add(weaponBank.WeaponID.Value); } } } this.App.UI.SetText(this.App.UI.Path(this.ID, DesignDetailsCard.UICrewValue), num1.ToString() + "/" + crewAvailable.ToString()); this.App.UI.SetText(this.App.UI.Path(this.ID, DesignDetailsCard.UISupplyValue), num2.ToString() + "/" + supplyAvailable.ToString()); this.App.UI.SetText(this.App.UI.Path(this.ID, DesignDetailsCard.UIPowerValue), num3.ToString() + "/" + powerAvailable.ToString()); this.App.UI.SetText(this.App.UI.Path(this.ID, DesignDetailsCard.UIUpkeepLabel), "Upkeep " + shipUpkeepCost.ToString()); this.App.UI.SetText(this.App.UI.Path(this.ID, DesignDetailsCard.UIEnduranceLabel), "Endurance " + endurance.ToString() + "T"); this.App.UI.SetText(this.App.UI.Path(this.ID, DesignDetailsCard.UIConstructionCostLabelValue), playerProductionCost.ToString("N0")); this.App.UI.SetText(this.App.UI.Path(this.ID, DesignDetailsCard.UIShipCostLabelValue), savingsCost.ToString("N0")); this.App.UI.ClearItems(DesignDetailsCard.ListWeaponIcons); foreach (int num4 in intList) { string asset = this.App.GameDatabase.GetWeaponAsset(num4); LogicalWeapon logicalWeapon = this.App.AssetDatabase.Weapons.FirstOrDefault <LogicalWeapon>((Func <LogicalWeapon, bool>)(x => x.FileName == asset)); if (logicalWeapon != null) { this.App.UI.AddItem(DesignDetailsCard.ListWeaponIcons, string.Empty, num4, ""); this.App.UI.SetPropertyString(this.App.UI.Path(this.App.UI.GetItemGlobalID(DesignDetailsCard.ListWeaponIcons, string.Empty, num4, ""), "imgWeaponIcon"), "sprite", logicalWeapon.IconSpriteName); } } }
private void SyncDesignTooltip(string panelId, int shipId) { ShipInfo shipInfo = this._game.GameDatabase.GetShipInfo(shipId, true); List <SectionEnumerations.DesignAttribute> list1 = this._game.GameDatabase.GetDesignAttributesForDesign(shipInfo.DesignInfo.ID).ToList <SectionEnumerations.DesignAttribute>(); FleetInfo fleetInfo = this._game.GameDatabase.GetFleetInfo(shipInfo.FleetID); List <int> intList = new List <int>(); foreach (DesignSectionInfo designSection in shipInfo.DesignInfo.DesignSections) { foreach (WeaponBankInfo weaponBank in designSection.WeaponBanks) { if (weaponBank.WeaponID.HasValue && !intList.Contains(weaponBank.WeaponID.Value)) { intList.Add(weaponBank.WeaponID.Value); } } } string str = ""; switch (shipInfo.DesignInfo.Class) { case ShipClass.Cruiser: str = App.Localize("@SHIPCLASSES_ABBR_CR"); break; case ShipClass.Dreadnought: str = App.Localize("@SHIPCLASSES_ABBR_DN"); break; case ShipClass.Leviathan: str = App.Localize("@SHIPCLASSES_ABBR_LV"); break; } this.App.UI.SetText(this.App.UI.Path(panelId, "lblDesignName"), shipInfo.ShipName); this.App.UI.SetText(this.App.UI.Path(panelId, "lblShipName"), str + " - " + shipInfo.DesignInfo.Name); this.App.UI.SetText(this.App.UI.Path(panelId, "lblFirstSection"), ""); this.App.UI.SetText(this.App.UI.Path(panelId, "lblSecondSection"), ""); this.App.UI.SetText(this.App.UI.Path(panelId, "lblThirdSection"), ""); foreach (DesignSectionInfo designSection in shipInfo.DesignInfo.DesignSections) { switch (designSection.ShipSectionAsset.Type) { case ShipSectionType.Command: this.App.UI.SetText(this.App.UI.Path(panelId, "lblFirstSection"), App.Localize(designSection.ShipSectionAsset.Title)); break; case ShipSectionType.Mission: this.App.UI.SetText(this.App.UI.Path(panelId, "lblSecondSection"), App.Localize(designSection.ShipSectionAsset.Title)); break; case ShipSectionType.Engine: this.App.UI.SetText(this.App.UI.Path(panelId, "lblThirdSection"), App.Localize(designSection.ShipSectionAsset.Title)); break; } } float scale = this.App.GameDatabase.GetAdmiralTraits(fleetInfo.AdmiralID).Contains <AdmiralInfo.TraitType>(AdmiralInfo.TraitType.Elite) ? this.App.AssetDatabase.EliteUpkeepCostScale : 1f; this.App.UI.SetText(this.App.UI.Path(panelId, "lblAttributeName"), !shipInfo.DesignInfo.isAttributesDiscovered || list1.Count <= 0 ? "" : App.Localize("@UI_" + list1.First <SectionEnumerations.DesignAttribute>().ToString())); this.App.UI.SetText(this.App.UI.Path(panelId, "lblUpkeep"), GameSession.CalculateShipUpkeepCost(this._game.AssetDatabase, shipInfo.DesignInfo, scale, fleetInfo.IsReserveFleet).ToString()); this.App.UI.SetText(this.App.UI.Path(panelId, "lblShipAge"), (this.App.GameDatabase.GetTurnCount() - shipInfo.ComissionDate).ToString() + " " + App.Localize("@UI_SHIPTOOLTIPAGE")); this.App.UI.SetText(this.App.UI.Path(panelId, "lblSupply"), string.Format("{0}/{1}", (object)shipInfo.DesignInfo.SupplyRequired, (object)shipInfo.DesignInfo.SupplyAvailable)); this.App.UI.SetText(this.App.UI.Path(panelId, "lblPower"), string.Format("{0}/{1}", (object)shipInfo.DesignInfo.PowerRequired, (object)shipInfo.DesignInfo.PowerAvailable)); this.App.UI.SetText(this.App.UI.Path(panelId, "lblCrew"), string.Format("{0}/{1}", (object)shipInfo.DesignInfo.CrewRequired, (object)shipInfo.DesignInfo.CrewAvailable)); this.App.UI.SetText(this.App.UI.Path(panelId, "lblEndurance"), shipInfo.DesignInfo.GetEndurance(this._game.Game).ToString()); this.App.UI.ClearItems("lstWeaponIcons"); foreach (int num in intList) { string asset = this.App.GameDatabase.GetWeaponAsset(num); LogicalWeapon logicalWeapon = this.App.AssetDatabase.Weapons.FirstOrDefault <LogicalWeapon>((Func <LogicalWeapon, bool>)(x => x.FileName == asset)); if (logicalWeapon != null) { this.App.UI.AddItem("lstWeaponIcons", string.Empty, num, ""); this.App.UI.SetPropertyString(this.App.UI.Path(this.App.UI.GetItemGlobalID("lstWeaponIcons", string.Empty, num, ""), "imgWeaponIcon"), "sprite", logicalWeapon.IconSpriteName); } } List <SectionInstanceInfo> list2 = this.App.GameDatabase.GetShipSectionInstances(shipInfo.ID).ToList <SectionInstanceInfo>(); Dictionary <ArmorSide, float> dictionary1 = new Dictionary <ArmorSide, float>(); Dictionary <ArmorSide, float> dictionary2 = new Dictionary <ArmorSide, float>(); if (list2.Count > 0) { ArmorSide[] values = (ArmorSide[])Enum.GetValues(typeof(ArmorSide)); foreach (SectionInstanceInfo sectionInstanceInfo in list2) { foreach (ArmorSide key in values) { if (key != ArmorSide.NumSides) { if (!dictionary1.ContainsKey(key)) { dictionary1.Add(key, 0.0f); } if (!dictionary2.ContainsKey(key)) { dictionary2.Add(key, 0.0f); } if (sectionInstanceInfo.Armor.ContainsKey(key)) { Dictionary <ArmorSide, float> dictionary3; ArmorSide index1; (dictionary3 = dictionary1)[index1 = key] = dictionary3[index1] + (float)sectionInstanceInfo.Armor[key].GetTotalFilled(); Dictionary <ArmorSide, float> dictionary4; ArmorSide index2; (dictionary4 = dictionary2)[index2 = key] = dictionary4[index2] + (float)sectionInstanceInfo.Armor[key].GetTotalPoints(); } } } } float num1 = (double)dictionary2[ArmorSide.Top] == 0.0 ? 1f : dictionary1[ArmorSide.Top] / dictionary2[ArmorSide.Top]; float num2 = (double)dictionary2[ArmorSide.Bottom] == 0.0 ? 1f : dictionary1[ArmorSide.Bottom] / dictionary2[ArmorSide.Bottom]; float num3 = (double)dictionary2[ArmorSide.Left] == 0.0 ? 1f : dictionary1[ArmorSide.Left] / dictionary2[ArmorSide.Left]; float num4 = (double)dictionary2[ArmorSide.Right] == 0.0 ? 1f : dictionary1[ArmorSide.Right] / dictionary2[ArmorSide.Right]; float num5 = ShipTooltip.ArmorPanelShape.W / 2f; this.App.UI.SetShape("top_armor", 0, (int)((double)num5 * (1.0 - (double)num1)), (int)ShipTooltip.ArmorPanelShape.W, (int)((double)num5 * (double)num1)); this.App.UI.SetShape("bottom_armor", 0, (int)num5, (int)ShipTooltip.ArmorPanelShape.W, (int)((double)num2 * (double)num5)); this.App.UI.SetShape("left_armor", (int)((double)num5 * (1.0 - (double)num3)), 0, (int)((double)num5 * (double)num3), (int)ShipTooltip.ArmorPanelShape.H); this.App.UI.SetShape("right_armor", (int)num5, 0, (int)((double)num5 * (double)num4), (int)ShipTooltip.ArmorPanelShape.H); } else { float num = ShipTooltip.ArmorPanelShape.W / 2f; this.App.UI.SetShape("top_armor", 0, 0, (int)ShipTooltip.ArmorPanelShape.W, (int)num); this.App.UI.SetShape("bottom_armor", 0, (int)num, (int)ShipTooltip.ArmorPanelShape.W, (int)num); this.App.UI.SetShape("left_armor", 0, 0, (int)num, (int)ShipTooltip.ArmorPanelShape.H); this.App.UI.SetShape("right_armor", (int)num, 0, (int)num, (int)ShipTooltip.ArmorPanelShape.H); } this._builder.New(this.App.GetPlayer(shipInfo.DesignInfo.PlayerID), shipInfo.DesignInfo, shipInfo.ShipName, shipInfo.SerialNumber, false); this._ready = false; this._activated = false; }
public override void Initialize() { CombatData combat = this._app.Game.CombatData.GetCombat(this._app.GameDatabase, this._combatID, this._systemID, this._turn); PlayerCombatData player1 = combat.GetPlayer(this._app.LocalPlayer.ID); if (player1 == null) { this._app.UI.CloseDialog((Dialog)this, true); } else { IEnumerable <PlayerInfo> playerInfos = this._app.GameDatabase.GetPlayerInfos(); StarSystemInfo starSystemInfo = this._app.GameDatabase.GetStarSystemInfo(combat.SystemID); string str1 = App.Localize("@ADMIRAL_LOCATION_DEEP_SPACE"); if (starSystemInfo != (StarSystemInfo)null) { str1 = starSystemInfo.Name; } this._app.UI.SetPropertyString("summaryText", "text", "Combat - " + player1.VictoryStatus.ToString() + " at " + str1); int num1 = 0; int num2 = 0; float val2_1 = 0.0f; float val2_2 = 0.0f; double num3 = 0.0; double num4 = 0.0; float num5 = 0.0f; double num6 = 0.0; double num7 = 0.0; float num8 = 0.0f; int num9 = 0; int num10 = 0; Dictionary <int, float> dictionary1 = new Dictionary <int, float>(); Dictionary <int, float> dictionary2 = new Dictionary <int, float>(); foreach (PlayerInfo playerInfo in playerInfos) { PlayerInfo player = playerInfo; PlayerCombatData player2 = combat.GetPlayer(player.ID); if (player2 != null) { DiplomacyInfo diplomacyInfo = this._app.GameDatabase.GetDiplomacyInfo(player1.PlayerID, player.ID); string itemGlobalId1; if (diplomacyInfo.State == DiplomacyState.WAR) { this._app.UI.AddItem("enemiesAvatars", "", player.ID, ""); itemGlobalId1 = this._app.UI.GetItemGlobalID("enemiesAvatars", "", player.ID, ""); } else { this._app.UI.AddItem("alliesAvatars", "", player.ID, ""); itemGlobalId1 = this._app.UI.GetItemGlobalID("alliesAvatars", "", player.ID, ""); } PlayerSetup playerSetup = this._app.GameSetup.Players.FirstOrDefault <PlayerSetup>((Func <PlayerSetup, bool>)(x => x.databaseId == player.ID)); string propertyValue = playerSetup == null ? player.Name : playerSetup.Name; this._app.UI.SetPropertyString(this._app.UI.Path(itemGlobalId1, "name"), "text", propertyValue); this._app.UI.SetPropertyString(this._app.UI.Path(itemGlobalId1, "playeravatar"), "texture", player.AvatarAssetPath); this._app.UI.SetPropertyString(this._app.UI.Path(itemGlobalId1, "badge"), "texture", player.BadgeAssetPath); this._app.UI.SetPropertyColorNormalized(this._app.UI.Path(itemGlobalId1, "primaryColor"), "color", player.PrimaryColor); this._app.UI.SetPropertyColorNormalized(this._app.UI.Path(itemGlobalId1, "secondaryColor"), "color", player.SecondaryColor); this._app.UI.AddItem("combatSummary", "", player.ID, ""); string itemGlobalId2 = this._app.UI.GetItemGlobalID("combatSummary", "", player.ID, ""); this._app.UI.SetPropertyString(this._app.UI.Path(itemGlobalId2, "itemName"), "text", propertyValue); List <ShipData> shipData1 = player2.ShipData; List <WeaponData> weaponData1 = player2.WeaponData; List <PlanetData> planetData1 = player2.PlanetData; int count = shipData1.Count; int num11 = 0; float val1_1 = 0.0f; float val1_2 = 0.0f; Dictionary <int, string> dictionary3 = new Dictionary <int, string>(); foreach (ShipData shipData2 in shipData1) { num11 += shipData2.killCount; val1_1 += shipData2.damageDealt; val1_2 += shipData2.damageReceived; if (diplomacyInfo.State == DiplomacyState.WAR) { num10 += shipData2.destroyed ? 1 : 0; } else { num9 += shipData2.destroyed ? 1 : 0; } if (!dictionary3.ContainsKey(shipData2.designID)) { this._app.UI.AddItem(this._app.UI.Path(itemGlobalId2, "shipList"), "", shipData2.designID, ""); dictionary3.Add(shipData2.designID, this._app.UI.GetItemGlobalID(this._app.UI.Path(itemGlobalId2, "shipList"), "", shipData2.designID, "")); } } foreach (WeaponData weaponData2 in weaponData1) { if (diplomacyInfo.State == DiplomacyState.WAR) { if (!dictionary2.ContainsKey(weaponData2.weaponID)) { dictionary2.Add(weaponData2.weaponID, 0.0f); } Dictionary <int, float> dictionary4; int weaponId; (dictionary4 = dictionary2)[weaponId = weaponData2.weaponID] = dictionary4[weaponId] + weaponData2.damageDealt; } else { if (!dictionary1.ContainsKey(weaponData2.weaponID)) { dictionary1.Add(weaponData2.weaponID, 0.0f); } Dictionary <int, float> dictionary4; int weaponId; (dictionary4 = dictionary1)[weaponId = weaponData2.weaponID] = dictionary4[weaponId] + weaponData2.damageDealt; } } foreach (PlanetData planetData2 in planetData1) { ColonyInfo colonyInfoForPlanet = this._app.GameDatabase.GetColonyInfoForPlanet(planetData2.orbitalObjectID); if (colonyInfoForPlanet != null) { if (colonyInfoForPlanet.PlayerID != this._app.LocalPlayer.ID) { num3 += planetData2.imperialDamage; num4 += planetData2.civilianDamage.Sum <PopulationData>((Func <PopulationData, double>)(x => x.damage)); num5 += planetData2.infrastructureDamage; } else { num6 += planetData2.imperialDamage; num7 += planetData2.civilianDamage.Sum <PopulationData>((Func <PopulationData, double>)(x => x.damage)); num8 += planetData2.infrastructureDamage; } } } foreach (int key in dictionary3.Keys) { int des = key; DesignInfo designInfo = this._app.GameDatabase.GetDesignInfo(des); int num12 = shipData1.Where <ShipData>((Func <ShipData, bool>)(x => x.designID == des)).Count <ShipData>(); this._app.UI.SetSliderRange(this._app.UI.Path(dictionary3[des], "stotalUnits"), 0, count); this._app.UI.SetSliderValue(this._app.UI.Path(dictionary3[des], "stotalUnits"), num12); this._app.UI.SetPropertyString(this._app.UI.Path(dictionary3[des], "stotalUnitsLabel"), "text", num12.ToString()); int num13 = shipData1.Where <ShipData>((Func <ShipData, bool>)(x => x.designID == des)).Sum <ShipData>((Func <ShipData, int>)(x => x.killCount)); this._app.UI.SetSliderRange(this._app.UI.Path(dictionary3[des], "sdestroyedUnits"), 0, num11); this._app.UI.SetSliderValue(this._app.UI.Path(dictionary3[des], "sdestroyedUnits"), num13); this._app.UI.SetPropertyString(this._app.UI.Path(dictionary3[des], "sdestroyedUnitsLabel"), "text", num13.ToString()); float num14 = shipData1.Where <ShipData>((Func <ShipData, bool>)(x => x.designID == des)).Sum <ShipData>((Func <ShipData, float>)(x => x.damageDealt)); this._app.UI.SetSliderRange(this._app.UI.Path(dictionary3[des], "sdamageInflicted"), 0, (int)val1_1); this._app.UI.SetSliderValue(this._app.UI.Path(dictionary3[des], "sdamageInflicted"), (int)num14); this._app.UI.SetPropertyString(this._app.UI.Path(dictionary3[des], "sdamageInflictedLabel"), "text", num14.ToString("N0")); float num15 = shipData1.Where <ShipData>((Func <ShipData, bool>)(x => x.designID == des)).Sum <ShipData>((Func <ShipData, float>)(x => x.damageReceived)); this._app.UI.SetSliderRange(this._app.UI.Path(dictionary3[des], "sdamageTaken"), 0, (int)val1_2); this._app.UI.SetSliderValue(this._app.UI.Path(dictionary3[des], "sdamageTaken"), (int)num15); this._app.UI.SetPropertyString(this._app.UI.Path(dictionary3[des], "sdamageTakenLabel"), "text", num15.ToString("N0")); this._app.UI.SetPropertyString(this._app.UI.Path(dictionary3[des], "subitem_label"), "text", designInfo.Name); } num1 = Math.Max(count, num1); num2 = Math.Max(num11, num2); val2_1 = Math.Max(val1_1, val2_1); val2_2 = Math.Max(val1_2, val2_2); this._app.UI.SetSliderRange(this._app.UI.Path(itemGlobalId2, "totalUnits"), 0, count); this._app.UI.SetSliderValue(this._app.UI.Path(itemGlobalId2, "totalUnits"), count); this._app.UI.SetPropertyString(this._app.UI.Path(itemGlobalId2, "totalUnitsLabel"), "text", count.ToString()); this._app.UI.SetSliderRange(this._app.UI.Path(itemGlobalId2, "destroyedUnits"), 0, num11); this._app.UI.SetSliderValue(this._app.UI.Path(itemGlobalId2, "destroyedUnits"), num11); this._app.UI.SetPropertyString(this._app.UI.Path(itemGlobalId2, "destroyedUnitsLabel"), "text", num11.ToString()); this._app.UI.SetSliderRange(this._app.UI.Path(itemGlobalId2, "damageInflicted"), 0, (int)val1_1); this._app.UI.SetSliderValue(this._app.UI.Path(itemGlobalId2, "damageInflicted"), (int)val1_1); this._app.UI.SetPropertyString(this._app.UI.Path(itemGlobalId2, "damageInflictedLabel"), "text", val1_1.ToString("N0")); this._app.UI.SetSliderRange(this._app.UI.Path(itemGlobalId2, "damageTaken"), 0, (int)val1_2); this._app.UI.SetSliderValue(this._app.UI.Path(itemGlobalId2, "damageTaken"), (int)val1_2); this._app.UI.SetPropertyString(this._app.UI.Path(itemGlobalId2, "damageTakenLabel"), "text", val1_2.ToString("N0")); } } foreach (PlayerInfo playerInfo in playerInfos) { if (combat.GetPlayer(playerInfo.ID) != null) { string itemGlobalId = this._app.UI.GetItemGlobalID("combatSummary", "", playerInfo.ID, ""); this._app.UI.SetSliderRange(this._app.UI.Path(itemGlobalId, "totalUnits"), 0, num1); this._app.UI.SetSliderRange(this._app.UI.Path(itemGlobalId, "destroyedUnits"), 0, num2); this._app.UI.SetSliderRange(this._app.UI.Path(itemGlobalId, "damageInflicted"), 0, (int)val2_1); this._app.UI.SetSliderRange(this._app.UI.Path(itemGlobalId, "damageTaken"), 0, (int)val2_2); } } foreach (int key in dictionary1.Keys) { int weapon = key; this._app.UI.AddItem("alliedWeaponList", "", weapon, ""); string itemGlobalId = this._app.UI.GetItemGlobalID("alliedWeaponList", "", weapon, ""); this._app.UI.SetPropertyString(this._app.UI.Path(itemGlobalId, "damageDealt"), "text", dictionary1[weapon].ToString("N0")); LogicalWeapon logicalWeapon = this._app.AssetDatabase.Weapons.First <LogicalWeapon>((Func <LogicalWeapon, bool>)(x => x.UniqueWeaponID == weapon)); string iconSpriteName = logicalWeapon.IconSpriteName; this._app.UI.SetPropertyString(this._app.UI.Path(itemGlobalId, "weaponIcon"), "sprite", iconSpriteName); this._app.UI.SetPropertyString(itemGlobalId, "tooltip", logicalWeapon.WeaponName); } foreach (int key in dictionary2.Keys) { int weapon = key; this._app.UI.AddItem("enemyWeaponList", "", weapon, ""); string itemGlobalId = this._app.UI.GetItemGlobalID("enemyWeaponList", "", weapon, ""); this._app.UI.SetPropertyString(this._app.UI.Path(itemGlobalId, "damageDealt"), "text", dictionary2[weapon].ToString("N0")); string iconSpriteName = this._app.AssetDatabase.Weapons.First <LogicalWeapon>((Func <LogicalWeapon, bool>)(x => x.UniqueWeaponID == weapon)).IconSpriteName; this._app.UI.SetPropertyString(this._app.UI.Path(itemGlobalId, "weaponIcon"), "sprite", iconSpriteName); } int num16 = 0; string text1 = ""; if (num7 > 0.0 && num6 > 0.0) { text1 = text1 + num6.ToString("N0") + " Imperialists and " + num7.ToString("N0") + " civilians lost. "; } else if (num7 > 0.0) { text1 = text1 + num7.ToString("N0") + " civilians lost. "; } else if (num6 > 0.0) { text1 = text1 + num6.ToString("N0") + " Imperialists lost. "; } if (num4 > 0.0 && num3 > 0.0) { text1 = text1 + num3.ToString("N0") + " enemy Imperialists and " + num4.ToString("N0") + " enemy civilians killed."; } else if (num4 > 0.0) { text1 = text1 + num4.ToString("N0") + " enemy civilians killed."; } else if (num3 > 0.0) { text1 = text1 + num3.ToString("N0") + " enemy Imperialists killed."; } if (text1.Length > 0) { this._app.UI.AddItem("happenings", "", num16++, text1); } string text2 = ""; float num17; if ((double)num8 > 0.01) { string str2 = text2; num17 = num8 * 100f; string str3 = num17.ToString("#0.00"); text2 = str2 + "Infrastructure reduced by " + str3 + "%"; } if ((double)num5 > 0.01) { string str2 = text2; num17 = num5 * 100f; string str3 = num17.ToString("#0.00"); text2 = str2 + " Enemy infrastructure reduced by " + str3 + "%"; } if (text2.Length > 0) { this._app.UI.AddItem("happenings", "", num16++, text2); } string str4 = ""; if (num9 > 0) { str4 = num9 <= 1 ? str4 + num9.ToString() + " friendly ship lost. " : str4 + num9.ToString() + " friendly ships lost. "; } if (num10 > 0) { str4 = num9 <= 1 ? str4 + num10.ToString() + " enemy ship destroyed." : str4 + num10.ToString() + " enemy ships destroyed."; } if (str4.Length <= 0) { return; } UICommChannel ui = this._app.UI; int userItemId = num16; int num18 = userItemId + 1; string text3 = str4; ui.AddItem("happenings", "", userItemId, text3); } }
public override void Initialize() { this.App.UI.HideTooltip(); this.BankDict = new Dictionary <string, int>(); this.ItemIDDict = new Dictionary <string, string>(); this.ModuleBankdict = new Dictionary <int, string>(); DesignInfo designInfo = this._ship.DesignInfo; if (designInfo.DesignSections[0].Modules.Any <DesignModuleInfo>((Func <DesignModuleInfo, bool>)(x => { ModuleEnums.StationModuleType?stationModuleType = x.StationModuleType; if ((stationModuleType.GetValueOrDefault() != ModuleEnums.StationModuleType.Combat ? 0 : (stationModuleType.HasValue ? 1 : 0)) != 0) { return(!x.WeaponID.HasValue); } return(false); }))) { this.UpdateStationDesignInfo(designInfo); this._app.GameDatabase.UpdateDesign(designInfo); } this.WorkingDesign = new DesignInfo(this._ship.DesignInfo.PlayerID, this._ship.DesignInfo.Name, new string[1] { this._ship.DesignInfo.DesignSections[0].FilePath }); this.WorkingDesign.StationLevel = designInfo.StationLevel; this.WorkingDesign.StationType = designInfo.StationType; DesignLab.SummarizeDesign(this._app.AssetDatabase, this._app.GameDatabase, this.WorkingDesign); this.WorkingDesign.DesignSections[0].Modules = new List <DesignModuleInfo>(); this.WorkingDesign.DesignSections[0].WeaponBanks = new List <WeaponBankInfo>(); this.WorkingDesign.DesignSections[0].Techs = new List <int>(); this.WorkingDesign.DesignSections[0].ShipSectionAsset = designInfo.DesignSections[0].ShipSectionAsset; int num = 0; foreach (DesignModuleInfo module in designInfo.DesignSections[0].Modules) { DesignModuleInfo designModuleInfo = new DesignModuleInfo() { MountNodeName = module.MountNodeName, ModuleID = module.ModuleID, WeaponID = module.WeaponID, DesignID = module.DesignID, StationModuleType = module.StationModuleType, ID = num }; ++num; this.WorkingDesign.DesignSections[0].Modules.Add(designModuleInfo); } this.UpdateStationDesignInfo(this.WorkingDesign); this.App.UI.ClearItems(this.App.UI.Path(this.ID, RetrofitStationDialog.RetrofitBankListID)); DesignLab.SummarizeDesign(this._app.AssetDatabase, this._app.GameDatabase, this.WorkingDesign); foreach (DesignSectionInfo designSection in this.WorkingDesign.DesignSections) { foreach (DesignModuleInfo module in designSection.Modules) { if (module.WeaponID.HasValue) { this.App.UI.AddItem(this.App.UI.Path(this.ID, RetrofitStationDialog.RetrofitBankListID), "", module.ID, ""); string itemGlobalId = this.App.UI.GetItemGlobalID(this.App.UI.Path(this.ID, RetrofitStationDialog.RetrofitBankListID), "", module.ID, ""); string asset = this.App.GameDatabase.GetWeaponAsset(module.WeaponID.Value); LogicalWeapon logicalWeapon = this.App.AssetDatabase.Weapons.First <LogicalWeapon>((Func <LogicalWeapon, bool>)(x => x.FileName == asset)); this.App.UI.SetPropertyString(this.App.UI.Path(itemGlobalId, "wepimg"), "sprite", logicalWeapon.IconSpriteName); string index = "retrofitButton|" + module.ID.ToString(); this.App.UI.SetPropertyString(this.App.UI.Path(itemGlobalId, "btnImageButton"), "id", index); if (!this.BankDict.ContainsKey(index)) { this.BankDict[index] = module.ID; } if (!this.ItemIDDict.ContainsKey(index)) { this.ItemIDDict[index] = itemGlobalId; } } } } this._weaponSelector = new WeaponSelector(this.App.UI, "gameWeaponSelector", ""); this.App.UI.SetParent(this._weaponSelector.ID, this.UI.Path(this.ID, "gameWeaponSelectorbox")); this._weaponSelector.SelectedWeaponChanged += new WeaponSelectionChangedEventHandler(this.WeaponSelectorSelectedWeaponChanged); StationInfo stationInfo = this.App.GameDatabase.GetStationInfosByPlayerID(this._ship.DesignInfo.PlayerID).FirstOrDefault <StationInfo>((Func <StationInfo, bool>)(x => x.ShipID == this._ship.ID)); if (stationInfo != null) { StationUI.SyncStationDetailsWidget(this.App.Game, this.UI.Path(this.ID, "stationDetails"), stationInfo.OrbitalObjectID, true); } this.UpdateUICostETA(); this.App.UI.SetEnabled(this.UI.Path(this.ID, "okButton"), (this.DesignChanged() ? 1 : 0) != 0); }
public void SyncEnemySide(int playerid) { CombatData combat = this._app.Game.CombatData.GetCombat(this._app.GameDatabase, this._combatID, this._systemID, this._turn); PlayerCombatData player1 = combat.GetPlayer(this._app.LocalPlayer.ID); if (player1 == null) { this._app.UI.CloseDialog((Dialog)this, true); } else { foreach (PlanetWidget sideplanetWidget in this._EnemySideplanetWidgets) { sideplanetWidget.Terminate(); } this._EnemySideplanetWidgets.Clear(); IEnumerable <PlayerInfo> playerInfos = this._app.GameDatabase.GetPlayerInfos(); StarSystemInfo starSystemInfo = this._app.GameDatabase.GetStarSystemInfo(combat.SystemID); App.Localize("@ADMIRAL_LOCATION_DEEP_SPACE"); if (starSystemInfo != (StarSystemInfo)null) { string name = starSystemInfo.Name; } int val2_1 = 0; int val2_2 = 0; float val2_3 = 0.0f; float val2_4 = 0.0f; double num1 = 0.0; double num2 = 0.0; float num3 = 0.0f; int num4 = 0; Dictionary <int, float> dictionary1 = new Dictionary <int, float>(); PlayerInfo player = playerInfos.FirstOrDefault <PlayerInfo>((Func <PlayerInfo, bool>)(x => x.ID == playerid)); PlayerCombatData player2 = combat.GetPlayer(player.ID); if (player2 != null) { this._app.GameDatabase.GetDiplomacyInfo(player1.PlayerID, player.ID); PlayerSetup playerSetup = this._app.GameSetup.Players.FirstOrDefault <PlayerSetup>((Func <PlayerSetup, bool>)(x => x.databaseId == player.ID)); string propertyValue1 = playerSetup == null || !(playerSetup.Name != "") || playerSetup.AI ? player.Name : playerSetup.Name; this._app.UI.SetPropertyString(this._app.UI.Path("enemySide", "alliesAvatars", "name"), "text", propertyValue1); this._app.UI.SetPropertyString(this._app.UI.Path("enemySide", "alliesAvatars", "playeravatar"), "texture", player.AvatarAssetPath); this._app.UI.SetPropertyString(this._app.UI.Path("enemySide", "alliesAvatars", "badge"), "texture", player.BadgeAssetPath); this._app.UI.SetPropertyColorNormalized(this._app.UI.Path("enemySide", "alliesAvatars", "primaryColor"), "color", player.PrimaryColor); this._app.UI.SetPropertyColorNormalized(this._app.UI.Path("enemySide", "alliesAvatars", "secondaryColor"), "color", player.SecondaryColor); this._app.UI.SetPropertyColorNormalized(this._app.UI.Path("enemySide", "empireColor"), "color", player.PrimaryColor); this._app.UI.SetPropertyString(this._app.UI.Path("enemySide", "playerData", "playerName"), "text", propertyValue1); List <ShipData> shipData1 = player2.ShipData; List <WeaponData> weaponData1 = player2.WeaponData; List <PlanetData> planetData1 = player2.PlanetData; int count = shipData1.Count; int val1_1 = 0; float val1_2 = 0.0f; float val1_3 = 0.0f; Dictionary <int, string> dictionary2 = new Dictionary <int, string>(); int userItemId1 = 0; this._app.UI.ClearItems(this._app.UI.Path("enemySide", "fleetDamage")); foreach (ShipData shipData2 in shipData1) { val1_1 += shipData2.killCount; val1_2 += shipData2.damageDealt; val1_3 += shipData2.damageReceived; num4 += shipData2.destroyed ? 1 : 0; DesignInfo designInfo = this._app.GameDatabase.GetDesignInfo(shipData2.designID); if (designInfo != null) { RealShipClasses?realShipClass = designInfo.GetRealShipClass(); if ((realShipClass.GetValueOrDefault() != RealShipClasses.AssaultShuttle ? 1 : (!realShipClass.HasValue ? 1 : 0)) != 0) { realShipClass = designInfo.GetRealShipClass(); if ((realShipClass.GetValueOrDefault() != RealShipClasses.Drone ? 1 : (!realShipClass.HasValue ? 1 : 0)) != 0) { realShipClass = designInfo.GetRealShipClass(); if ((realShipClass.GetValueOrDefault() != RealShipClasses.BoardingPod ? 1 : (!realShipClass.HasValue ? 1 : 0)) != 0 && this._app.Game.ScriptModules.MeteorShower.PlayerID != player.ID) { string propertyValue2 = ""; if (shipData2.destroyed) { propertyValue2 = designInfo.Name + " class ship has been destroyed."; } else if ((double)shipData2.damageReceived > 0.0) { propertyValue2 = designInfo.Name + " class ship has been damaged."; } if (propertyValue2 != "") { this._app.UI.AddItem(this._app.UI.Path("enemySide", "fleetDamage"), "", userItemId1, ""); this._app.UI.SetPropertyString(this._app.UI.Path(this._app.UI.GetItemGlobalID(this._app.UI.Path("enemySide", "fleetDamage"), "", userItemId1, ""), "name"), "text", propertyValue2); ++userItemId1; } } } } } } this._app.UI.SetPropertyString(this._app.UI.Path("enemySide", "playerData", "playerScore"), "text", (shipData1.Count - num4).ToString() + "/" + shipData1.Count.ToString()); this._app.UI.SetSliderRange(this._app.UI.Path("enemySide", "playerData", "assets"), 0, shipData1.Count); this._app.UI.SetSliderValue(this._app.UI.Path("enemySide", "playerData", "assets"), shipData1.Count - num4); foreach (WeaponData weaponData2 in weaponData1) { if (!dictionary1.ContainsKey(weaponData2.weaponID)) { dictionary1.Add(weaponData2.weaponID, 0.0f); } Dictionary <int, float> dictionary3; int weaponId; (dictionary3 = dictionary1)[weaponId = weaponData2.weaponID] = dictionary3[weaponId] + weaponData2.damageDealt; } this._app.UI.ClearItems(this._app.UI.Path("enemySide", "weaponDamage")); int num5 = 0; int userItemId2 = 0; string str = null; foreach (int key in dictionary1.Keys) { int weapon = key; if (num5 == 5 || str == null) { this._app.UI.AddItem(this._app.UI.Path("enemySide", "weaponDamage"), "", userItemId2, ""); str = this._app.UI.GetItemGlobalID(this._app.UI.Path("enemySide", "weaponDamage"), "", userItemId2, ""); ++userItemId2; num5 = 0; for (int index = 0; index < 5; ++index) { this._app.UI.SetVisible(this._app.UI.Path(str, "weapon" + index.ToString()), false); } } this._app.UI.SetPropertyString(this._app.UI.Path(str, "weapon" + num5.ToString(), "damageDealt"), "text", dictionary1[weapon].ToString("N0")); LogicalWeapon logicalWeapon = this._app.AssetDatabase.Weapons.First <LogicalWeapon>((Func <LogicalWeapon, bool>)(x => x.UniqueWeaponID == weapon)); string iconSpriteName = logicalWeapon.IconSpriteName; this._app.UI.SetPropertyString(this._app.UI.Path(str, "weapon" + num5.ToString(), "weaponIcon"), "sprite", iconSpriteName); this._app.UI.SetPropertyString(this._app.UI.Path(str, "weapon" + num5.ToString()), "tooltip", logicalWeapon.WeaponName); this._app.UI.SetVisible(this._app.UI.Path(str, "weapon" + num5.ToString()), true); ++num5; } this._app.UI.ClearItems(this._app.UI.Path("enemySide", "planetDamage")); foreach (PlanetData planetData2 in planetData1) { ColonyInfo colonyInfoForPlanet = this._app.GameDatabase.GetColonyInfoForPlanet(planetData2.orbitalObjectID); if (colonyInfoForPlanet != null) { num1 += planetData2.imperialDamage; num2 += planetData2.civilianDamage.Sum <PopulationData>((Func <PopulationData, double>)(x => x.damage)); num3 += planetData2.infrastructureDamage; this._app.UI.AddItem(this._app.UI.Path("enemySide", "planetDamage"), "", colonyInfoForPlanet.ID, ""); string itemGlobalId = this._app.UI.GetItemGlobalID(this._app.UI.Path("enemySide", "planetDamage"), "", colonyInfoForPlanet.ID, ""); OrbitalObjectInfo orbitalObjectInfo = this._app.GameDatabase.GetOrbitalObjectInfo(colonyInfoForPlanet.OrbitalObjectID); PlanetInfo planetInfo = this._app.GameDatabase.GetPlanetInfo(colonyInfoForPlanet.OrbitalObjectID); Faction faction = this._app.AssetDatabase.GetFaction(this._app.GameDatabase.GetPlayerFactionID(colonyInfoForPlanet.PlayerID)); double civilianPopulation = this._app.GameDatabase.GetCivilianPopulation(colonyInfoForPlanet.OrbitalObjectID, faction.ID, faction.HasSlaves()); float num6 = planetInfo != null ? planetInfo.Infrastructure : 0.0f; this._app.UI.SetPropertyString(this._app.UI.Path(itemGlobalId, "planetName"), "text", orbitalObjectInfo != null ? orbitalObjectInfo.Name : "?"); this._app.UI.SetPropertyString(this._app.UI.Path(itemGlobalId, "civslbl"), "text", civilianPopulation.ToString("N0")); this._app.UI.SetPropertyString(this._app.UI.Path(itemGlobalId, "implbl"), "text", colonyInfoForPlanet.ImperialPop.ToString("N0")); this._app.UI.SetPropertyString(this._app.UI.Path(itemGlobalId, "infralbl"), "text", num6.ToString()); double num7 = civilianPopulation + planetData2.civilianDamage.Sum <PopulationData>((Func <PopulationData, double>)(x => x.damage)); this._app.UI.SetSliderRange(this._app.UI.Path(itemGlobalId, "civAmount"), 0, (int)num7); this._app.UI.SetSliderValue(this._app.UI.Path(itemGlobalId, "civAmount"), (int)(num7 - planetData2.civilianDamage.Sum <PopulationData>((Func <PopulationData, double>)(x => x.damage)))); double num8 = colonyInfoForPlanet.ImperialPop + planetData2.imperialDamage; this._app.UI.SetSliderRange(this._app.UI.Path(itemGlobalId, "impAmount"), 0, (int)num8); this._app.UI.SetSliderValue(this._app.UI.Path(itemGlobalId, "impAmount"), (int)(num8 - planetData2.imperialDamage)); float num9 = num6 + planetData2.infrastructureDamage; this._app.UI.SetSliderRange(this._app.UI.Path(itemGlobalId, "infraAmount"), 0, (int)(100.0 * (double)num9)); this._app.UI.SetSliderValue(this._app.UI.Path(itemGlobalId, "infraAmount"), (int)(100.0 * ((double)num9 - (double)planetData2.infrastructureDamage))); if (planetInfo != null) { this._EnemySideplanetWidgets.Add(new PlanetWidget(this._app, itemGlobalId)); this._EnemySideplanetWidgets.Last <PlanetWidget>().Sync(planetInfo.ID, false, false); } } } Math.Max(count, val2_1); Math.Max(val1_1, val2_2); Math.Max(val1_2, val2_3); Math.Max(val1_3, val2_4); } this._app.UI.AutoSizeContents(this._app.UI.Path(this.ID, "enemySide")); } }
public Turret(App game, Turret.TurretDescription description) { List <SectionEnumerations.DesignAttribute> attributes = new List <SectionEnumerations.DesignAttribute>(); if (description.SInfo != null) { attributes = game.GameDatabase.GetDesignAttributesForDesign(description.SInfo.DesignID).ToList <SectionEnumerations.DesignAttribute>(); } List <object> objectList = new List <object>(); objectList.Add((object)description.Weapon.GameObject.ObjectID); objectList.Add((object)description.Ship.ObjectID); objectList.Add((object)description.Section.ObjectID); objectList.Add((object)(description.Module != null ? description.Module.ObjectID : 0)); objectList.Add((object)description.WeaponBank.ObjectID); objectList.Add((object)description.WeaponModels.WeaponModelPath.ModelPath); objectList.Add((object)description.WeaponModels.WeaponModelPath.DefaultModelPath); objectList.Add((object)description.WeaponModels.SubWeaponModelPath.ModelPath); objectList.Add((object)description.WeaponModels.SubWeaponModelPath.DefaultModelPath); objectList.Add((object)description.WeaponModels.SecondaryWeaponModelPath.ModelPath); objectList.Add((object)description.WeaponModels.SecondaryWeaponModelPath.DefaultModelPath); objectList.Add((object)description.WeaponModels.SecondarySubWeaponModelPath.ModelPath); objectList.Add((object)description.WeaponModels.SecondarySubWeaponModelPath.DefaultModelPath); objectList.Add((object)ScriptHost.AllowConsole); objectList.Add((object)(description.TurretBase != null ? description.TurretBase.ObjectID : 0)); objectList.Add((object)description.CollisionShapeRadius); objectList.Add((object)(description.TurretCollisionShape != null ? description.TurretCollisionShape.ObjectID : 0)); objectList.Add((object)description.TurretIndex); objectList.Add((object)(float)((double)description.MaxTurretHealth + (double)description.Weapon.Health)); objectList.Add((object)description.TurretHealth); objectList.Add((object)(float)((double)description.Housing.TrackSpeed + (double)description.Weapon.TrackSpeedModifier)); objectList.Add((object)this.CalcRateOfFire(attributes)); objectList.Add((object)description.Weapon.CritHitBonus); objectList.Add((object)this.CalcBallisticWeaponRangeModifier(attributes, 1f)); float num1 = 1f; float num2 = (description.Ship.RealShipClass == RealShipClasses.Drone ? 1.5f : 1f) * description.TechModifiers.ROFModifier; if (description.Ship.CombatAI == SectionEnumerations.CombatAiType.SwarmerQueen) { num2 *= 1.25f; } if (description.Fleet != null) { if (game.GameDatabase.GetAdmiralTraits(description.Fleet.AdmiralID).ToList <AdmiralInfo.TraitType>().Contains(AdmiralInfo.TraitType.DrillSergeant)) { num1 -= 0.1f; } if (description.Fleet.Type == FleetType.FL_NORMAL && (double)description.Fleet.SupplyRemaining == 0.0 && (((IEnumerable <WeaponEnums.WeaponTraits>)description.Weapon.Traits).Contains <WeaponEnums.WeaponTraits>(WeaponEnums.WeaponTraits.Ballistic) || description.Weapon.PayloadType == WeaponEnums.PayloadTypes.Missile)) { num2 *= 0.2f; } } objectList.Add((object)num2); objectList.Add((object)(float)((double)description.Ship.AccuracyModifier * (double)this.CalcAccuracyModifier(attributes) * (double)num1)); objectList.Add((object)description.Ship.PDAccuracyModifier); objectList.Add((object)description.Weapon.MalfunctionPercent); objectList.Add((object)description.Weapon.MalfunctionDamage); objectList.Add((object)description.TechModifiers.DamageModifier); objectList.Add((object)description.TechModifiers.SpeedModifier); objectList.Add((object)description.TechModifiers.AccelModifier); objectList.Add((object)description.TechModifiers.MassModifier); objectList.Add((object)description.TechModifiers.RangeModifier); objectList.Add((object)description.TechModifiers.SmartNanites); objectList.Add((object)description.TurretModelName); objectList.Add((object)description.BarrelModelName); objectList.Add((object)description.DestroyedTurretEffect.Name); objectList.Add((object)description.Mount.NodeName); objectList.Add((object)description.Mount.FireAnimName); objectList.Add((object)description.Mount.ReloadAnimName); objectList.Add((object)description.Weapon.SolutionTolerance); objectList.Add((object)description.Mount.Yaw.Min); objectList.Add((object)description.Mount.Yaw.Max); objectList.Add((object)description.Mount.Pitch.Min); objectList.Add((object)description.Mount.Pitch.Max); objectList.Add((object)description.LogicalBank.TurretSize); objectList.Add((object)description.LogicalBank.TurretClass); game.AddExistingObject((IGameObject)this, objectList.ToArray()); this._weapon = description.Weapon; this.ParentID = description.ParentObject.ObjectID; this.NodeName = description.Mount.NodeName; this.SetTag((object)description.Mount); }
private void PopulateWeaponSelector(List <LogicalWeapon> weapons, LogicalWeapon selected) { this.App.UI.MovePanelToMouse(this._weaponSelector.ID, UICommChannel.AnchorPoint.TopLeft, new Vector2(-4f, -4f)); this._weaponSelector.SetAvailableWeapons((IEnumerable <LogicalWeapon>)weapons.OrderBy <LogicalWeapon, WeaponEnums.WeaponSizes>((Func <LogicalWeapon, WeaponEnums.WeaponSizes>)(x => x.DefaultWeaponSize)), selected); this._weaponSelector.SetVisible(true); }
private void SyncFleet() { FleetInfo fleetInfo = this.App.GameDatabase.GetFleetInfo(this._syncedFleet); if (fleetInfo == null) { return; } IEnumerable <ShipInfo> shipInfoByFleetId = this.App.GameDatabase.GetShipInfoByFleetID(fleetInfo.ID, true); List <object> objectList = new List <object>(); int num1 = 0; foreach (ShipInfo shipInfo1 in shipInfoByFleetId) { ShipInfo ship = shipInfo1; bool flag1 = true; ++num1; objectList.Add((object)true); objectList.Add((object)ship.DesignID); objectList.Add((object)ship.ID); objectList.Add((object)ship.DesignInfo.Name); objectList.Add((object)ship.ShipName); bool flag2 = false; string str = ""; PlatformTypes?platformType = ship.DesignInfo.GetPlatformType(); bool flag3 = false; bool flag4 = ship.IsPoliceShip(); int defenseAssetCpCost = this.App.AssetDatabase.DefenseManagerSettings.GetDefenseAssetCPCost(ship.DesignInfo); if (ship.IsMinelayer()) { flag2 = true; foreach (DesignSectionInfo designSection in ship.DesignInfo.DesignSections) { foreach (WeaponBankInfo weaponBank in designSection.WeaponBanks) { string wasset = this.App.GameDatabase.GetWeaponAsset(weaponBank.WeaponID.Value); if (wasset.Contains("Min_")) { LogicalWeapon logicalWeapon = this.App.AssetDatabase.Weapons.FirstOrDefault <LogicalWeapon>((Func <LogicalWeapon, bool>)(x => x.FileName == wasset)); if (logicalWeapon != null) { str = logicalWeapon.IconSpriteName; break; } } } } } else if (ship.IsSDB()) { flag3 = true; } else if (ship.IsPoliceShip()) { flag4 = true; } objectList.Add((object)flag2); objectList.Add((object)flag3); objectList.Add((object)str); objectList.Add(platformType.HasValue ? (object)platformType.Value.ToString() : (object)string.Empty); objectList.Add((object)flag4); if (defenseAssetCpCost == 0) { objectList.Add((object)this.App.GameDatabase.GetShipCommandPointCost(ship.ID, true)); } else { objectList.Add((object)defenseAssetCpCost); } objectList.Add((object)this.App.GameDatabase.GetDesignCommandPointQuota(this.App.AssetDatabase, ship.DesignInfo.ID)); objectList.Add((object)flag1); int num2 = 0; int num3 = 0; int num4 = 0; int num5 = 0; int num6 = 0; int num7 = 0; ShipSectionAsset shipSectionAsset1 = (ShipSectionAsset)null; List <SectionInstanceInfo> list1 = this.App.GameDatabase.GetShipSectionInstances(ship.ID).ToList <SectionInstanceInfo>(); if (list1.Count != ship.DesignInfo.DesignSections.Length) { throw new InvalidDataException(string.Format("Mismatched design section vs ship section instance count for designId={0} and shipId={1}.", (object)ship.DesignInfo.ID, (object)ship.ID)); } for (int i = 0; i < ((IEnumerable <DesignSectionInfo>)ship.DesignInfo.DesignSections).Count <DesignSectionInfo>(); ++i) { if (list1.Count <= i) { App.Log.Warn("Tried syncing ship with no section", "game"); } else { ShipSectionAsset shipSectionAsset2 = this.App.AssetDatabase.GetShipSectionAsset(ship.DesignInfo.DesignSections[i].FilePath); if (shipSectionAsset2.Type == ShipSectionType.Mission) { shipSectionAsset1 = shipSectionAsset2; } SectionInstanceInfo sectionInstanceInfo = list1.First <SectionInstanceInfo>((Func <SectionInstanceInfo, bool>)(x => x.SectionID == ship.DesignInfo.DesignSections[i].ID)); num6 += shipSectionAsset2.ConstructionPoints; num7 += shipSectionAsset2.ColonizationSpace; num5 += shipSectionAsset2.Structure; num3 += shipSectionAsset2.RepairPoints; num4 += sectionInstanceInfo.Structure; num2 += sectionInstanceInfo.RepairPoints; Dictionary <ArmorSide, DamagePattern> armorInstances = this.App.GameDatabase.GetArmorInstances(sectionInstanceInfo.ID); if (armorInstances.Count > 0) { for (int index = 0; index < 4; ++index) { num5 += armorInstances[(ArmorSide)index].Width * armorInstances[(ArmorSide)index].Height * 3; for (int x = 0; x < armorInstances[(ArmorSide)index].Width; ++x) { for (int y = 0; y < armorInstances[(ArmorSide)index].Height; ++y) { if (!armorInstances[(ArmorSide)index].GetValue(x, y)) { num4 += 3; } } } } } List <ModuleInstanceInfo> list2 = this.App.GameDatabase.GetModuleInstances(sectionInstanceInfo.ID).ToList <ModuleInstanceInfo>(); List <DesignModuleInfo> module = ship.DesignInfo.DesignSections[i].Modules; for (int mod = 0; mod < module.Count; ++mod) { ModuleInstanceInfo moduleInstanceInfo = list2.First <ModuleInstanceInfo>((Func <ModuleInstanceInfo, bool>)(x => x.ModuleNodeID == module[mod].MountNodeName)); string modAsset = this.App.GameDatabase.GetModuleAsset(module[mod].ModuleID); LogicalModule logicalModule = this.App.AssetDatabase.Modules.Where <LogicalModule>((Func <LogicalModule, bool>)(x => x.ModulePath == modAsset)).First <LogicalModule>(); num5 += (int)logicalModule.Structure; num4 += moduleInstanceInfo.Structure; num3 += logicalModule.RepairPointsBonus; num2 += moduleInstanceInfo.RepairPoints; } foreach (WeaponInstanceInfo weaponInstanceInfo in this.App.GameDatabase.GetWeaponInstances(list1[i].ID).ToList <WeaponInstanceInfo>()) { num5 += (int)weaponInstanceInfo.MaxStructure; num4 += (int)weaponInstanceInfo.Structure; } } } objectList.Add((object)num4); objectList.Add((object)num5); objectList.Add((object)num2); objectList.Add((object)num3); objectList.Add((object)num6); objectList.Add((object)num7); IEnumerable <ShipInfo> ridersByParentId = this.App.GameDatabase.GetBattleRidersByParentID(ship.ID); objectList.Add((object)ridersByParentId.Count <ShipInfo>()); foreach (ShipInfo shipInfo2 in ridersByParentId) { objectList.Add((object)shipInfo2.ID); } objectList.Add((object)0); objectList.Add((object)shipSectionAsset1.RealClass); objectList.Add((object)shipSectionAsset1.BattleRiderType); Matrix?shipSystemPosition = this.App.GameDatabase.GetShipSystemPosition(ship.ID); objectList.Add((object)(shipSystemPosition.HasValue ? 1 : 0)); if (shipSystemPosition.HasValue) { objectList.Add((object)shipSystemPosition.Value); } } objectList.Insert(0, (object)num1); int systemDefensePoints = this.App.GameDatabase.GetSystemDefensePoints(fleetInfo.SystemID, this.App.LocalPlayer.ID); objectList.Insert(1, (object)systemDefensePoints); objectList.Insert(2, (object)fleetInfo.ID); this.PostSetProp("SyncShips", objectList.ToArray()); }
private void SyncLimitationGroup(LimitationTreatyType ltt) { this._app.UI.ClearItems("lstLimitationGroup"); switch (ltt) { case LimitationTreatyType.ShipClass: using (Dictionary <ShipClass, string> .Enumerator enumerator = TreatyEditDialog.ShipClassLimitationGroups.GetEnumerator()) { while (enumerator.MoveNext()) { KeyValuePair <ShipClass, string> current = enumerator.Current; this._app.UI.AddItem("lstLimitationGroup", string.Empty, (int)current.Key, App.Localize(current.Value)); } break; } case LimitationTreatyType.Weapon: using (IEnumerator <LogicalWeapon> enumerator = this._app.AssetDatabase.Weapons.GetEnumerator()) { while (enumerator.MoveNext()) { LogicalWeapon current = enumerator.Current; this._app.UI.AddItem("lstLimitationGroup", string.Empty, current.UniqueWeaponID, current.WeaponName); } break; } case LimitationTreatyType.ResearchTree: int userItemId = 0; using (List <TechFamily> .Enumerator enumerator = this._app.AssetDatabase.MasterTechTree.TechFamilies.GetEnumerator()) { while (enumerator.MoveNext()) { TechFamily current = enumerator.Current; this._app.UI.AddItem("lstLimitationGroup", string.Empty, userItemId, current.Name); ++userItemId; } break; } case LimitationTreatyType.ResearchTech: using (List <Tech> .Enumerator enumerator = this._app.AssetDatabase.MasterTechTree.Technologies.GetEnumerator()) { while (enumerator.MoveNext()) { Tech current = enumerator.Current; int techId = this._app.GameDatabase.GetTechID(current.Id); PlayerTechInfo playerTechInfo1 = this._app.GameDatabase.GetPlayerTechInfo(this._editedTreaty.InitiatingPlayerId, techId); PlayerTechInfo playerTechInfo2 = this._app.GameDatabase.GetPlayerTechInfo(this._editedTreaty.ReceivingPlayerId, techId); if (playerTechInfo1 != null && playerTechInfo1.State != TechStates.Researched && (playerTechInfo1.State != TechStates.Researching && playerTechInfo2 != null) && (playerTechInfo2.State != TechStates.Researched && playerTechInfo2.State != TechStates.Researching)) { this._app.UI.AddItem("lstLimitationGroup", string.Empty, techId, current.Name); } } break; } case LimitationTreatyType.StationType: using (Dictionary <StationType, string> .Enumerator enumerator = TreatyEditDialog.StationTypeLimitationGroups.GetEnumerator()) { while (enumerator.MoveNext()) { KeyValuePair <StationType, string> current = enumerator.Current; this._app.UI.AddItem("lstLimitationGroup", string.Empty, (int)current.Key, App.Localize(current.Value)); } break; } } }
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); }