using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Omegasis.SaveAnywhere.Framework { /// /// Interface for the Save Anywhere API /// Other mods can use this interface to get the /// API from the SMAPI helper /// public class SaveAnywhereAPI { /********* ** Events *********/ /// /// Event that fires before game save /// public event EventHandler BeforeSave { add { SaveAnywhere.Instance.SaveManager.beforeSave += value; } remove { SaveAnywhere.Instance.SaveManager.beforeSave -= value; } } /// /// Event that fires after game save /// public event EventHandler AfterSave { add { SaveAnywhere.Instance.SaveManager.afterSave += value; } remove { SaveAnywhere.Instance.SaveManager.afterSave -= value; } } /// /// Event that fires after game load /// public event EventHandler AfterLoad { add { SaveAnywhere.Instance.SaveManager.afterLoad += value; } remove { SaveAnywhere.Instance.SaveManager.afterLoad -= value; } } public SaveAnywhereAPI() { } /// /// Add in an event that can trigger before saving begins. /// /// /// public void addBeforeSaveEvent(string ID, Action BeforeSave) { SaveAnywhere.Instance.SaveManager.beforeCustomSavingBegins.Add(ID, BeforeSave); } /// /// Remove an event that can trigger before saving begins. /// /// /// public void removeBeforeSaveEvent(string ID, Action BeforeSave) { SaveAnywhere.Instance.SaveManager.beforeCustomSavingBegins.Remove(ID); } /// /// Add an event that tiggers after saving has finished. /// /// /// public void addAfterSaveEvent(string ID, Action AfterSave) { SaveAnywhere.Instance.SaveManager.afterCustomSavingCompleted.Add(ID, AfterSave); } /// ///Remove an event that triggers after saving has occured. /// /// /// public void removeAfterSaveEvent(string ID, Action AfterSave) { SaveAnywhere.Instance.SaveManager.afterCustomSavingCompleted.Remove(ID); } /// /// Add in an event that triggers afer loading has occured. /// /// /// public void addAfterLoadEvent(string ID, Action AfterLoad) { SaveAnywhere.Instance.SaveManager.afterSaveLoaded.Add(ID, AfterLoad); } /// /// Remove an event that occurs after loading has occured. /// /// /// public void removeAfterLoadEvent(string ID, Action AfterLoad) { SaveAnywhere.Instance.SaveManager.afterSaveLoaded.Remove(ID); } } }