using System.Collections.Generic; using UnityEngine; [System.Serializable] public class ChestPrefabAssetData : PrefabAssetModelData { [SerializeField] ChestData ChestData; //public List> Content { get; set; } public ChestPrefabAssetData(ChestPrefabAsset assetModel) : base(assetModel) { ChestData = MapModelToData(assetModel.Chest); /* Content = new List>(); Debug.Log("ChestPrefarbAsset to ChestPrefarbAssetData - " + assetModel.Name); foreach(KeyValuePair itemEntry in assetModel.Content) { Debug.Log("Slot nr " + itemEntry.Key); Content[itemEntry.Key] = itemEntry.Value.MapPrefabAssetModelToData(); }*/ } public ChestData MapModelToData(Chest chest) { return new ChestData(chest); } public override PrefabAssetModelData PrefabAssetModelToData(PrefabAssetModel assetModel) { return new ChestPrefabAssetData((ChestPrefabAsset)assetModel); } public override PrefabAssetModel MapDataToPrefabAssetModel() { ChestPrefabAsset chestPrefabAsset = new ChestPrefabAsset( Name, PrefabAssetName, new Vector3(Position[0], Position[1], Position[2]) ); // todo convert each item to data Debug.Log(ChestData); chestPrefabAsset.Chest = ChestData.MapDataToObject(); // clear content and set items from data - this will modify Scri-0ptableObject data also in source //chestPrefabAsset.Chest.Content.Clear(); /* foreach (IndexValuePair modelData in ChestData.content) { var objectFromData = (modelData.Value).MapDataToObject(); Debug.Log(objectFromData); chestPrefabAsset.Chest.Content.Add( new IndexValuePair(modelData.Key, objectFromData) ); }*/ return chestPrefabAsset; } }