ExtensibleSaveFormat.cs 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. using BepInEx;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. namespace ExtensibleSaveFormat
  7. {
  8. public class ExtensibleSaveFormat : BaseUnityPlugin
  9. {
  10. public override string ID => "com.bepis.bepinex.extendedsave";
  11. public override string Name => "Extensible Save Format";
  12. public override Version Version => new Version("1.0");
  13. void Awake()
  14. {
  15. Hooks.InstallHooks();
  16. }
  17. internal static Dictionary<ChaFile, Dictionary<string, object>> internalDictionary = new Dictionary<ChaFile, Dictionary<string, object>>();
  18. #region Events
  19. public delegate void CardEventHandler(ChaFile file);
  20. public static event CardEventHandler CardBeingSaved;
  21. public static event CardEventHandler CardBeingLoaded;
  22. internal static void writeEvent(ChaFile file)
  23. {
  24. CardBeingSaved?.Invoke(file);
  25. }
  26. internal static void readEvent(ChaFile file)
  27. {
  28. CardBeingLoaded?.Invoke(file);
  29. }
  30. #endregion
  31. public static bool TryGetExtendedFormat(ChaFile file, out Dictionary<string, object> extendedFormatData)
  32. {
  33. return internalDictionary.TryGetValue(file, out extendedFormatData);
  34. }
  35. public static void SetExtendedFormat(ChaFile file, Dictionary<string, object> extendedFormatData)
  36. {
  37. internalDictionary[file] = extendedFormatData;
  38. }
  39. }
  40. }