private Ship(ShipSerializable serializable, Database.Loader loader) { Id = new ItemId <Ship>(serializable.Id); loader.AddShip(serializable.Id, this); ShipCategory = serializable.ShipCategory; Name = serializable.Name; Faction = loader.GetFaction(new ItemId <Faction>(serializable.Faction)); SizeClass = serializable.SizeClass; IconImage = new SpriteId(serializable.IconImage, SpriteId.Type.ShipIcon); IconScale = UnityEngine.Mathf.Clamp(serializable.IconScale, 0.1f, 100f); ModelImage = new SpriteId(serializable.ModelImage, SpriteId.Type.Ship); ModelScale = UnityEngine.Mathf.Clamp(serializable.ModelScale, 0.1f, 100f); _enginePosition = serializable.EnginePosition; EngineColor = new ColorData(serializable.EngineColor); _engineSize = UnityEngine.Mathf.Clamp(serializable.EngineSize, 0f, 1f); Engines = new ImmutableCollection <Engine>(serializable.Engines?.Select(item => Engine.Create(item, loader))); EnergyResistance = UnityEngine.Mathf.Clamp(serializable.EnergyResistance, -100f, 100f); KineticResistance = UnityEngine.Mathf.Clamp(serializable.KineticResistance, -100f, 100f); HeatResistance = UnityEngine.Mathf.Clamp(serializable.HeatResistance, -100f, 100f); Regeneration = serializable.Regeneration; BaseWeightModifier = UnityEngine.Mathf.Clamp(serializable.BaseWeightModifier, -0.9f, 1000f); BuiltinDevices = new ImmutableCollection <Device>(serializable.BuiltinDevices?.Select(item => loader.GetDevice(new ItemId <Device>(item), true))); Layout = new Layout(serializable.Layout); Barrels = new ImmutableCollection <Barrel>(serializable.Barrels?.Select(item => Barrel.Create(item, loader))); OnDataDeserialized(serializable, loader); }
private Satellite(SatelliteSerializable serializable, Database.Loader loader) { Id = new ItemId <Satellite>(serializable.Id); loader.AddSatellite(serializable.Id, this); Name = serializable.Name; ModelImage = new SpriteId(serializable.ModelImage, SpriteId.Type.Satellite); ModelScale = UnityEngine.Mathf.Clamp(serializable.ModelScale, 0.1f, 100f); SizeClass = serializable.SizeClass; Layout = new Layout(serializable.Layout); Barrels = new ImmutableCollection <Barrel>(serializable.Barrels?.Select(item => Barrel.Create(item, loader))); OnDataDeserialized(serializable, loader); }