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

62 lines
2.1 KiB
C#
Raw Permalink Normal View History

using System.Collections.Generic;
using UnityEngine;
[System.Serializable]
public class ChestPrefabAssetData : PrefabAssetModelData
{
[SerializeField] ChestData ChestData;
2022-11-24 03:03:30 +01:00
//public List<IndexValuePair<int, EquippableItemPrefabAssetData>> Content { get; set; }
public ChestPrefabAssetData(ChestPrefabAsset assetModel) : base(assetModel)
{
ChestData = MapModelToData(assetModel.Chest);
2022-11-27 21:28:55 +01:00
/*
Content = new List<IndexValuePair<int, EquippableItemPrefabAssetData>>();
2022-11-24 03:03:30 +01:00
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();
2022-11-24 03:03:30 +01:00
// clear content and set items from data - this will modify Scri-0ptableObject data also in source
//chestPrefabAsset.Chest.Content.Clear();
2022-11-27 21:28:55 +01:00
/* 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;
}
}