public void Save(SerializableShip serializable) { serializable.ShipCategory = ShipCategory; serializable.Name = Name; serializable.Faction = FactionId.Id; serializable.SizeClass = SizeClass; serializable.IconImage = IconImage; serializable.IconScale = IconScale.Value; serializable.ModelImage = ModelImage; serializable.ModelScale = ModelScale.Value; serializable.EnginePosition = EnginePosition; serializable.EngineColor = Helpers.ColorToString(EngineColor); serializable.EngineSize = EngineSize.Value; serializable.EnergyResistance = EnergyResistance.Value; serializable.KineticResistance = KineticResistance.Value; serializable.HeatResistance = HeatResistance.Value; serializable.Regeneration = Regeneration; serializable.BaseWeightModifier = BaseWeightModifier.Value; serializable.Layout = Layout.Data; serializable.BuiltinDevices = BuiltinDevices?.Select(device => device.Item.Id).ToArray(); serializable.Barrels = Barrels?.Select(item => item.Serialize()).ToArray(); serializable.Engines = Engines?.Select(item => new SerializableShip.Engine { Position = item.Position, Size = item.Size.Value }).ToArray(); }
public ShipSerializable Serialize() { var serializable = new ShipSerializable(); serializable.Id = ItemId.Id; serializable.FileName = ItemId.Name; serializable.ItemType = (int)ItemType.Ship; serializable.ShipCategory = ShipCategory; serializable.Name = Name; serializable.Faction = Faction.Id; serializable.SizeClass = SizeClass; serializable.IconImage = IconImage.ToString(); serializable.IconScale = IconScale.Value; serializable.ModelImage = ModelImage.ToString(); serializable.ModelScale = ModelScale.Value; serializable.EnginePosition = EnginePosition; serializable.EngineColor = Utils.ColorUtils.ColorToString(EngineColor); serializable.EngineSize = EngineSize.Value; serializable.EnergyResistance = EnergyResistance.Value; serializable.KineticResistance = KineticResistance.Value; serializable.HeatResistance = HeatResistance.Value; serializable.Regeneration = Regeneration; serializable.BaseWeightModifier = BaseWeightModifier.Value; serializable.BuiltinDevices = BuiltinDevices?.Select(item => item.Item.Id).ToArray(); serializable.Layout = Layout.Data; serializable.Barrels = Barrels?.Select(item => item.Serialize()).ToArray(); return(serializable); }
public void Save(ShipSerializable serializable) { serializable.ShipCategory = ShipCategory; serializable.Name = Name; serializable.Faction = Faction.Value; serializable.SizeClass = SizeClass; serializable.IconImage = IconImage; serializable.IconScale = IconScale.Value; serializable.ModelImage = ModelImage; serializable.ModelScale = ModelScale.Value; serializable.EnginePosition = EnginePosition; serializable.EngineColor = Helpers.ColorToString(EngineColor); serializable.EngineSize = EngineSize.Value; if (Engines == null || Engines.Length == 0) { serializable.Engines = null; } else { serializable.Engines = Engines.Select(item => item.Serialize()).ToArray(); } serializable.EnergyResistance = EnergyResistance.Value; serializable.KineticResistance = KineticResistance.Value; serializable.HeatResistance = HeatResistance.Value; serializable.Regeneration = Regeneration; serializable.BaseWeightModifier = BaseWeightModifier.Value; if (BuiltinDevices == null || BuiltinDevices.Length == 0) { serializable.BuiltinDevices = null; } else { serializable.BuiltinDevices = BuiltinDevices.Select(wrapper => wrapper.Item.Value).ToArray(); } serializable.Layout = Layout.Data; if (Barrels == null || Barrels.Length == 0) { serializable.Barrels = null; } else { serializable.Barrels = Barrels.Select(item => item.Serialize()).ToArray(); } OnDataSerialized(ref serializable); }