using System; using System.Runtime.InteropServices; using Decal.Interop.Filters; namespace Decal.Adapter.Wrappers; public class EnchantmentWrapper : MarshalByRefObject, IDisposable { private Enchantment myEnchantment; private bool isDisposed; public double Adjustment => myEnchantment.Adjustment; public int Affected => myEnchantment.Affected; public int AffectedMask => myEnchantment.AffectedMask; public double Duration => myEnchantment.Duration; public int Family => myEnchantment.Family; public int Layer => myEnchantment.Layer; public int SpellId => myEnchantment.SpellID; public int TimeRemaining => myEnchantment.TimeRemaining; public DateTime Expires => DateTime.Now.AddSeconds(TimeRemaining); internal EnchantmentWrapper(Enchantment enchant) { myEnchantment = enchant; } ~EnchantmentWrapper() { Dispose(disposing: false); } public void Dispose() { Dispose(disposing: true); GC.SuppressFinalize(this); } protected virtual void Dispose(bool disposing) { if (!isDisposed) { } if (myEnchantment != null) { Marshal.ReleaseComObject(myEnchantment); } isDisposed = true; } protected void EnforceDisposedOnce() { if (isDisposed) { throw new ObjectDisposedException("EnchantmentWrapper"); } } }