Scriptum/Assets/Scripts/REFACTORING/Application/Panel/Inventory/SceneInventoryDataLoader.cs
2022-11-24 03:03:30 +01:00

65 lines
2.0 KiB
C#

using System;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
public class SceneInventoryDataLoader : SceneBaseDataLoader<IndexValuePair<int, EquippableItemPrefabAsset>>
{
public SceneInventoryDataLoader(string _objectListName, string _objectFolderName)
{
SaveModelSystem = new SaveInventoryManager();
SaveModelSystem.ObjectFolderName = _objectFolderName;
SaveModelSystem.ObjectListName = _objectListName;
}
protected override List<IndexValuePair<int, EquippableItemPrefabAsset>> LoadGenericData()
{
SaveModelSystem.Path = PathBuilder.BuildSavePath().GetString();
return SaveModelSystem.LoadModelList();
}
protected override bool SaveGenericData(List<IndexValuePair<int, EquippableItemPrefabAsset>> _elements)
{
SaveModelSystem.Path = PathBuilder.BuildSavePath().GetString();
try
{
SaveModelSystem.SaveModelList(_elements);
return true;
}
catch (Exception e) { Debug.LogError(e.Message); }
return false;
}
protected override List<IndexValuePair<int, EquippableItemPrefabAsset>> LoadStaticData() { throw new System.NotImplementedException(); }
protected override List<IndexValuePair<int, EquippableItemPrefabAsset>> LoadDynamicData()
{
SaveModelSystem.Path = PathBuilder.BuildSavePath().GetString();
return SaveModelSystem.LoadModelList();
}
protected override bool SaveStaticData(List<IndexValuePair<int, EquippableItemPrefabAsset>> _elements) { throw new System.NotImplementedException(); }
protected override bool SaveDynamicData(List<IndexValuePair<int, EquippableItemPrefabAsset>> _elements)
{
SaveModelSystem.Path = PathBuilder.BuildSavePath().GetString();
Debug.Log(SaveModelSystem.Path);
try
{
SaveModelSystem.SaveModelList(_elements);
return true;
}
catch (Exception e) { Debug.LogError(e.Message); }
return false;
}
}