PixelCrushers_EnviroSaver_2020-07-21.unitypackage
EnviroSaver.cs
Code: Select all
using System;
using PixelCrushers;
/// <summary>
/// Pixel Crushers Save System saver for Hendrik Haupt's Enviro.
/// </summary>
public class EnviroSaver : Saver
{
[Serializable]
public class Data
{
public float timeOfDay;
public int days;
public int years;
}
private Data m_data = new Data();
public override string RecordData()
{
m_data.timeOfDay = EnviroSkyMgr.instance.GetTimeOfDay();
m_data.days = EnviroSkyMgr.instance.Time.Days;
m_data.years = EnviroSkyMgr.instance.Time.Years;
return SaveSystem.Serialize(m_data);
}
public override void ApplyData(string s)
{
if (string.IsNullOrEmpty(s)) return;
m_data = SaveSystem.Deserialize<Data>(s, m_data);
if (m_data == null)
{
m_data = new Data();
}
else
{
EnviroSkyMgr.instance.SetTimeOfDay(m_data.timeOfDay);
EnviroSkyMgr.instance.Time.Days = m_data.days;
EnviroSkyMgr.instance.Time.Years = m_data.years;
}
}
}