Beispiel #1
0
 private ShipBuildData(ShipBuildSerializable serializable, Database database)
 {
     ItemId             = new ItemId <ShipBuildData>(serializable.Id, serializable.FileName);
     ShipId             = database.GetShipId(serializable.ShipId);
     NotAvailableInGame = serializable.NotAvailableInGame;
     DifficultyClass    = serializable.DifficultyClass;
     BuildFaction       = database.GetFactionId(serializable.BuildFaction);
     Components         = serializable.Components?.Select(item => InstalledComponentData.Deserialize(item, database)).ToArray();
 }
Beispiel #2
0
        public ShipBuildSerializable Serialize()
        {
            var serializable = new ShipBuildSerializable();

            serializable.Id                 = ItemId.Id;
            serializable.FileName           = ItemId.Name;
            serializable.ItemType           = (int)ItemType.ShipBuild;
            serializable.ShipId             = ShipId.Id;
            serializable.NotAvailableInGame = NotAvailableInGame;
            serializable.DifficultyClass    = DifficultyClass;
            serializable.BuildFaction       = BuildFaction.Id;
            serializable.Components         = Components?.Select(item => item.Serialize()).ToArray();
            return(serializable);
        }
Beispiel #3
0
        public ShipBuild(ShipBuildSerializable serializable, Database database)
        {
            Id   = new ItemId <ShipBuild>(serializable.Id, serializable.FileName);
            Ship = database.GetShipId(serializable.ShipId);
            if (Ship.IsNull)
            {
                throw new DatabaseException(this.GetType().Name + ".Ship cannot be null");
            }
            NotAvailableInGame = serializable.NotAvailableInGame;
            DifficultyClass    = serializable.DifficultyClass;
            BuildFaction       = database.GetFactionId(serializable.BuildFaction);
            Components         = serializable.Components?.Select(item => new InstalledComponent(item, database)).ToArray();

            OnDataDeserialized(serializable, database);
        }
Beispiel #4
0
 public void Save(ShipBuildSerializable serializable)
 {
     serializable.ShipId             = Ship.Value;
     serializable.NotAvailableInGame = NotAvailableInGame;
     serializable.DifficultyClass    = DifficultyClass;
     serializable.BuildFaction       = BuildFaction.Value;
     if (Components == null || Components.Length == 0)
     {
         serializable.Components = null;
     }
     else
     {
         serializable.Components = Components.Select(item => item.Serialize()).ToArray();
     }
     OnDataSerialized(ref serializable);
 }
Beispiel #5
0
        private ShipBuild(ShipBuildSerializable serializable, Database.Loader loader)
        {
            Id = new ItemId <ShipBuild>(serializable.Id);
            loader.AddShipBuild(serializable.Id, this);

            Ship = loader.GetShip(new ItemId <Ship>(serializable.ShipId));
            if (Ship == null)
            {
                throw new DatabaseException(this.GetType().Name + ".Ship cannot be null - " + serializable.ShipId);
            }
            NotAvailableInGame = serializable.NotAvailableInGame;
            DifficultyClass    = serializable.DifficultyClass;
            BuildFaction       = loader.GetFaction(new ItemId <Faction>(serializable.BuildFaction));
            Components         = new ImmutableCollection <InstalledComponent>(serializable.Components?.Select(item => InstalledComponent.Create(item, loader)));

            OnDataDeserialized(serializable, loader);
        }
Beispiel #6
0
 partial void OnDataSerialized(ref ShipBuildSerializable serializable);
Beispiel #7
0
 partial void OnDataDeserialized(ShipBuildSerializable serializable, Database database);
Beispiel #8
0
 public static ShipBuild Create(ShipBuildSerializable serializable, Database.Loader loader)
 {
     return(new ShipBuild(serializable, loader));
 }
Beispiel #9
0
 partial void OnDataDeserialized(ShipBuildSerializable serializable, Database.Loader loader);
Beispiel #10
0
 public static ShipBuildData Deserialize(ShipBuildSerializable serializable, Database database)
 {
     return(new ShipBuildData(serializable, database));
 }