Scriptum/Assets/Scripts/REFACTORING/Models/Chest/ChestPrefabAssetData.cs
2022-11-28 00:52:47 +01:00

62 lines
2.1 KiB
C#

using System.Collections.Generic;
using UnityEngine;
[System.Serializable]
public class ChestPrefabAssetData : PrefabAssetModelData
{
[SerializeField] ChestData ChestData;
//public List<IndexValuePair<int, EquippableItemPrefabAssetData>> Content { get; set; }
public ChestPrefabAssetData(ChestPrefabAsset assetModel) : base(assetModel)
{
ChestData = MapModelToData(assetModel.Chest);
/*
Content = new List<IndexValuePair<int, EquippableItemPrefabAssetData>>();
Debug.Log("ChestPrefarbAsset to ChestPrefarbAssetData - " + assetModel.Name);
foreach(IndexValuePair<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
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;
}
}