private Design makeDesign(StaticsDB statics, StatesDB states, PredefinedDesign predefDesign, Dictionary <string, double> techLevels, bool isVirtual) { var hull = statics.Hulls[predefDesign.HullCode].MakeHull(techLevels); var specials = predefDesign.SpecialEquipment.OrderBy(x => x.Key).Select( x => statics.SpecialEquipment[x.Key].MakeBest(techLevels, x.Value) ).ToList(); var armor = AComponentType.MakeBest(statics.Armors.Values, techLevels); var reactor = ReactorType.MakeBest(techLevels, hull, specials, statics); var isDrive = predefDesign.HasIsDrive ? IsDriveType.MakeBest(techLevels, hull, reactor, specials, statics) : null; var sensor = AComponentType.MakeBest(statics.Sensors.Values, techLevels); var shield = predefDesign.ShieldCode != null ? statics.Shields[predefDesign.ShieldCode].MakeBest(techLevels) : null; var equipment = predefDesign.MissionEquipment.Select( x => statics.MissionEquipment[x.Key].MakeBest(techLevels, x.Value) ).ToList(); var thruster = AComponentType.MakeBest(statics.Thrusters.Values, techLevels); var design = new Design( states.MakeDesignId(), Player, false, isVirtual, predefDesign.Name, predefDesign.HullImageIndex, armor, hull, isDrive, reactor, sensor, shield, equipment, specials, thruster ); design.CalcHash(statics); if (!states.Designs.Contains(design)) { states.Designs.Add(design); this.Analyze(design, statics); return(design); } return(states.Designs.First(x => x == design)); }
public Design DesignUpgrade(Design oldDesign, StaticsDB statics, StatesDB states) { var techLevels = states.DevelopmentAdvances.Of[Player].ToDictionary(x => x.Topic.IdCode, x => (double)x.Level); var hull = statics.Hulls[oldDesign.Hull.TypeInfo.IdCode].MakeHull(techLevels); var specials = oldDesign.SpecialEquipment.Select( x => statics.SpecialEquipment[x.TypeInfo.IdCode].MakeBest(techLevels, x.Quantity) ).ToList(); var armor = AComponentType.MakeBest(statics.Armors.Values, techLevels); var reactor = ReactorType.MakeBest(techLevels, hull, specials, statics); var isDrive = oldDesign.IsDrive != null?IsDriveType.MakeBest(techLevels, hull, reactor, specials, statics) : null; var sensor = AComponentType.MakeBest(statics.Sensors.Values, techLevels); var shield = oldDesign.Shield != null ? statics.Shields[oldDesign.Shield.TypeInfo.IdCode].MakeBest(techLevels) : null; var equipment = oldDesign.MissionEquipment.Select( x => statics.MissionEquipment[x.TypeInfo.IdCode].MakeBest(techLevels, x.Quantity) ).ToList(); var thruster = AComponentType.MakeBest(statics.Thrusters.Values, techLevels); var design = new Design( states.MakeDesignId(), Player, false, oldDesign.IsVirtual, oldDesign.Name, oldDesign.ImageIndex, armor, hull, isDrive, reactor, sensor, shield, equipment, specials, thruster ); design.CalcHash(statics); return(design); }