namespace Cthangover.Mods.Equipment { using Cthangover.Core.Mods; using Cthangover.Core.Settings; using Cthangover.Mods.Stats; /// Saves what everyone wears in the equipment slot. public class EquipmentSaveable : IModSaveable { private const string BlobKey = "Worn"; /// public void OnSave(ModSlot slot) { slot.Data[BlobKey] = new DataBlob(1, EquipmentService.Data); } /// public bool OnLoad(ModSlot slot, out string errorMessage) { errorMessage = null; EquipmentService.Data = new EquipmentStateData(); if (slot?.Data != null && slot.Data.TryGetValue(BlobKey, out var blob)) EquipmentService.Data = blob.ReadJson() ?? new EquipmentStateData(); StatsService.ClearCache(); return true; } } }