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 persistence manager, a collection of scene datas
///
[Serializable]
public class MMPersistenceManagerData
{
public string PersistenceID;
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 MMPersistenceSceneData
{
public DictionaryStringString ObjectDatas;
}
///
/// The various types of persistence events that can be triggered by the MMPersistencyManager
///
public enum MMPersistenceEventType { DataSavedToMemory, DataLoadedFromMemory, DataSavedFromMemoryToFile, DataLoadedFromFileToMemory }
///
/// A data structure used to store persistence event data.
/// To use :
/// MMPersistencyEvent.Trigger(MMPersistencyEventType.DataLoadedFromFileToMemory, "yourPersistencyID");
///
public struct MMPersistenceEvent
{
public MMPersistenceEventType PersistenceEventType;
public string PersistenceID;
public MMPersistenceEvent(MMPersistenceEventType eventType, string persistenceID)
{
PersistenceEventType = eventType;
PersistenceID = persistenceID;
}
static MMPersistenceEvent e;
public static void Trigger(MMPersistenceEventType eventType, string persistencyID)
{
e.PersistenceEventType = eventType;
e.PersistenceID = persistencyID;
}
}
}