using Fantasy.DataStructure.Collection;
using Fantasy.Entitas;
using Fantasy.Helper;
using MongoDB.Bson.Serialization.Attributes;
using MongoDB.Bson.Serialization.Options;

namespace NB.Chat;

/// <summary>
/// 玩家邮件组件
/// </summary>
public class MailComponent : Entity
{
    /// <summary>
    /// 最大邮件数据
    /// </summary>
    public const int MaxMailCount = 50;

    /// <summary>
    /// 邮件最大保留时间
    /// </summary>
    public const long MaxExpireTime = TimeHelper.OneDay * 365;

    /// <summary>
    /// 邮件列表
    /// </summary>
    [BsonDictionaryOptions(DictionaryRepresentation.ArrayOfArrays)]
    public Dictionary<long, Mail> Mails = new Dictionary<long, Mail>();

    /// <summary>
    /// 按照时间进行排序
    /// </summary>
    [BsonIgnore] public readonly SortedOneToManyListPool<long, long> Timer = new SortedOneToManyListPool<long, long>();
}