public override void Dispose() { base.Dispose(); this._bank = (LogicalBank)null; this._module = (Module)null; this._section = (Section)null; }
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 static bool IsRiderBank(LogicalBank bank) { switch (bank.TurretClass) { case WeaponEnums.TurretClasses.DestroyerRider: case WeaponEnums.TurretClasses.CruiserRider: case WeaponEnums.TurretClasses.DreadnoughtRider: return(true); default: return(false); } }
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); }
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))) }); }
private void SyncFleet(int fleetID) { this.App.GameDatabase.GetFleetInfo(fleetID); IEnumerable <ShipInfo> shipInfoByFleetId = this.App.GameDatabase.GetShipInfoByFleetID(fleetID, false); List <object> objectList = new List <object>(); int num1 = 0; foreach (ShipInfo shipInfo in shipInfoByFleetId) { DesignInfo designInfo = shipInfo.DesignInfo; int num2 = 0; int count1 = objectList.Count; BattleRiderTypes type = BattleRiderTypes.Unspecified; int num3 = 0; List <CarrierWingData> source = new List <CarrierWingData>(); foreach (DesignSectionInfo designSection in designInfo.DesignSections) { ShipSectionAsset shipSectionAsset = this.App.AssetDatabase.GetShipSectionAsset(designSection.FilePath); if (shipSectionAsset.Type == ShipSectionType.Mission) { type = shipSectionAsset.BattleRiderType; } num2 += RiderManager.GetNumRiderSlots(this.App, designSection); foreach (LogicalBank bank1 in shipSectionAsset.Banks) { LogicalBank bank = bank1; if (RiderManager.IsRiderBank(bank)) { List <LogicalMount> list = ((IEnumerable <LogicalMount>)shipSectionAsset.Mounts).Where <LogicalMount>((Func <LogicalMount, bool>)(x => x.Bank == bank)).ToList <LogicalMount>(); WeaponEnums.TurretClasses mountClass = bank.TurretClass; int count2 = list.Count; int riderSlotsPerSquad = BattleRiderSquad.GetMinRiderSlotsPerSquad(mountClass, designInfo.Class); int numRidersPerSquad = BattleRiderSquad.GetNumRidersPerSquad(mountClass, designInfo.Class, Math.Max(count2, riderSlotsPerSquad)); int num4 = numRidersPerSquad > count2 ? 1 : count2 / numRidersPerSquad; for (int index1 = 0; index1 < num4; ++index1) { int num5 = Math.Min(count2, numRidersPerSquad); List <int> intList = new List <int>(); for (int index2 = 0; index2 < num5; ++index2) { intList.Add(num3); ++num3; } CarrierWingData carrierWingData = source.FirstOrDefault <CarrierWingData>((Func <CarrierWingData, bool>)(x => { if (x.Class == mountClass) { return(x.SlotIndexes.Count < numRidersPerSquad); } return(false); })); if (carrierWingData != null) { carrierWingData.SlotIndexes.AddRange((IEnumerable <int>)intList); } else { source.Add(new CarrierWingData() { SlotIndexes = intList, Class = mountClass }); } } foreach (LogicalMount logicalMount in list) { objectList.Add((object)(int)bank.TurretClass); } } else if (WeaponEnums.IsWeaponBattleRider(bank.TurretClass)) { num3 += ((IEnumerable <LogicalMount>)shipSectionAsset.Mounts).Count <LogicalMount>((Func <LogicalMount, bool>)(x => x.Bank == bank)); } } foreach (DesignModuleInfo module in designSection.Modules) { string path = this.App.GameDatabase.GetModuleAsset(module.ModuleID); LogicalModule logicalModule = this.App.AssetDatabase.Modules.FirstOrDefault <LogicalModule>((Func <LogicalModule, bool>)(x => x.ModulePath == path)); foreach (LogicalBank bank1 in logicalModule.Banks) { LogicalBank bank = bank1; if (RiderManager.IsRiderBank(bank)) { List <LogicalMount> list = ((IEnumerable <LogicalMount>)logicalModule.Mounts).Where <LogicalMount>((Func <LogicalMount, bool>)(x => x.Bank == bank)).ToList <LogicalMount>(); int count2 = list.Count; List <int> intList = new List <int>(); for (int index = 0; index < count2; ++index) { intList.Add(num3); ++num3; } source.Add(new CarrierWingData() { SlotIndexes = intList, Class = bank.TurretClass, DefaultType = logicalModule.AbilityType == ModuleEnums.ModuleAbilities.KingfisherRider ? BattleRiderTypes.scout : BattleRiderTypes.Unspecified }); foreach (LogicalMount logicalMount in list) { objectList.Add((object)(int)bank.TurretClass); } } else if (WeaponEnums.IsWeaponBattleRider(bank.TurretClass)) { num3 += ((IEnumerable <LogicalMount>)logicalModule.Mounts).Count <LogicalMount>((Func <LogicalMount, bool>)(x => x.Bank == bank)); } } } } objectList.Insert(count1, (object)num2); int num6 = 0; string str1 = ""; string str2 = ""; foreach (DesignSectionInfo designSection in designInfo.DesignSections) { ShipSectionAsset shipSectionAsset = designSection.ShipSectionAsset; num6 += shipSectionAsset.ReserveSize; if (shipSectionAsset.Type == ShipSectionType.Mission) { str1 = App.Localize(shipSectionAsset.Title); } if (shipSectionAsset.Type == ShipSectionType.Engine) { str2 = App.Localize(shipSectionAsset.Title); } } if (num6 > 0 || num2 > 0 || type.IsBattleRiderType()) { objectList.Add((object)shipInfo.DesignID); objectList.Add((object)shipInfo.ID); objectList.Add((object)designInfo.Name); objectList.Add((object)shipInfo.ShipName); objectList.Add((object)num6); objectList.Add((object)(int)designInfo.Class); objectList.Add((object)(int)type); objectList.Add((object)shipInfo.ParentID); objectList.Add((object)shipInfo.RiderIndex); objectList.Add((object)str1); objectList.Add((object)str2); if (num2 > 0) { objectList.Add((object)source.Count); foreach (CarrierWingData carrierWingData in source) { objectList.Add((object)carrierWingData.SlotIndexes.Count); foreach (int slotIndex in carrierWingData.SlotIndexes) { objectList.Add((object)slotIndex); } objectList.Add((object)(int)carrierWingData.Class); objectList.Add((object)(int)carrierWingData.DefaultType); } } else if (num6 > 0) { objectList.Add((object)0); } ++num1; } else { objectList.RemoveRange(count1, objectList.Count - count1); } } objectList.Insert(0, (object)num1); this.PostSetProp("SyncShips", objectList.ToArray()); }
public static IEnumerable <CarrierWingData> GetDesignBattleriderWingData( App App, DesignInfo des) { int num1 = 0; int num2 = 0; List <CarrierWingData> source = new List <CarrierWingData>(); foreach (DesignSectionInfo designSection in des.DesignSections) { ShipSectionAsset shipSectionAsset = App.AssetDatabase.GetShipSectionAsset(designSection.FilePath); if (shipSectionAsset.Type == ShipSectionType.Mission) { int battleRiderType = (int)shipSectionAsset.BattleRiderType; } num1 += RiderManager.GetNumRiderSlots(App, designSection); foreach (LogicalBank bank1 in shipSectionAsset.Banks) { LogicalBank bank = bank1; if (RiderManager.IsRiderBank(bank)) { List <LogicalMount> list = ((IEnumerable <LogicalMount>)shipSectionAsset.Mounts).Where <LogicalMount>((Func <LogicalMount, bool>)(x => x.Bank == bank)).ToList <LogicalMount>(); WeaponEnums.TurretClasses mountClass = bank.TurretClass; int count = list.Count; int riderSlotsPerSquad = BattleRiderSquad.GetMinRiderSlotsPerSquad(mountClass, des.Class); int numRidersPerSquad = BattleRiderSquad.GetNumRidersPerSquad(mountClass, des.Class, Math.Max(count, riderSlotsPerSquad)); int num3 = numRidersPerSquad > count ? 1 : count / numRidersPerSquad; for (int index1 = 0; index1 < num3; ++index1) { int num4 = Math.Min(count, numRidersPerSquad); List <int> intList = new List <int>(); for (int index2 = 0; index2 < num4; ++index2) { intList.Add(num2); ++num2; } CarrierWingData carrierWingData = source.FirstOrDefault <CarrierWingData>((Func <CarrierWingData, bool>)(x => { if (x.Class == mountClass) { return(x.SlotIndexes.Count < numRidersPerSquad); } return(false); })); if (carrierWingData != null) { carrierWingData.SlotIndexes.AddRange((IEnumerable <int>)intList); } else { source.Add(new CarrierWingData() { SlotIndexes = intList, Class = mountClass }); } } } else if (WeaponEnums.IsWeaponBattleRider(bank.TurretClass)) { num2 += ((IEnumerable <LogicalMount>)shipSectionAsset.Mounts).Count <LogicalMount>((Func <LogicalMount, bool>)(x => x.Bank == bank)); } } foreach (DesignModuleInfo module in designSection.Modules) { string path = App.GameDatabase.GetModuleAsset(module.ModuleID); LogicalModule logicalModule = App.AssetDatabase.Modules.FirstOrDefault <LogicalModule>((Func <LogicalModule, bool>)(x => x.ModulePath == path)); foreach (LogicalBank bank1 in logicalModule.Banks) { LogicalBank bank = bank1; if (RiderManager.IsRiderBank(bank)) { int count = ((IEnumerable <LogicalMount>)logicalModule.Mounts).Where <LogicalMount>((Func <LogicalMount, bool>)(x => x.Bank == bank)).ToList <LogicalMount>().Count; List <int> intList = new List <int>(); for (int index = 0; index < count; ++index) { intList.Add(num2); ++num2; } source.Add(new CarrierWingData() { SlotIndexes = intList, Class = bank.TurretClass, DefaultType = logicalModule.AbilityType == ModuleEnums.ModuleAbilities.KingfisherRider ? BattleRiderTypes.scout : BattleRiderTypes.Unspecified }); } else if (WeaponEnums.IsWeaponBattleRider(bank.TurretClass)) { num2 += ((IEnumerable <LogicalMount>)logicalModule.Mounts).Count <LogicalMount>((Func <LogicalMount, bool>)(x => x.Bank == bank)); } } } } return((IEnumerable <CarrierWingData>)source); }
public ShipDummy(App game, CreateShipDummyParams dummyParams) { this.ShipID = dummyParams.ShipID; this._checkStatusBootstrapped = false; this._shipClass = dummyParams.Sections.First <ShipSectionAsset>().Class; ShipSectionAsset shipSectionAsset = dummyParams.Sections.FirstOrDefault <ShipSectionAsset>((Func <ShipSectionAsset, bool>)(x => x.Type == ShipSectionType.Mission)); ShipDummy.ShipDummyPart shipDummyPart1 = new ShipDummy.ShipDummyPart(); shipDummyPart1.Model = game.AddObject <StaticModel>((object)Ship.FixAssetNameForDLC(shipSectionAsset.ModelName, dummyParams.PreferredMount)); shipDummyPart1.IsSection = true; this._dummyParts.Add(shipDummyPart1); this._objects.Add((IGameObject)shipDummyPart1.Model); foreach (ShipSectionAsset section in dummyParams.Sections) { ShipDummy.ShipDummyPart sectionPart = shipDummyPart1; if (section != shipSectionAsset) { ShipDummy.ShipDummyPart shipDummyPart2 = new ShipDummy.ShipDummyPart(); shipDummyPart2.Model = game.AddObject <StaticModel>((object)Ship.FixAssetNameForDLC(section.ModelName, dummyParams.PreferredMount)); shipDummyPart2.AttachedModel = (IGameObject)shipDummyPart1.Model; shipDummyPart2.AttachedNodeName = section.Type.ToString(); shipDummyPart2.IsSection = true; this._dummyParts.Add(shipDummyPart2); this._objects.Add((IGameObject)shipDummyPart2.Model); sectionPart = shipDummyPart2; } for (int index = 0; index < section.Banks.Length; ++index) { LogicalBank bank = section.Banks[index]; this.AddTurretsToShipDummy(game, dummyParams.PreferredMount, dummyParams.ShipFaction, section, sectionPart, dummyParams.AssignedWeapons, dummyParams.PreferredWeapons, game.AssetDatabase.Weapons, game.AssetDatabase.TurretHousings, (LogicalModule)null, (ShipDummy.ShipDummyPart)null, bank); } for (int sectionModuleMountIndex = 0; sectionModuleMountIndex < section.Modules.Length; ++sectionModuleMountIndex) { LogicalModuleMount moduleMount = section.Modules[sectionModuleMountIndex]; if (dummyParams.AssignedModules != null) { LogicalModule module = (LogicalModule)null; ModuleAssignment moduleAssignment = dummyParams.AssignedModules.FirstOrDefault <ModuleAssignment>((Func <ModuleAssignment, bool>)(x => x.ModuleMount == moduleMount)); if (moduleAssignment != null) { module = moduleAssignment.Module; } if (module == null) { module = LogicalModule.EnumerateModuleFits(dummyParams.PreferredModules, section, sectionModuleMountIndex, false).FirstOrDefault <LogicalModule>(); } if (module != null) { ShipDummy.ShipDummyPart modulePart = new ShipDummy.ShipDummyPart(); modulePart.Model = game.AddObject <StaticModel>((object)module.ModelPath); modulePart.AttachedModel = (IGameObject)sectionPart.Model; modulePart.AttachedNodeName = moduleMount.NodeName; this._dummyParts.Add(modulePart); this._objects.Add((IGameObject)modulePart.Model); for (int index = 0; index < module.Banks.Length; ++index) { LogicalBank bank = module.Banks[index]; this.AddTurretsToShipDummy(game, dummyParams.PreferredMount, dummyParams.ShipFaction, section, sectionPart, dummyParams.AssignedWeapons, dummyParams.PreferredWeapons, game.AssetDatabase.Weapons, game.AssetDatabase.TurretHousings, module, modulePart, bank); } } } } } this._objects.Add((IGameObject)game.AddObject <RigidBody>((object)1f, (object)false)); }