89 lines
2.1 KiB
C#
89 lines
2.1 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.SceneManagement;
|
|
|
|
public abstract class SceneBaseDataLoader<T> : SceneDataLoaderInterface<T>
|
|
{
|
|
protected SaveModelSystem<T> SaveModelSystem;
|
|
protected PathBuilder PathBuilder;
|
|
|
|
protected string CurrentMap;
|
|
|
|
protected SceneBaseDataLoader()
|
|
{
|
|
PathBuilder = new PathBuilder();
|
|
|
|
CurrentMap = SceneManager.GetActiveScene().name;
|
|
}
|
|
|
|
public List<T> LoadData(SceneElementTypeEnum type)
|
|
{
|
|
switch (type)
|
|
{
|
|
case SceneElementTypeEnum.None:
|
|
{
|
|
return LoadGenericData();
|
|
}
|
|
/* case SceneElementTypeEnum.Static:
|
|
{
|
|
return LoadStaticData();
|
|
}*/
|
|
case SceneElementTypeEnum.Dynamic:
|
|
{
|
|
return LoadDynamicData();
|
|
}
|
|
default: // for SceneElementTypeEnum.All
|
|
{
|
|
Debug.Log("Handle All case...");
|
|
|
|
return new List<T>();
|
|
}
|
|
}
|
|
}
|
|
|
|
public bool SaveData(List<T> _elements, SceneElementTypeEnum type)
|
|
{
|
|
switch (type)
|
|
{
|
|
case SceneElementTypeEnum.None:
|
|
{
|
|
return SaveGenericData(_elements);
|
|
}
|
|
/* case SceneElementTypeEnum.Static:
|
|
{
|
|
return SaveStaticData(_elements);
|
|
}*/
|
|
case SceneElementTypeEnum.Dynamic:
|
|
{
|
|
return SaveDynamicData(_elements);
|
|
}
|
|
default: // for SceneElementTypeEnum.All
|
|
{
|
|
Debug.Log("Handle All case...");
|
|
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
protected abstract List<T> LoadDynamicData();
|
|
protected abstract List<T> LoadGenericData();
|
|
|
|
protected virtual bool SaveDynamicData(List<T> _elements)
|
|
{
|
|
/* try
|
|
{*/
|
|
SaveModelSystem.SaveModelList(_elements);
|
|
|
|
return true;
|
|
/* }
|
|
catch (Exception e) { Debug.LogError(e.Message); }*/
|
|
|
|
return false;
|
|
}
|
|
|
|
protected abstract bool SaveGenericData(List<T> _elements);
|
|
}
|