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); }
private void RemoveDesign(int designid, bool listid = true) { int removedinex = 0; if (listid) { removedinex = this.SelectedDesigns[this.ListDesignMap[designid]]; if (this.SelectedDesigns.ContainsKey(this.ListDesignMap[designid])) { Dictionary <int, int> selectedDesigns; int listDesign; (selectedDesigns = this.SelectedDesigns)[listDesign = this.ListDesignMap[designid]] = selectedDesigns[listDesign] - 1; } designid = this.ListDesignMap[designid]; } else if (this.SelectedDesigns.ContainsKey(designid)) { Dictionary <int, int> selectedDesigns; int index; (selectedDesigns = this.SelectedDesigns)[index = designid] = selectedDesigns[index] - 1; } bool flag = false; foreach (DialogLoaFleetCompositor.RiderStruct riderStruct in this.RiderListMap.Where <DialogLoaFleetCompositor.RiderStruct>((Func <DialogLoaFleetCompositor.RiderStruct, bool>)(x => { if (x.CarrierDesignID == designid) { return(x.SelectedDesignCarrierKey == removedinex); } return(false); }))) { flag = true; foreach (DialogLoaFleetCompositor.RiderWingStruct riderWingStruct in riderStruct.WingData) { using (List <int> .Enumerator enumerator = riderWingStruct.riders.GetEnumerator()) { if (enumerator.MoveNext()) { this.RemoveDesign(enumerator.Current, false); } } } } if (flag) { this.RiderListMap.Remove(this.RiderListMap.First <DialogLoaFleetCompositor.RiderStruct>((Func <DialogLoaFleetCompositor.RiderStruct, bool>)(x => { if (x.CarrierDesignID == designid) { return(x.SelectedDesignCarrierKey == removedinex); } return(false); }))); } DesignInfo designInfo = this._app.GameDatabase.GetDesignInfo(designid); 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>((Func <int, bool>)(k => k == designid))); } 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>((Func <int, bool>)(k => k == designid))); } return(false); })); foreach (int slotIndex in riderWingStruct.wingdata.SlotIndexes) { riderWingStruct.riders.Remove(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); }