private Planet(IkonComposite rawData, ObjectDeindexer deindexer) { var starSave = rawData[StarKey]; this.Star = deindexer.Get <StarData>(starSave.To <int>()); var positionSave = rawData[PositionKey]; this.Position = positionSave.To <int>(); var typeSave = rawData[TypeKey]; this.Type = (PlanetType)Enum.Parse(typeof(PlanetType), (string)typeSave.Tag); var sizeSave = rawData[SizeKey]; this.Size = sizeSave.To <double>(); var traitsSave = rawData[TraitsKey]; this.Traits = new PendableSet <BodyTrait>(); foreach (var item in traitsSave.To <IkonArray>()) { this.Traits.Add(deindexer.Get <BodyTraitType>(item.Tag as string).Load(this, item)); } }
private Treaty(IkonComposite rawData, ObjectDeindexer deindexer) { var party1Save = rawData[Party1Key]; this.Party1 = deindexer.Get <Player>(party1Save.To <int>()); var party2Save = rawData[Party2Key]; this.Party2 = deindexer.Get <Player>(party2Save.To <int>()); }
private ColonizationProject(IkonComposite rawData, ObjectDeindexer deindexer) { var ownerSave = rawData[OwnerKey]; this.Owner = deindexer.Get <Player>(ownerSave.To <int>()); var destinationSave = rawData[DestinationKey]; this.Destination = deindexer.Get <Planet>(destinationSave.To <int>()); }
private Wormhole(IkonComposite rawData, ObjectDeindexer deindexer) { var fromStarSave = rawData[FromStarKey]; this.FromStar = deindexer.Get <StarData>(fromStarSave.To <int>()); var toStarSave = rawData[ToStarKey]; this.ToStar = deindexer.Get <StarData>(toStarSave.To <int>()); }
public static LocationBody Load(IkonComposite rawData, ObjectDeindexer deindexer) { if (rawData.Tag.Equals(StarTag)) { return(new LocationBody(deindexer.Get <StarData>(rawData[IdKey].To <int>()))); } else { Planet planet = deindexer.Get <Planet>(rawData[IdKey].To <int>()); return(new LocationBody(planet.Star, planet)); } }
private ColonizationPlan(IkonComposite rawData, ObjectDeindexer deindexer) { var destinationSave = rawData[DestinationKey]; this.Destination = deindexer.Get<Planet>(destinationSave.To<int>()); var sourcesSave = rawData[SourcesKey]; this.Sources = new List<StarData>(); foreach(var item in sourcesSave.To<IkonArray>()) this.Sources.Add(deindexer.Get<StarData>(item.To<int>())); }
public static AMission Load(Ikadn.IkadnBaseObject rawData, ObjectDeindexer deindexer) { var dataStruct = rawData as IkonComposite; var destination = deindexer.Get <StarData>(dataStruct[DestinationKey].To <int>()); Wormhole usedWormhole = null; if (dataStruct.Keys.Contains(WormholeKey)) { usedWormhole = deindexer.Get <Wormhole>(dataStruct[WormholeKey].To <int>()); } return(new MoveMission(destination, usedWormhole)); }
private Dictionary <Design, Design> loadRefitOrders(IkadnBaseObject rawData, ObjectDeindexer deindexer) { var orders = new Dictionary <Design, Design>(); foreach (var orderData in rawData.To <IEnumerable <IkonComposite> >()) { orders.Add( deindexer.Get <Design>(orderData[FromDesignKey].To <int>()), deindexer.Get <Design>(orderData[ToDesignKey].To <int>()) ); } return(orders); }
//TODO(later) make separate collections for colony and stellaris construction orders private Dictionary <AConstructionSite, ConstructionOrders> loadConstruction(IkadnBaseObject rawData, ObjectDeindexer deindexer) { var queue = new Dictionary <AConstructionSite, ConstructionOrders>(); foreach (var plan in rawData.To <IEnumerable <IkonComposite> >()) { AConstructionSite site = plan.Tag.Equals(StellarisConstructionTag) ? (AConstructionSite)deindexer.Get <StellarisAdmin>(plan[LocationKey].To <int>()) : (AConstructionSite)deindexer.Get <Colony>(plan[LocationKey].To <int>()); queue.Add(site, ConstructionOrders.Load(plan[OrdersKey].To <IkonComposite>(), deindexer)); } return(queue); }
private Fleet(IkonComposite rawData, ObjectDeindexer deindexer) { var ownerSave = rawData[OwnerKey]; this.Owner = deindexer.Get <Player>(ownerSave.To <int>()); var positionSave = rawData[PositionKey]; var positionArray = positionSave.To <IkonArray>(); double positionX = positionArray[0].To <double>(); double positionY = positionArray[1].To <double>(); this.Position = new Vector2D(positionX, positionY); var missionsSave = rawData[MissionsKey]; this.Missions = new LinkedList <AMission>(); foreach (var item in missionsSave.To <IkonArray>()) { this.Missions.AddLast(MissionFactory.Load(item, deindexer)); } var shipsSave = rawData[ShipsKey]; this.Ships = new ShipGroupCollection(); foreach (var item in shipsSave.To <IkonArray>()) { this.Ships.Add(ShipGroup.Load(item.To <IkonComposite>(), deindexer)); } }
private StarData(IkonComposite rawData, ObjectDeindexer deindexer) { var colorSave = rawData[ColorKey]; var colorArray = colorSave.To <IkonArray>(); int colorR = colorArray[0].To <int>(); int colorG = colorArray[1].To <int>(); int colorB = colorArray[2].To <int>(); this.Color = Color.FromArgb(colorR, colorG, colorB); var imageSizeScaleSave = rawData[SizeKey]; this.ImageSizeScale = imageSizeScaleSave.To <float>(); var nameSave = rawData[NameKey]; this.Name = loadName(nameSave); var positionSave = rawData[PositionKey]; var positionArray = positionSave.To <IkonArray>(); double positionX = positionArray[0].To <double>(); double positionY = positionArray[1].To <double>(); this.Position = new Vector2D(positionX, positionY); var traitsSave = rawData[TraitsKey]; this.Traits = new PendableSet <BodyTrait>(); foreach (var item in traitsSave.To <IkonArray>()) { this.Traits.Add(deindexer.Get <BodyTraitType>(item.Tag as string).Load(this, item)); } }
public static Component <T> Load(IkonArray rawData, ObjectDeindexer deindexer) { return(new Component <T>( deindexer.Get <T>(rawData[TypeIndex].To <string>()), rawData[LevelIndex].To <int>(), QuantityIndex < rawData.Count ? rawData[QuantityIndex].To <int>() : 1 )); }
public static IReport Load(IkonComposite reportData, ObjectDeindexer deindexer) { return(new DevelopmentReport(new DevelopmentResult( reportData[CountKey].To <long>(), reportData[InvestedKey].To <double>(), deindexer.Get <DevelopmentProgress>(reportData[TopicKey].To <int>()), reportData[LeftoverKey].To <double>() ))); }
private ResearchProgress(IkonComposite rawData, ObjectDeindexer deindexer) { var ownerSave = rawData[OwnerKey]; this.Owner = deindexer.Get <Player>(ownerSave.To <int>()); var topicSave = rawData[TopicKey]; this.Topic = deindexer.Get <ResearchTopic>(topicSave.To <string>()); var levelSave = rawData[LevelKey]; this.Level = levelSave.To <int>(); var investedPointsSave = rawData[InvestedKey]; this.InvestedPoints = investedPointsSave.To <double>(); }
private Dictionary <Planet, ColonizationPlan> loadColonizationOrders(IkadnBaseObject rawData, ObjectDeindexer deindexer) { var orders = new Dictionary <Planet, ColonizationPlan>(); foreach (var orderData in rawData.To <IEnumerable <IkonComposite> >()) { var destination = deindexer.Get <Planet>(orderData[ColonizationDestinationTag].To <int>()); var plan = new ColonizationPlan(destination); foreach (var sourceIndex in orderData[ColonizationSourcesTag].To <IEnumerable <int> >()) { plan.Sources.Add(deindexer.Get <StarData>(sourceIndex)); } orders.Add(destination, plan); } return(orders); }
private ConstructionOrders(IkonComposite rawData, ObjectDeindexer deindexer) { var spendingRatioSave = rawData[SpendingRatioKey]; this.SpendingRatio = spendingRatioSave.To <double>(); var queueSave = rawData[QueueKey]; this.Queue = new List <Constructable>(); foreach (var item in queueSave.To <IkonArray>()) { this.Queue.Add(deindexer.Get <Constructable>(item.To <string>())); } }
private Intelligence(IkonComposite rawData, ObjectDeindexer deindexer) { var starKnowledgeSave = rawData[StarKnowledgeKey]; this.starKnowledge = new Dictionary <StarData, StarIntelligence>(); foreach (var item in starKnowledgeSave.To <IEnumerable <IkonComposite> >()) { var itemKey = item[StarDataKey]; var itemValue = item[StarIntelligenceKey]; this.starKnowledge.Add( deindexer.Get <StarData>(itemKey.To <int>()), StarIntelligence.Load(itemValue.To <IkonComposite>(), deindexer) ); } }
private ShipGroup(IkonComposite rawData, ObjectDeindexer deindexer) { var designSave = rawData[DesignKey]; this.Design = deindexer.Get <Design>(designSave.To <int>()); var quantitySave = rawData[QuantityKey]; this.Quantity = quantitySave.To <long>(); var damageSave = rawData[DamageKey]; this.Damage = damageSave.To <double>(); var upgradePointsSave = rawData[UpgradePointsKey]; this.UpgradePoints = upgradePointsSave.To <double>(); }
private StarIntelligence(IkonComposite rawData, ObjectDeindexer deindexer) { var lastVisitedSave = rawData[LastVisitedKey]; this.LastVisited = lastVisitedSave.To <int>(); var planetsSave = rawData[PlanetsKey]; this.Planets = new Dictionary <Planet, PlanetIntelligence>(); foreach (var item in planetsSave.To <IEnumerable <IkonComposite> >()) { var itemKey = item[PlanetKey]; var itemValue = item[PlanetIntelligenceKey]; this.Planets.Add( deindexer.Get <Planet>(itemKey.To <int>()), PlanetIntelligence.Load(itemValue.To <IkonComposite>(), deindexer) ); } }
protected AConstructionSite(IkonComposite rawData, ObjectDeindexer deindexer) { var locationSave = rawData[LocationKey]; this.Location = LocationBody.Load(locationSave.To <IkonComposite>(), deindexer); var ownerSave = rawData[OwnerKey]; this.Owner = deindexer.Get <Player>(ownerSave.To <int>()); var buildingsSave = rawData[BuildingsKey]; this.Buildings = new Dictionary <string, double>(); foreach (var item in buildingsSave.To <IEnumerable <IkonComposite> >()) { var itemKey = item[BuildingTypeKey]; var itemValue = item[BuildingAmountKey]; this.Buildings.Add( itemKey.To <string>(), itemValue.To <double>() ); } var stockpileSave = rawData[StockpileKey]; this.Stockpile = new Dictionary <string, double>(); foreach (var item in stockpileSave.To <IEnumerable <IkonComposite> >()) { var itemKey = item[StockpileGroupKey]; var itemValue = item[StockpileAmountKey]; this.Stockpile.Add( itemKey.To <string>(), itemValue.To <double>() ); } #if DEBUG this.id = NextId(); #endif }
private Player(IkonComposite rawData, ObjectDeindexer deindexer) { var nameSave = rawData[NameKey]; this.Name = nameSave.To <string>(); var colorSave = rawData[ColorKey]; var colorArray = colorSave.To <IkonArray>(); int colorR = colorArray[0].To <int>(); int colorG = colorArray[1].To <int>(); int colorB = colorArray[2].To <int>(); this.Color = Color.FromArgb(colorR, colorG, colorB); var controlTypeSave = rawData[ControlTypeKey]; this.ControlType = (PlayerControlType)Enum.Parse(typeof(PlayerControlType), (string)controlTypeSave.Tag); var offscreenControlSave = rawData[OffscreenControlKey]; this.OffscreenControl = loadControl(offscreenControlSave); var unlockedDesignsSave = rawData[UnlockedDesignsKey]; this.UnlockedDesigns = new HashSet <PredefinedDesign>(); foreach (var item in unlockedDesignsSave.To <IkonArray>()) { this.UnlockedDesigns.Add(deindexer.Get <PredefinedDesign>(item.To <int>())); } var intelligenceSave = rawData[IntelligenceKey]; this.Intelligence = Intelligence.Load(intelligenceSave.To <IkonComposite>(), deindexer); #if DEBUG this.id = NextId(); #endif }
private Design(IkonComposite rawData, ObjectDeindexer deindexer) { var idCodeSave = rawData[IdCodeKey]; this.IdCode = idCodeSave.To <string>(); var ownerSave = rawData[OwnerKey]; this.Owner = deindexer.Get <Player>(ownerSave.To <int>()); var isObsoleteSave = rawData[IsObsoleteKey]; this.IsObsolete = isObsoleteSave.To <int>() >= 0; var isVirtualSave = rawData[IsVirtualKey]; this.IsVirtual = isVirtualSave.To <int>() >= 0; var nameSave = rawData[NameKey]; this.Name = nameSave.To <string>(); var imageIndexSave = rawData[ImageIndexKey]; this.ImageIndex = imageIndexSave.To <int>(); var armorSave = rawData[ArmorKey]; this.Armor = Component <ArmorType> .Load(armorSave.To <IkonArray>(), deindexer); var hullSave = rawData[HullKey]; this.Hull = Component <HullType> .Load(hullSave.To <IkonArray>(), deindexer); if (rawData.Keys.Contains(IsDriveKey)) { var isDriveSave = rawData[IsDriveKey]; this.IsDrive = Component <IsDriveType> .Load(isDriveSave.To <IkonArray>(), deindexer); } var reactorSave = rawData[ReactorKey]; this.Reactor = Component <ReactorType> .Load(reactorSave.To <IkonArray>(), deindexer); var sensorsSave = rawData[SensorsKey]; this.Sensors = Component <SensorType> .Load(sensorsSave.To <IkonArray>(), deindexer); if (rawData.Keys.Contains(ShieldKey)) { var shieldSave = rawData[ShieldKey]; this.Shield = Component <ShieldType> .Load(shieldSave.To <IkonArray>(), deindexer); } var missionEquipmentSave = rawData[EquipmentKey]; this.MissionEquipment = new List <Component <MissionEquipmentType> >(); foreach (var item in missionEquipmentSave.To <IkonArray>()) { this.MissionEquipment.Add(Component <MissionEquipmentType> .Load(item.To <IkonArray>(), deindexer)); } var specialEquipmentSave = rawData[SpecialsKey]; this.SpecialEquipment = new List <Component <SpecialEquipmentType> >(); foreach (var item in specialEquipmentSave.To <IkonArray>()) { this.SpecialEquipment.Add(Component <SpecialEquipmentType> .Load(item.To <IkonArray>(), deindexer)); } var thrustersSave = rawData[ThrustersKey]; this.Thrusters = Component <ThrusterType> .Load(thrustersSave.To <IkonArray>(), deindexer); this.Cost = initCost(); }