提交示例代码
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>();
|
||||
}
|
||||
8
邮件系统课程完整代码/Server/Entity/Mail/Entity/Item.cs
Normal file
8
邮件系统课程完整代码/Server/Entity/Mail/Entity/Item.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
using Fantasy.Entitas;
|
||||
|
||||
namespace Fantasy;
|
||||
|
||||
public sealed class Item : Entity
|
||||
{
|
||||
public string Name;
|
||||
}
|
||||
25
邮件系统课程完整代码/Server/Entity/Mail/Entity/Mail.cs
Normal file
25
邮件系统课程完整代码/Server/Entity/Mail/Entity/Mail.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
using Fantasy.Entitas;
|
||||
using MongoDB.Bson.Serialization.Attributes;
|
||||
using MongoDB.Bson.Serialization.Options;
|
||||
|
||||
namespace Fantasy;
|
||||
|
||||
/// <summary>
|
||||
/// 代表游戏中的一封邮件实体
|
||||
/// </summary>
|
||||
public sealed class Mail : Entity
|
||||
{
|
||||
// 这个代表里游戏中的一封邮件
|
||||
// 标题、内容、金钱、物品
|
||||
public long OwnerId; // 邮件拥有者的Id(AccountId、UnitId、RoleId)
|
||||
public string Title; // 邮件的标题
|
||||
public string Content; // 邮件的内容
|
||||
public long CreateTime; // 邮件的创建时间
|
||||
public long ExpireTime; // 邮件的过期时间(决定这个实体的生命周期)
|
||||
public int Money; // 邮件的中钱
|
||||
public MailState MailState; // 邮件的状态
|
||||
public MailType MailType; // 邮件的类型
|
||||
public List<Item> Items = new List<Item>(); // 邮件中的物品
|
||||
// [BsonDictionaryOptions(DictionaryRepresentation.ArrayOfArrays)]
|
||||
// public Dictionary<long,Item> Items = new Dictionary<long,Item>();
|
||||
}
|
||||
24
邮件系统课程完整代码/Server/Entity/Mail/Entity/MailBox.cs
Normal file
24
邮件系统课程完整代码/Server/Entity/Mail/Entity/MailBox.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using Fantasy.Entitas;
|
||||
|
||||
namespace Fantasy;
|
||||
|
||||
/// <summary>
|
||||
/// 邮件箱
|
||||
/// </summary>
|
||||
public sealed class MailBox : Entity
|
||||
{
|
||||
// 快递
|
||||
// 快递包装、用盒子。然后这个盒子上有一个标签、收件人、发件人、快递的公司。
|
||||
// 这个盒子了。可以装任何不同种类的东西。
|
||||
// 一对一、我发一个快递,给张三和李四。
|
||||
|
||||
// 但是邮件可能会有这个的功能,比如给某一个范围的人发送同一份邮件,比如补偿、或者奖励。
|
||||
|
||||
public Mail Mail; // 邮件
|
||||
public long CreateTime; // 箱子的创建时间
|
||||
public long ExpireTime; // 箱子的过期时间
|
||||
public MailBoxType MailBoxType; // 箱子的类型
|
||||
public HashSet<long> AccountId = new HashSet<long>(); // 收件人
|
||||
public HashSet<long> Received = new HashSet<long>(); // 领取过的人
|
||||
public long SendAccountId; // 发件人/发送人
|
||||
}
|
||||
13
邮件系统课程完整代码/Server/Entity/Mail/Entity/MailUnit.cs
Normal file
13
邮件系统课程完整代码/Server/Entity/Mail/Entity/MailUnit.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using Fantasy.Entitas;
|
||||
using MongoDB.Bson.Serialization.Attributes;
|
||||
|
||||
namespace Fantasy;
|
||||
|
||||
public sealed class MailUnit : Entity
|
||||
{
|
||||
public string Name;
|
||||
public long AccountId;
|
||||
public long CreateTime;
|
||||
[BsonIgnore]
|
||||
public long GateRouteId;
|
||||
}
|
||||
37
邮件系统课程完整代码/Server/Entity/Mail/Enum/MailEnum.cs
Normal file
37
邮件系统课程完整代码/Server/Entity/Mail/Enum/MailEnum.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
using CommandLine;
|
||||
|
||||
namespace Fantasy;
|
||||
|
||||
public enum MailType
|
||||
{
|
||||
None = 0,
|
||||
System = 1, // 系统邮件
|
||||
Rewards = 2, // 奖励邮件(擂台、有奖问答)
|
||||
User = 3, // 个人邮件(玩家给玩家之间发送)
|
||||
}
|
||||
|
||||
public enum MailState
|
||||
{
|
||||
None = 0,
|
||||
Unread = 1, // 未读
|
||||
HaveRead = 2, // 已读
|
||||
NotClaimed = 3, // 未领取
|
||||
Received = 4, // 已领取
|
||||
}
|
||||
|
||||
public enum MailBoxType
|
||||
{
|
||||
None = 0,
|
||||
Specify = 1, // 指定目标
|
||||
Online = 2, // 给在线所有人发送邮件
|
||||
All = 3, // 所有人
|
||||
AllToDate = 4, // 根据玩家注册的时间发送邮件
|
||||
}
|
||||
|
||||
public enum MailRemoveActionType
|
||||
{
|
||||
None = 0,
|
||||
Remove = 1, // 手动移除
|
||||
ExpireTimeRemove = 2, // 过期时间移除
|
||||
Overtop = 3, // 超过邮件上限移除
|
||||
}
|
||||
Reference in New Issue
Block a user