namespace XGame.Framework.Asset
{
    /// <summary>
    /// 回收资源用的结构体
    /// 用于资源被业务异常销毁或者不可复制资源(贴图等)被大批量引用时清引用计数
    /// </summary>
    public struct RecycleObject
    {
        /// <summary>
        /// 使用IAssetManager.Load加载返回的对象
        /// </summary>
        public object asset;
        /// <summary>
        /// 引用计数
        /// </summary>
        public int reference;
        /// <summary>
        /// asset的HashCode
        /// </summary>
        public long hashcode;
        /// <summary>
        /// 是否立即销毁
        /// 只对GameObject有效
        /// </summary>
        public bool destroyImmediate;

        public RecycleObject(object asset)
        {
            this.asset = asset;
            reference = 1;
            hashcode = asset?.GetLongHashCode() ?? 0;
            destroyImmediate = false;
        }
    }
}

