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()); }
protected void SyncCompoShips(int Compositionid) { //DialogLoaFleetSelector.<> c__DisplayClass13 CS$<> 8__locals1 = new DialogLoaFleetSelector.<> c__DisplayClass13(); LoaFleetComposition loaFleetComposition = this._app.GameDatabase.GetLoaFleetCompositions().FirstOrDefault((LoaFleetComposition x) => x.ID == Compositionid); if (loaFleetComposition != null) { this.selectedcompo = new int?(Compositionid); List <DesignInfo> list = Kerberos.Sots.StarFleet.StarFleet.GetDesignBuildOrderForComposition(this._app.Game, this._basefleet.ID, loaFleetComposition, this._mission).ToList <DesignInfo>(); int fleetLoaCubeValue = Kerberos.Sots.StarFleet.StarFleet.GetFleetLoaCubeValue(this._app.Game, this._basefleet.ID); int num = 0; List <DesignInfo> list2 = (from X in list where X.Class == ShipClass.BattleRider select X).ToList <DesignInfo>(); this._app.UI.ClearItems(this._app.UI.Path(new string[] { base.ID, DialogLoaFleetSelector.UIShipList })); foreach (DesignInfo designInfo in list) { if (designInfo.Class != ShipClass.BattleRider && !(designInfo.GetRealShipClass() == RealShipClasses.BoardingPod) && !(designInfo.GetRealShipClass() == RealShipClasses.Drone) && !(designInfo.GetRealShipClass() == RealShipClasses.EscapePod)) { this._app.UI.AddItem(this._app.UI.Path(new string[] { base.ID, DialogLoaFleetSelector.UIShipList }), "", DialogLoaFleetSelector.designlistid, designInfo.Name); string itemGlobalID = this._app.UI.GetItemGlobalID(this._app.UI.Path(new string[] { base.ID, DialogLoaFleetSelector.UIShipList }), "", DialogLoaFleetSelector.designlistid, ""); this._app.UI.SetText(this._app.UI.Path(new string[] { itemGlobalID, "designName" }), designInfo.Name); this._app.UI.SetVisible(this._app.UI.Path(new string[] { itemGlobalID, "designDeleteButton" }), false); if (num + designInfo.GetPlayerProductionCost(this._app.GameDatabase, this._basefleet.PlayerID, false, null) <= fleetLoaCubeValue) { this._app.UI.SetPropertyColor(this._app.UI.Path(new string[] { itemGlobalID, "designName" }), "color", new Vector3(255f, 255f, 255f)); num += designInfo.GetPlayerProductionCost(this._app.GameDatabase, this._basefleet.PlayerID, false, null); } else { this._app.UI.SetPropertyColor(this._app.UI.Path(new string[] { itemGlobalID, "designName" }), "color", new Vector3(255f, 0f, 0f)); } DialogLoaFleetSelector.designlistid++; List <CarrierWingData> list3 = RiderManager.GetDesignBattleriderWingData(this._app, designInfo).ToList <CarrierWingData>(); using (List <CarrierWingData> .Enumerator enumerator2 = list3.GetEnumerator()) { while (enumerator2.MoveNext()) { //DialogLoaFleetSelector.<> c__DisplayClass16 CS$<> 8__locals2 = new DialogLoaFleetSelector.<> c__DisplayClass16(); //CS$<> 8__locals2.CS$<> 8__locals14 = CS$<> 8__locals1; CarrierWingData wd = enumerator2.Current; List <DesignInfo> classriders = (from x in list2 where StrategicAI.BattleRiderMountSet.GetMatchingTurretClass(x) == wd.Class select x).ToList <DesignInfo>(); if (classriders.Any <DesignInfo>() && wd.SlotIndexes.Any <int>()) { BattleRiderTypes SelectedType = (from x in classriders where classriders.Count((DesignInfo j) => j.ID == x.ID) >= wd.SlotIndexes.Count select x).First <DesignInfo>().GetMissionSectionAsset().BattleRiderType; DesignInfo designInfo2 = classriders.FirstOrDefault((DesignInfo x) => x.GetMissionSectionAsset().BattleRiderType == SelectedType && classriders.Count((DesignInfo j) => j.ID == x.ID) >= wd.SlotIndexes.Count); foreach (int num2 in wd.SlotIndexes) { if (designInfo2 != null) { this._app.UI.AddItem(this._app.UI.Path(new string[] { base.ID, DialogLoaFleetSelector.UIShipList }), "", DialogLoaFleetSelector.designlistid, designInfo2.Name); itemGlobalID = this._app.UI.GetItemGlobalID(this._app.UI.Path(new string[] { base.ID, DialogLoaFleetSelector.UIShipList }), "", DialogLoaFleetSelector.designlistid, ""); this._app.UI.SetText(this._app.UI.Path(new string[] { itemGlobalID, "designName" }), designInfo2.Name); this._app.UI.SetVisible(this._app.UI.Path(new string[] { itemGlobalID, "designDeleteButton" }), false); if (num + designInfo2.GetPlayerProductionCost(this._app.GameDatabase, this._basefleet.PlayerID, false, null) <= fleetLoaCubeValue) { this._app.UI.SetPropertyColor(this._app.UI.Path(new string[] { itemGlobalID, "designName" }), "color", new Vector3(255f, 255f, 255f)); num += designInfo2.GetPlayerProductionCost(this._app.GameDatabase, this._basefleet.PlayerID, false, null); } else { this._app.UI.SetPropertyColor(this._app.UI.Path(new string[] { itemGlobalID, "designName" }), "color", new Vector3(255f, 0f, 0f)); } list2.Remove(designInfo2); DialogLoaFleetSelector.designlistid++; } } } } } } } this.SyncCompoInfo(loaFleetComposition); } }
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); }