linting fixes
This commit is contained in:
parent
f846df9d8c
commit
603b2d3469
|
|
@ -6,6 +6,6 @@ using UnityEngine;
|
||||||
public class InventoryData
|
public class InventoryData
|
||||||
{
|
{
|
||||||
public int capacity = 0;
|
public int capacity = 0;
|
||||||
|
|
||||||
public SerializableDictionary<string, int> items = new SerializableDictionary<string, int>();
|
public SerializableDictionary<string, int> items = new SerializableDictionary<string, int>();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using UnityEngine;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using UnityEngine;
|
||||||
using UnityEngine.SceneManagement;
|
using UnityEngine.SceneManagement;
|
||||||
|
|
||||||
public class DataPersistenceManager : MonoBehaviour
|
public class DataPersistenceManager : MonoBehaviour
|
||||||
|
|
@ -10,11 +10,15 @@ public class DataPersistenceManager : MonoBehaviour
|
||||||
// [SerializeField] private bool initializeDataIfNull = false;
|
// [SerializeField] private bool initializeDataIfNull = false;
|
||||||
|
|
||||||
[Header("File Storage Config")]
|
[Header("File Storage Config")]
|
||||||
[SerializeField] private string fileName;
|
[SerializeField]
|
||||||
[SerializeField] private bool useEncryption;
|
private string fileName;
|
||||||
|
|
||||||
|
[SerializeField]
|
||||||
|
private bool useEncryption;
|
||||||
|
|
||||||
[Header("Auto Saving Configuration")]
|
[Header("Auto Saving Configuration")]
|
||||||
[SerializeField] private float autoSaveTimeSeconds = 60f;
|
[SerializeField]
|
||||||
|
private float autoSaveTimeSeconds = 60f;
|
||||||
|
|
||||||
private GameData gameData = new GameData();
|
private GameData gameData = new GameData();
|
||||||
private List<IDataPersistence<GameData>> dataPersistenceObjects;
|
private List<IDataPersistence<GameData>> dataPersistenceObjects;
|
||||||
|
|
@ -28,14 +32,20 @@ public class DataPersistenceManager : MonoBehaviour
|
||||||
{
|
{
|
||||||
if (instance != null)
|
if (instance != null)
|
||||||
{
|
{
|
||||||
Debug.Log("Found more than one Data Persistence Manager in the scene. Destroying the newest one.");
|
Debug.Log(
|
||||||
|
"Found more than one Data Persistence Manager in the scene. Destroying the newest one."
|
||||||
|
);
|
||||||
Destroy(this.gameObject);
|
Destroy(this.gameObject);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
instance = this;
|
instance = this;
|
||||||
DontDestroyOnLoad(this.gameObject);
|
DontDestroyOnLoad(this.gameObject);
|
||||||
|
|
||||||
this.dataHandler = new FileDataHandler(Application.persistentDataPath, fileName, useEncryption);
|
this.dataHandler = new FileDataHandler(
|
||||||
|
Application.persistentDataPath,
|
||||||
|
fileName,
|
||||||
|
useEncryption
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnEnable()
|
private void OnEnable()
|
||||||
|
|
@ -90,7 +100,7 @@ public class DataPersistenceManager : MonoBehaviour
|
||||||
}
|
}
|
||||||
|
|
||||||
// if no data can be loaded, don't continue
|
// if no data can be loaded, don't continue
|
||||||
// if (this.gameData == null)
|
// if (this.gameData == null)
|
||||||
// {
|
// {
|
||||||
// Debug.Log("No data was found. A New Game needs to be started before data can be loaded.");
|
// Debug.Log("No data was found. A New Game needs to be started before data can be loaded.");
|
||||||
// return;
|
// return;
|
||||||
|
|
@ -112,7 +122,9 @@ public class DataPersistenceManager : MonoBehaviour
|
||||||
// if we don't have any data to save, log a warning here
|
// if we don't have any data to save, log a warning here
|
||||||
if (this.gameData == null)
|
if (this.gameData == null)
|
||||||
{
|
{
|
||||||
Debug.LogWarning("No data was found. A New Game needs to be started before data can be saved.");
|
Debug.LogWarning(
|
||||||
|
"No data was found. A New Game needs to be started before data can be saved."
|
||||||
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -137,8 +149,9 @@ public class DataPersistenceManager : MonoBehaviour
|
||||||
private List<IDataPersistence<GameData>> FindAllDataPersistenceObjects()
|
private List<IDataPersistence<GameData>> FindAllDataPersistenceObjects()
|
||||||
{
|
{
|
||||||
// FindObjectsofType takes in an optional boolean to include inactive gameobjects
|
// FindObjectsofType takes in an optional boolean to include inactive gameobjects
|
||||||
IEnumerable<IDataPersistence<GameData>> dataPersistenceObjects = FindObjectsByType<MonoBehaviour>(FindObjectsSortMode.None)
|
IEnumerable<IDataPersistence<GameData>> dataPersistenceObjects =
|
||||||
.OfType<IDataPersistence<GameData>>();
|
FindObjectsByType<MonoBehaviour>(FindObjectsSortMode.None)
|
||||||
|
.OfType<IDataPersistence<GameData>>();
|
||||||
|
|
||||||
var list = new List<IDataPersistence<GameData>>(dataPersistenceObjects);
|
var list = new List<IDataPersistence<GameData>>(dataPersistenceObjects);
|
||||||
return list;
|
return list;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue