public static int GetNumRiderSlots(App game, DesignSectionInfo info) { ShipSectionAsset shipSectionAsset = game.AssetDatabase.GetShipSectionAsset(info.FilePath); int num = 0; foreach (LogicalMount mount in shipSectionAsset.Mounts) { if (RiderManager.IsRiderMount(mount)) { ++num; } } foreach (DesignModuleInfo module in info.Modules) { string path = game.GameDatabase.GetModuleAsset(module.ModuleID); foreach (LogicalMount mount in game.AssetDatabase.Modules.FirstOrDefault <LogicalModule>((Func <LogicalModule, bool>)(x => x.ModulePath == path)).Mounts) { if (RiderManager.IsRiderMount(mount)) { ++num; } } } return(num); }
public List <int> GetSyncedShips() { List <int> intList = new List <int>(); foreach (int syncedFleet in this._syncedFleets) { this.App.GameDatabase.GetFleetInfo(syncedFleet); foreach (ShipInfo shipInfo in this.App.GameDatabase.GetShipInfoByFleetID(syncedFleet, false)) { DesignInfo designInfo = shipInfo.DesignInfo; int num1 = 0; BattleRiderTypes type = BattleRiderTypes.Unspecified; foreach (DesignSectionInfo designSection in designInfo.DesignSections) { ShipSectionAsset shipSectionAsset = designSection.ShipSectionAsset; if (shipSectionAsset.BattleRiderType != BattleRiderTypes.Unspecified) { type = shipSectionAsset.BattleRiderType; } num1 += RiderManager.GetNumRiderSlots(this.App, designSection); } int num2 = 0; foreach (DesignSectionInfo designSection in designInfo.DesignSections) { ShipSectionAsset shipSectionAsset = designSection.ShipSectionAsset; num2 += shipSectionAsset.ReserveSize; } if (num2 > 0 || num1 > 0 || type.IsBattleRiderType()) { intList.Add(shipInfo.ID); } } } return(intList); }
protected void SyncCompoInfo(LoaFleetComposition composition) { List <DesignInfo> source = new List <DesignInfo>(); foreach (int designID in composition.designs.Select <LoaFleetShipDef, int>((Func <LoaFleetShipDef, int>)(x => x.DesignID))) { source.Add(this._app.GameDatabase.GetDesignInfo(designID)); } int num1 = 0; int num2 = 0; foreach (DesignInfo designInfo in source) { RealShipClasses?realShipClass1 = designInfo.GetRealShipClass(); if ((realShipClass1.GetValueOrDefault() != RealShipClasses.BoardingPod ? 0 : (realShipClass1.HasValue ? 1 : 0)) == 0) { RealShipClasses?realShipClass2 = designInfo.GetRealShipClass(); if ((realShipClass2.GetValueOrDefault() != RealShipClasses.Drone ? 0 : (realShipClass2.HasValue ? 1 : 0)) == 0) { RealShipClasses?realShipClass3 = designInfo.GetRealShipClass(); if ((realShipClass3.GetValueOrDefault() != RealShipClasses.EscapePod ? 0 : (realShipClass3.HasValue ? 1 : 0)) == 0) { foreach (DesignSectionInfo designSection in designInfo.DesignSections) { num1 += RiderManager.GetNumRiderSlots(this._app, designSection); } if (designInfo.Class == ShipClass.BattleRider) { ++num2; } } } } } this._app.UI.SetText(this._app.UI.Path(this.ID, DialogLoaFleetSelector.UIBRAmount), num2.ToString() + "/" + num1.ToString()); this._app.UI.SetText(this._app.UI.Path(this.ID, "totalShipsAmount"), source.Count <DesignInfo>().ToString()); this._app.UI.SetText(this._app.UI.Path(this.ID, DialogLoaFleetSelector.UICRAmount), source.Count <DesignInfo>((Func <DesignInfo, bool>)(x => x.Class == ShipClass.Cruiser)).ToString()); this._app.UI.SetText(this._app.UI.Path(this.ID, DialogLoaFleetSelector.UIDNAmount), source.Count <DesignInfo>((Func <DesignInfo, bool>)(x => x.Class == ShipClass.Dreadnought)).ToString()); this._app.UI.SetText(this._app.UI.Path(this.ID, DialogLoaFleetSelector.UILVAmount), source.Count <DesignInfo>((Func <DesignInfo, bool>)(x => x.Class == ShipClass.Leviathan)).ToString()); int num3 = 0; int num4 = 0; int num5 = 0; bool flag = false; foreach (DesignInfo designInfo in source) { num4 += designInfo.CommandPointCost; if (designInfo.GetCommandPoints() > 0 && !flag) { num5 += this._app.GameDatabase.GetDesignCommandPointQuota(this._app.AssetDatabase, designInfo.ID); flag = true; } num3 += designInfo.GetPlayerProductionCost(this._app.GameDatabase, this._basefleet.PlayerID, false, new float?()); } this._app.UI.SetText(this._app.UI.Path(this.ID, DialogLoaFleetSelector.UICPAmount), num4.ToString("N0") + "/" + num5.ToString("N0")); this._app.UI.SetText(this._app.UI.Path(this.ID, DialogLoaFleetSelector.UIConstrictionPoints), num3.ToString("N0") + "/" + Kerberos.Sots.StarFleet.StarFleet.GetFleetLoaCubeValue(this._app.Game, this._basefleet.ID).ToString("N0")); }
private void AddDesign(int designid) { DesignInfo designInfo = this._app.GameDatabase.GetDesignInfo(designid); if (designInfo.Class == ShipClass.BattleRider && !this.CanMountBattleRider(designInfo)) { return; } if (!this.SelectedDesigns.ContainsKey(designid)) { this.SelectedDesigns.Add(designid, 1); } else { Dictionary <int, int> selectedDesigns; int index; (selectedDesigns = this.SelectedDesigns)[index = designid] = selectedDesigns[index] + 1; } int selectedDesign = this.SelectedDesigns[designid]; List <CarrierWingData> list = RiderManager.GetDesignBattleriderWingData(this._app, designInfo).ToList <CarrierWingData>(); if (list.Any <CarrierWingData>()) { DialogLoaFleetCompositor.RiderStruct riderStruct = new DialogLoaFleetCompositor.RiderStruct(); foreach (CarrierWingData carrierWingData in list) { riderStruct.WingData.Add(new DialogLoaFleetCompositor.RiderWingStruct() { wingdata = carrierWingData }); } riderStruct.CarrierDesignID = designid; riderStruct.SelectedDesignCarrierKey = selectedDesign; this.RiderListMap.Add(riderStruct); } if (designInfo.Class != ShipClass.BattleRider) { return; } WeaponEnums.TurretClasses? turretclass = StrategicAI.BattleRiderMountSet.GetMatchingTurretClass(designInfo); DialogLoaFleetCompositor.RiderStruct riderStruct1 = this.RiderListMap.FirstOrDefault <DialogLoaFleetCompositor.RiderStruct>((Func <DialogLoaFleetCompositor.RiderStruct, bool>)(x => x.WingData.Any <DialogLoaFleetCompositor.RiderWingStruct>((Func <DialogLoaFleetCompositor.RiderWingStruct, bool>)(j => { WeaponEnums.TurretClasses turretClasses = j.wingdata.Class; WeaponEnums.TurretClasses?nullable = turretclass; if ((turretClasses != nullable.GetValueOrDefault() ? 0 : (nullable.HasValue ? 1 : 0)) != 0) { return(!j.riders.Any <int>()); } return(false); })))); if (riderStruct1 != null) { DialogLoaFleetCompositor.RiderWingStruct riderWingStruct = riderStruct1.WingData.First <DialogLoaFleetCompositor.RiderWingStruct>((Func <DialogLoaFleetCompositor.RiderWingStruct, bool>)(x => { WeaponEnums.TurretClasses turretClasses = x.wingdata.Class; WeaponEnums.TurretClasses?nullable = turretclass; if ((turretClasses != nullable.GetValueOrDefault() ? 0 : (nullable.HasValue ? 1 : 0)) != 0) { return(!x.riders.Any <int>()); } return(false); })); foreach (int slotIndex in riderWingStruct.wingdata.SlotIndexes) { riderWingStruct.riders.Add(designid); } Dictionary <int, int> selectedDesigns; int index; (selectedDesigns = this.SelectedDesigns)[index = designid] = selectedDesigns[index] + (riderWingStruct.wingdata.SlotIndexes.Count - 1); } if (this.SelectedClass != RealShipClasses.BattleRider && this.SelectedClass != RealShipClasses.BattleShip && this.SelectedClass != RealShipClasses.BattleCruiser) { return; } this.SyncDesignListList(this.SelectedClass); }
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); } }
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 static bool IsRiderMount(LogicalMount mount) { return(RiderManager.IsRiderBank(mount.Bank)); }