Scriptum/Assets/Scripts/REFACTORING/Models/Chest/ChestPrefabAssetData.cs

61 lines
2.0 KiB
C#

using System.Collections.Generic;
using UnityEngine;
[System.Serializable]
public class ChestPrefabAssetData : PrefabAssetModelData
{
[SerializeField] ChestData ChestData;
//public List<KeyValuePair<int, EquippableItemPrefabAssetData>> Content { get; set; }
public ChestPrefabAssetData(ChestPrefabAsset assetModel) : base(assetModel)
{
ChestData = MapModelToData(assetModel.Chest);
/* Content = new List<KeyValuePair<int, EquippableItemPrefabAssetData>>();
Debug.Log("ChestPrefarbAsset to ChestPrefarbAssetData - " + assetModel.Name);
foreach(KeyValuePair<int, EquippableItemPrefabAsset> 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<EquippableItemData> modelData in ChestData.content)
{
var objectFromData = (modelData.Value).MapDataToObject();
Debug.Log(objectFromData);
chestPrefabAsset.Chest.Content.Add(
new IndexValuePair<Item>(modelData.Key, objectFromData)
);
}*/
return chestPrefabAsset;
}
}