using System;
using System.Collections;
using System.Collections.Generic;
using System.Runtime.Serialization;
using UnityEngine;
namespace MoreMountains.Tools
{
///
/// A serializable class used to store scene data, the key is a string (the scene name), the value is a MMPersistencySceneData
///
[Serializable]
public class DictionaryStringSceneData : MMSerializableDictionary
{
public DictionaryStringSceneData() : base() { }
protected DictionaryStringSceneData(SerializationInfo info, StreamingContext context) : base(info, context) { }
}
///
/// A serializable class used to store object data, the key is a string (the object name), the value is a string (the object data)
///
[Serializable]
public class DictionaryStringString : MMSerializableDictionary
{
public DictionaryStringString() : base() { }
protected DictionaryStringString(SerializationInfo info, StreamingContext context) : base(info, context) { }
}
///
/// A serializable class used to store all the data for a persistency manager, a collection of scene datas
///
[Serializable]
public class MMPersistencyManagerData
{
public string PersistencyID;
public string SaveDate;
public DictionaryStringSceneData SceneDatas;
}
///
/// A serializable class used to store all the data for a scene, a collection of object datas
///
[Serializable]
public class MMPersistencySceneData
{
public DictionaryStringString ObjectDatas;
}
///
/// The various types of persistency events that can be triggered by the MMPersistencyManager
///
public enum MMPersistencyEventType { DataSavedToMemory, DataLoadedFromMemory, DataSavedFromMemoryToFile, DataLoadedFromFileToMemory }
///
/// A data structure used to store persistency event data.
/// To use :
/// MMPersistencyEvent.Trigger(MMPersistencyEventType.DataLoadedFromFileToMemory, "yourPersistencyID");
///
public struct MMPersistencyEvent
{
public MMPersistencyEventType PersistencyEventType;
public string PersistencyID;
public MMPersistencyEvent(MMPersistencyEventType eventType, string persistencyID)
{
PersistencyEventType = eventType;
PersistencyID = persistencyID;
}
static MMPersistencyEvent e;
public static void Trigger(MMPersistencyEventType eventType, string persistencyID)
{
e.PersistencyEventType = eventType;
e.PersistencyID = persistencyID;
}
}
}