提交示例代码
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
using Fantasy.DataStructure.Collection;
|
||||
using Fantasy.Entitas;
|
||||
|
||||
namespace Fantasy;
|
||||
|
||||
/// <summary>
|
||||
/// 邮件物流中转中心,用来存放所有离线的邮件。
|
||||
/// 玩家可以在上线的第一时间去这里领取属于自己的邮件。
|
||||
/// </summary>
|
||||
public class MailBoxManageComponent : Entity
|
||||
{
|
||||
// 定时清楚过期邮件的时间
|
||||
public const int MailCheckTIme = 10000;
|
||||
// 存放所有邮箱都会在这里,包括发送给个人的和所有人的邮件。
|
||||
public readonly Dictionary<long, MailBox> MailBoxes = new Dictionary<long, MailBox>();
|
||||
// 个人领取邮件列表
|
||||
public readonly OneToManyList<long, MailBox> MailsByAccount = new OneToManyList<long, MailBox>();
|
||||
// 按照邮件箱类型存储
|
||||
public readonly OneToManyList<int, MailBox> MailsByMailBoxType = new OneToManyList<int, MailBox>();
|
||||
// 按照时间排序的邮件箱
|
||||
public readonly SortedOneToManyList<long, long> Timers = new SortedOneToManyList<long, long>();
|
||||
// 临时的存放过期时间的队列
|
||||
public readonly Queue<long> TimeOutQueue = new Queue<long>();
|
||||
// 时间任务的Id
|
||||
public long TimerId;
|
||||
// 最小的时间
|
||||
public long MinTime;
|
||||
}
|
||||
23
邮件系统课程完整代码/Server/Entity/Mail/Components/MailComponent.cs
Normal file
23
邮件系统课程完整代码/Server/Entity/Mail/Components/MailComponent.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using Fantasy.DataStructure.Collection;
|
||||
using Fantasy.Entitas;
|
||||
using MongoDB.Bson.Serialization.Attributes;
|
||||
using MongoDB.Bson.Serialization.Options;
|
||||
|
||||
namespace Fantasy;
|
||||
|
||||
/// <summary>
|
||||
/// 这个代表一个用户身上所有邮件的组件
|
||||
/// </summary>
|
||||
public sealed class MailComponent : Entity
|
||||
{
|
||||
// 最大的邮件数量
|
||||
public const int MaxMailCount = 50;
|
||||
// 邮件的过期时间,这个是过期7天时间。
|
||||
public const int MailExpireTime = 1000 * 60 * 60 * 24 * 7;
|
||||
// 玩家的邮件
|
||||
[BsonDictionaryOptions(DictionaryRepresentation.ArrayOfArrays)]
|
||||
public Dictionary<long, Mail> Mails = new Dictionary<long, Mail>();
|
||||
// 按照时间进行排序
|
||||
[BsonIgnore]
|
||||
public readonly SortedOneToManyList<long, long> Timer = new SortedOneToManyList<long, long>();
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
using Fantasy.Entitas;
|
||||
|
||||
namespace Fantasy;
|
||||
|
||||
public sealed class MailUnitManageComponent : Entity
|
||||
{
|
||||
public readonly Dictionary<long, MailUnit> Online = new Dictionary<long, MailUnit>();
|
||||
public readonly Dictionary<string, MailUnit> UnitByName = new Dictionary<string, MailUnit>();
|
||||
public readonly Dictionary<long, MailUnit> UnitByAccountId = new Dictionary<long, MailUnit>();
|
||||
}
|
||||
Reference in New Issue
Block a user