diff --git a/Entity/Entity.csproj b/Entity/Entity.csproj
index 891c4b4..fed989a 100644
--- a/Entity/Entity.csproj
+++ b/Entity/Entity.csproj
@@ -19,6 +19,8 @@
+
+
diff --git a/Entity/Game/Social/Chat/Components/ChatChannelCenterComponent.cs b/Entity/Game/Chat/Components/ChatChannelCenterComponent.cs
similarity index 100%
rename from Entity/Game/Social/Chat/Components/ChatChannelCenterComponent.cs
rename to Entity/Game/Chat/Components/ChatChannelCenterComponent.cs
diff --git a/Entity/Game/Social/Chat/Components/ChatChannelComponent.cs b/Entity/Game/Chat/Components/ChatChannelComponent.cs
similarity index 100%
rename from Entity/Game/Social/Chat/Components/ChatChannelComponent.cs
rename to Entity/Game/Chat/Components/ChatChannelComponent.cs
diff --git a/Entity/Game/Social/Chat/Enum/ChatChannelType.cs b/Entity/Game/Chat/Enum/ChatChannelType.cs
similarity index 100%
rename from Entity/Game/Social/Chat/Enum/ChatChannelType.cs
rename to Entity/Game/Chat/Enum/ChatChannelType.cs
diff --git a/Entity/Game/Social/Chat/Model/ChatInfoTree.cs b/Entity/Game/Chat/Model/ChatInfoTree.cs
similarity index 100%
rename from Entity/Game/Social/Chat/Model/ChatInfoTree.cs
rename to Entity/Game/Chat/Model/ChatInfoTree.cs
diff --git a/Entity/Game/Social/Chat/Model/ChatUnit.cs b/Entity/Game/Chat/Model/ChatUnit.cs
similarity index 100%
rename from Entity/Game/Social/Chat/Model/ChatUnit.cs
rename to Entity/Game/Chat/Model/ChatUnit.cs
diff --git a/Entity/Game/Social/Club/Club.cs b/Entity/Game/Club/Club.cs
similarity index 100%
rename from Entity/Game/Social/Club/Club.cs
rename to Entity/Game/Club/Club.cs
diff --git a/Entity/Game/Social/Club/ClubManageComponent.cs b/Entity/Game/Club/ClubManageComponent.cs
similarity index 100%
rename from Entity/Game/Social/Club/ClubManageComponent.cs
rename to Entity/Game/Club/ClubManageComponent.cs
diff --git a/Entity/Game/Item/IItemUse.cs b/Entity/Game/Item/IItemUse.cs
new file mode 100644
index 0000000..70a3d55
--- /dev/null
+++ b/Entity/Game/Item/IItemUse.cs
@@ -0,0 +1,42 @@
+namespace NB.Game;
+
+[AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = false)]
+public sealed class ItemUseAttribute : Attribute
+{
+ public ItemUseEffect Type { get; }
+
+ public ItemUseAttribute(ItemUseEffect type)
+ {
+ Type = type;
+ }
+}
+
+public enum ItemUseEffect
+{
+ None = 0,
+ Equip = 1, // 装备到身上
+ UnEquip = 2, // 从身上卸下
+ AddAttr = 3, // 增加属性
+ CutAttr = 4, // 减少属性
+}
+
+public interface IItemUse
+{
+ ///
+ /// 正常的情况下,应该是使用Unit,因为这个代表的是某一个单位。
+ /// 由于课程中没有这个Unit,所以暂时用Account来代替。
+ ///
+ ///
+ ///
+ ///
+ ///
+ uint CanUse(Player player, cfg.Item config, ref int count);
+
+ ///
+ /// 使用物品的逻辑。
+ ///
+ ///
+ ///
+ ///
+ void Use(Player player, cfg.Item config, ref int count);
+}
\ No newline at end of file
diff --git a/Entity/Game/Item/Item.cs b/Entity/Game/Item/Item.cs
index 86f2e20..6a8c6cc 100644
--- a/Entity/Game/Item/Item.cs
+++ b/Entity/Game/Item/Item.cs
@@ -9,7 +9,7 @@ public enum ItemBasicType
Currency = 1,
Item = 2,
Rod = 3,
- Reel =4,
+ Reel = 4,
Bobber = 5,
Line = 6,
Bait = 7,
@@ -60,4 +60,4 @@ public class Item : Entity
/// 正则使用中
///
[BsonIgnore] public bool InUse;
-}
\ No newline at end of file
+}
diff --git a/Entity/Game/Item/ItemUseComponent.cs b/Entity/Game/Item/ItemUseComponent.cs
new file mode 100644
index 0000000..a9d6e6a
--- /dev/null
+++ b/Entity/Game/Item/ItemUseComponent.cs
@@ -0,0 +1,196 @@
+using Fantasy;
+using Fantasy.Assembly;
+using Fantasy.Async;
+using Fantasy.DataStructure.Collection;
+using Fantasy.Entitas;
+
+namespace NB.Game;
+
+public class ItemUseComponent : Entity, IAssemblyLifecycle
+{
+ private readonly Dictionary _handlers = new Dictionary();
+ private readonly OneToManyList _assemblyHandlers = new OneToManyList();
+
+ public override void Dispose()
+ {
+ base.Dispose();
+ _handlers.Clear();
+ _assemblyHandlers.Clear();
+ }
+
+ public async FTask Initialize()
+ {
+ // 注册到生命周期中
+ await AssemblyLifecycle.Add(this);
+ }
+
+ #region Assembly
+
+ public async FTask OnLoad(AssemblyManifest assemblyManifest)
+ {
+ var tcs = FTask.Create(false);
+ Scene.ThreadSynchronizationContext.Post(() =>
+ {
+ InnerLoad(assemblyManifest);
+ tcs.SetResult();
+ });
+ await tcs;
+ }
+
+ public async FTask OnUnload(AssemblyManifest assemblyManifest)
+ {
+ var tcs = FTask.Create(false);
+ Scene.ThreadSynchronizationContext.Post(() =>
+ {
+ InnerUnLoad(assemblyManifest);
+ tcs.SetResult();
+ });
+ await tcs;
+ }
+
+ private void InnerLoad(AssemblyManifest assemblyManifest)
+ {
+ var assembly = assemblyManifest.Assembly;
+ var assemblyIdentity = assemblyManifest.AssemblyManifestId;
+
+ foreach (var type in assembly.GetTypes())
+ {
+ if (!typeof(IItemUse).IsAssignableFrom(type))
+ {
+ continue;
+ }
+
+ if (type.IsInterface || type.IsAbstract)
+ {
+ continue;
+ }
+
+ var customAttributes = type.GetCustomAttributes(typeof(ItemUseAttribute), false);
+ if (customAttributes.Length == 0)
+ {
+ Log.Warning(
+ $"type {type.FullName} Implemented the interface of IItemUse, requiring the implementation of ItemUseAttribute");
+ continue;
+ }
+
+ var instance = (IItemUse)Activator.CreateInstance(type)!;
+ foreach (ItemUseAttribute customAttribute in customAttributes)
+ {
+ var customAttributeType = (int)customAttribute.Type;
+ _handlers.Add(customAttributeType, instance);
+ _assemblyHandlers.Add(assemblyIdentity, customAttributeType);
+ }
+ }
+ }
+
+ private void InnerUnLoad(AssemblyManifest assemblyManifest)
+ {
+ var assemblyIdentity = assemblyManifest.AssemblyManifestId;
+ if (!_assemblyHandlers.TryGetValue(assemblyIdentity, out var assemblyHandlers))
+ {
+ return;
+ }
+
+ foreach (var assemblyHandler in assemblyHandlers)
+ {
+ _handlers.Remove(assemblyHandler);
+ }
+
+ _assemblyHandlers.Remove(assemblyIdentity);
+ }
+
+ #endregion
+
+ public uint CanUse(Player account, cfg.Item config, ref int count)
+ {
+ var itemUseEffect = (ItemUseEffect)config.Effect;
+
+ if (itemUseEffect == ItemUseEffect.None)
+ {
+ Log.Error($"config.Effect is zero!");
+ return 1;
+ }
+
+ return CanUse(account, config, itemUseEffect, ref count);
+ }
+
+ public void Use(Player account, cfg.Item config, ref int count)
+ {
+ var itemUseEffect = (ItemUseEffect)config.Effect;
+
+ if (itemUseEffect == ItemUseEffect.None)
+ {
+ Log.Error($"config.Effect is zero!");
+ return;
+ }
+
+ if (!_handlers.TryGetValue((int)itemUseEffect, out var handler))
+ {
+ return;
+ }
+
+ handler.Use(account, config, ref count);
+ }
+
+ public uint UseHandler(Player account, cfg.Item config, ref int count)
+ {
+ var itemUseEffect = (ItemUseEffect)config.Effect;
+
+ if (itemUseEffect == ItemUseEffect.None)
+ {
+ Log.Error($"config.Effect is zero!");
+ return 1;
+ }
+
+ if (!_handlers.TryGetValue((int)itemUseEffect, out var handler))
+ {
+ return 0;
+ }
+
+ var canUse = handler.CanUse(account, config, ref count);
+ if (canUse != 0)
+ {
+ return canUse;
+ }
+
+ handler.Use(account, config, ref count);
+ return 0;
+ }
+
+ public uint CanUse(Player account, cfg.Item config, ItemUseEffect itemUseEffect, ref int count)
+ {
+ if (!_handlers.TryGetValue((int)itemUseEffect, out var handler))
+ {
+ return 0;
+ }
+
+ return handler.CanUse(account, config, ref count);
+ }
+
+ public void Use(Player account, cfg.Item config, ItemUseEffect itemUseEffect, ref int count)
+ {
+ if (!_handlers.TryGetValue((int)itemUseEffect, out var handler))
+ {
+ return;
+ }
+
+ handler.Use(account, config, ref count);
+ }
+
+ public uint UseHandler(Player account, cfg.Item config, ItemUseEffect itemUseEffect, ref int count)
+ {
+ if (!_handlers.TryGetValue((int)itemUseEffect, out var handler))
+ {
+ return 0;
+ }
+
+ var canUse = handler.CanUse(account, config, ref count);
+ if (canUse != 0)
+ {
+ return canUse;
+ }
+
+ handler.Use(account, config, ref count);
+ return 0;
+ }
+}
\ No newline at end of file
diff --git a/Entity/Game/Mail/Components/MailBoxManageComponent.cs b/Entity/Game/Mail/Components/MailBoxManageComponent.cs
new file mode 100644
index 0000000..1a5d369
--- /dev/null
+++ b/Entity/Game/Mail/Components/MailBoxManageComponent.cs
@@ -0,0 +1,36 @@
+using Fantasy;
+using Fantasy.DataStructure.Collection;
+using Fantasy.Entitas;
+
+namespace NB;
+
+///
+/// 邮件物流中转中心,用来存放所有离线的邮件。
+/// 玩家可以在上线的第一时间去这里领取属于自己的邮件。
+///
+public class MailBoxManageComponent : Entity
+{
+ // 定时清楚过期邮件的时间
+ public const int MailCheckTIme = 10000;
+
+ // 存放所有邮箱都会在这里,包括发送给个人的和所有人的邮件。
+ public readonly Dictionary MailBoxes = new Dictionary();
+
+ // 个人领取邮件列表
+ public readonly OneToManyList MailsByAccount = new OneToManyList();
+
+ // 按照邮件箱类型存储
+ public readonly OneToManyList MailsByMailBoxType = new OneToManyList();
+
+ // 按照时间排序的邮件箱
+ public readonly SortedOneToManyList Timers = new SortedOneToManyList();
+
+ // 临时的存放过期时间的队列
+ public readonly Queue TimeOutQueue = new Queue();
+
+ // 时间任务的Id
+ public long TimerId;
+
+ // 最小的时间
+ public long MinTime;
+}
\ No newline at end of file
diff --git a/Entity/Game/Mail/Components/MailComponent.cs b/Entity/Game/Mail/Components/MailComponent.cs
new file mode 100644
index 0000000..2156845
--- /dev/null
+++ b/Entity/Game/Mail/Components/MailComponent.cs
@@ -0,0 +1,27 @@
+using System.Collections.Generic;
+using Fantasy.DataStructure.Collection;
+using Fantasy.Entitas;
+using Fantasy.Helper;
+using MongoDB.Bson.Serialization.Attributes;
+using MongoDB.Bson.Serialization.Options;
+
+namespace NB;
+
+///
+/// 这个代表一个用户身上所有邮件的组件
+///
+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 Mails = new Dictionary();
+
+ // 按照时间进行排序
+ [BsonIgnore] public readonly SortedOneToManyList Timer = new SortedOneToManyList();
+}
\ No newline at end of file
diff --git a/Entity/Game/Mail/Entity/Mail.cs b/Entity/Game/Mail/Entity/Mail.cs
new file mode 100644
index 0000000..aca74c7
--- /dev/null
+++ b/Entity/Game/Mail/Entity/Mail.cs
@@ -0,0 +1,26 @@
+using System.Collections.Generic;
+using Fantasy.Entitas;
+using MongoDB.Bson.Serialization.Attributes;
+using NB.Game;
+
+namespace NB;
+
+///
+/// 代表游戏中的一封邮件实体
+///
+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- Items = new List
- (); // 邮件中的物品
+ // [BsonDictionaryOptions(DictionaryRepresentation.ArrayOfArrays)]
+ // public Dictionary Items = new Dictionary();
+}
\ No newline at end of file
diff --git a/Entity/Game/Mail/Entity/MailBox.cs b/Entity/Game/Mail/Entity/MailBox.cs
new file mode 100644
index 0000000..eea7bfd
--- /dev/null
+++ b/Entity/Game/Mail/Entity/MailBox.cs
@@ -0,0 +1,25 @@
+using System.Collections.Generic;
+using Fantasy.Entitas;
+using NB;
+
+namespace Fantasy;
+
+///
+/// 邮件箱
+///
+public sealed class MailBox : Entity
+{
+ // 快递
+ // 快递包装、用盒子。然后这个盒子上有一个标签、收件人、发件人、快递的公司。
+ // 这个盒子了。可以装任何不同种类的东西。
+ // 一对一、我发一个快递,给张三和李四。
+
+ // 但是邮件可能会有这个的功能,比如给某一个范围的人发送同一份邮件,比如补偿、或者奖励。
+ public Mail Mail; // 邮件
+ public long CreateTime; // 箱子的创建时间
+ public long ExpireTime; // 箱子的过期时间
+ public MailBoxType MailBoxType; // 箱子的类型
+ public HashSet AccountId = new HashSet(); // 收件人
+ public HashSet Received = new HashSet(); // 领取过的人
+ public long SendAccountId; // 发件人/发送人
+}
\ No newline at end of file
diff --git a/Entity/Game/Mail/Entity/MailConversation.cs b/Entity/Game/Mail/Entity/MailConversation.cs
new file mode 100644
index 0000000..a736abd
--- /dev/null
+++ b/Entity/Game/Mail/Entity/MailConversation.cs
@@ -0,0 +1,58 @@
+// using System.Collections.Generic;
+// using Fantasy.Entitas;
+// using MongoDB.Bson.Serialization.Attributes;
+//
+// namespace NB.Chat;
+//
+// public class MailConversation : Entity
+// {
+// ///
+// /// 第一id
+// ///
+// [BsonElement("id1")] public long FirstId;
+//
+// ///
+// /// 第二id
+// ///
+// [BsonElement("id2")] public long SecondId;
+//
+// ///
+// /// 会话
+// ///
+// [BsonElement("list")] public List Mails = new List();
+//
+// ///
+// /// 第一个阅读时间
+// ///
+// [BsonElement("ft")] public long FirstReadTime;
+//
+// ///
+// /// 第二阅读时间
+// ///
+// [BsonElement("st")] public long SecondReadTime;
+//
+// ///
+// /// 最后更新时间
+// ///
+// [BsonElement("ut")] public long UpdateTime;
+//
+// ///
+// /// 删除人标志
+// ///
+// [BsonElement("rid")] public HashSet RemoveId = new HashSet();
+//
+// ///
+// /// 会话key,id-id,按大小排序
+// ///
+// [BsonIgnore] public string Key = string.Empty;
+//
+// ///
+// /// 最后保存时间
+// ///
+// [BsonIgnore] public long NeedSaveTime = 0;
+//
+// ///
+// /// 需要保存
+// ///
+// [BsonIgnore] public bool NeedSave;
+// }
\ No newline at end of file
diff --git a/Entity/Game/Mail/Enum/MailEnum.cs b/Entity/Game/Mail/Enum/MailEnum.cs
new file mode 100644
index 0000000..cee3a08
--- /dev/null
+++ b/Entity/Game/Mail/Enum/MailEnum.cs
@@ -0,0 +1,35 @@
+namespace NB;
+
+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, // 超过邮件上限移除
+}
\ No newline at end of file
diff --git a/Entity/Game/Player/Player.cs b/Entity/Game/Player/Player.cs
index 624e133..c20b152 100644
--- a/Entity/Game/Player/Player.cs
+++ b/Entity/Game/Player/Player.cs
@@ -62,6 +62,11 @@ public sealed class Player : Entity
///
[BsonElement("vExTime")] public long VipExpirationTime;
+ ///
+ /// 创建时间
+ ///
+ public long CreateTime;
+
[BsonIgnore] public long SessionRunTimeId;
diff --git a/Entity/Game/Social/Mail/Components/MailComponent.cs b/Entity/Game/Social/Mail/Components/MailComponent.cs
deleted file mode 100644
index b2fee75..0000000
--- a/Entity/Game/Social/Mail/Components/MailComponent.cs
+++ /dev/null
@@ -1,35 +0,0 @@
-using System.Collections.Generic;
-using Fantasy.DataStructure.Collection;
-using Fantasy.Entitas;
-using Fantasy.Helper;
-using MongoDB.Bson.Serialization.Attributes;
-using MongoDB.Bson.Serialization.Options;
-
-namespace NB.Chat;
-
-///
-/// 玩家邮件组件
-///
-public class MailComponent : Entity
-{
- ///
- /// 最大邮件数据
- ///
- public const int MaxMailCount = 50;
-
- ///
- /// 邮件最大保留时间
- ///
- public const long MaxExpireTime = TimeHelper.OneDay * 365;
-
- ///
- /// 邮件列表
- ///
- [BsonDictionaryOptions(DictionaryRepresentation.ArrayOfArrays)]
- public Dictionary Mails = new Dictionary();
-
- ///
- /// 按照时间进行排序
- ///
- [BsonIgnore] public readonly SortedOneToManyListPool Timer = new SortedOneToManyListPool();
-}
\ No newline at end of file
diff --git a/Entity/Game/Social/Mail/Components/MailManageComponent.cs b/Entity/Game/Social/Mail/Components/MailManageComponent.cs
deleted file mode 100644
index edb6bae..0000000
--- a/Entity/Game/Social/Mail/Components/MailManageComponent.cs
+++ /dev/null
@@ -1,20 +0,0 @@
-using System.Collections.Generic;
-using Fantasy.Entitas;
-
-namespace NB.Chat;
-
-///
-/// 邮件管理组件
-///
-public class MailManageComponent : Entity
-{
- ///
- /// 会话列表
- ///
- public Dictionary Conversations = new Dictionary();
-
- ///
- /// 缓存了的列表
- ///
- public HashSet CacheRoleIds = new HashSet();
-}
\ No newline at end of file
diff --git a/Entity/Game/Social/Mail/Entity/Mail.cs b/Entity/Game/Social/Mail/Entity/Mail.cs
deleted file mode 100644
index c1fb940..0000000
--- a/Entity/Game/Social/Mail/Entity/Mail.cs
+++ /dev/null
@@ -1,49 +0,0 @@
-using System.Collections.Generic;
-using Fantasy.Entitas;
-using MongoDB.Bson.Serialization.Attributes;
-using NB.Game;
-
-namespace NB.Chat;
-
-public sealed class Mail : Entity
-{
- ///
- /// 邮件发送者
- ///
- [BsonElement("send")] public long Sender;
-
- ///
- /// 邮件拥有者
- ///
- [BsonElement("owner")] public long OwnerId;
-
- ///
- /// 邮件状态
- ///
- [BsonElement("state")] public MailState State = MailState.None;
-
- ///
- /// 邮件状态
- ///
- [BsonElement("type")] public MailType MailType = MailType.None;
-
- ///
- /// 邮件内容
- ///
- [BsonElement("con")] public string Content;
-
- ///
- /// 创建时间
- ///
- [BsonElement("ct")] public long CreateTime;
-
- ///
- /// 过期时间
- ///
- [BsonElement("et")] public long ExpireTime;
-
- ///
- /// 邮件的附件内容
- ///
- [BsonElement("item")] public List Items = new List();
-}
\ No newline at end of file
diff --git a/Entity/Game/Social/Mail/Entity/MailBox.cs b/Entity/Game/Social/Mail/Entity/MailBox.cs
deleted file mode 100644
index 0e04a99..0000000
--- a/Entity/Game/Social/Mail/Entity/MailBox.cs
+++ /dev/null
@@ -1,45 +0,0 @@
-using System.Collections.Generic;
-using Fantasy.Entitas;
-
-namespace NB.Chat;
-
-///
-/// 邮件箱,系统群发用
-///
-public class MailBox : Entity
-{
- ///
- /// 邮件
- ///
- public Mail Mail;
-
- ///
- /// 创建时间
- ///
- public long CreateTime;
-
- ///
- /// 失效时间
- ///
- public long ExpireTime;
-
- ///
- /// 邮箱类型
- ///
- public MailBoxType BoxType;
-
- ///
- /// 发送人
- ///
- public long SendAccountId = 0;
-
- ///
- /// 收件人
- ///
- public HashSet AccountId = new HashSet();
-
- ///
- /// 领取过的人
- ///
- public HashSet Received = new HashSet();
-}
\ No newline at end of file
diff --git a/Entity/Game/Social/Mail/Entity/MailConversation.cs b/Entity/Game/Social/Mail/Entity/MailConversation.cs
deleted file mode 100644
index bb663b9..0000000
--- a/Entity/Game/Social/Mail/Entity/MailConversation.cs
+++ /dev/null
@@ -1,58 +0,0 @@
-using System.Collections.Generic;
-using Fantasy.Entitas;
-using MongoDB.Bson.Serialization.Attributes;
-
-namespace NB.Chat;
-
-public class MailConversation : Entity
-{
- ///
- /// 第一id
- ///
- [BsonElement("id1")] public long FirstId;
-
- ///
- /// 第二id
- ///
- [BsonElement("id2")] public long SecondId;
-
- ///
- /// 会话
- ///
- [BsonElement("list")] public List Mails = new List();
-
- ///
- /// 第一个阅读时间
- ///
- [BsonElement("ft")] public long FirstReadTime;
-
- ///
- /// 第二阅读时间
- ///
- [BsonElement("st")] public long SecondReadTime;
-
- ///
- /// 最后更新时间
- ///
- [BsonElement("ut")] public long UpdateTime;
-
- ///
- /// 删除人标志
- ///
- [BsonElement("rid")] public HashSet RemoveId = new HashSet();
-
- ///
- /// 会话key,id-id,按大小排序
- ///
- [BsonIgnore] public string Key = string.Empty;
-
- ///
- /// 最后保存时间
- ///
- [BsonIgnore] public long NeedSaveTime = 0;
-
- ///
- /// 需要保存
- ///
- [BsonIgnore] public bool NeedSave;
-}
\ No newline at end of file
diff --git a/Entity/Game/Social/Mail/Enum/MailEnum.cs b/Entity/Game/Social/Mail/Enum/MailEnum.cs
deleted file mode 100644
index 9068185..0000000
--- a/Entity/Game/Social/Mail/Enum/MailEnum.cs
+++ /dev/null
@@ -1,54 +0,0 @@
-namespace NB.Chat;
-
-public enum MailType
-{
- None = 0,
- System = 1, //系统邮件
- Rewards = 2, //奖励邮件
- User = 3, //个人邮件
-}
-
-public enum MailState
-{
- None = 0,
-
- ///
- /// 未读
- ///
- Unread = 1,
-
- ///
- /// 已读
- ///
- HaveRead = 2,
-
- ///
- /// 未领取
- ///
- NotClaimed = 3,
-
- ///
- /// 已领取
- ///
- Received = 4,
-
- ///
- /// 已删除
- ///
- Deleted = 5,
-}
-
-public enum MailBoxType
-{
- None = 0,
-
- ///
- /// 指定目标
- ///
- Specify = 1,
-
- ///
- /// 全部人
- ///
- All = 2
-}
\ No newline at end of file
diff --git a/Entity/Game/Social/SocialUnit.cs b/Entity/Game/Social/SocialUnit.cs
deleted file mode 100644
index e6fe65f..0000000
--- a/Entity/Game/Social/SocialUnit.cs
+++ /dev/null
@@ -1,33 +0,0 @@
-// using Fantasy;
-// using Fantasy.Entitas;
-//
-// namespace NB.Chat;
-//
-// public sealed class SocialUnit : Entity
-// {
-// public long GateRouteId;
-//
-// public RoleSimpleInfo Role;
-//
-// ///
-// /// 当前所在地图
-// ///
-// public long MapId;
-//
-//
-// public readonly Dictionary Channels = new();
-// public readonly Dictionary SendTime = new Dictionary();
-//
-//
-// public override void Dispose()
-// {
-// if (IsDisposed)
-// {
-// return;
-// }
-//
-// GateRouteId = 0;
-// Role = null;
-// base.Dispose();
-// }
-// }
\ No newline at end of file
diff --git a/Entity/Game/Social/SocialUnitManageComponent.cs b/Entity/Game/Social/SocialUnitManageComponent.cs
deleted file mode 100644
index 20f0c34..0000000
--- a/Entity/Game/Social/SocialUnitManageComponent.cs
+++ /dev/null
@@ -1,17 +0,0 @@
-// using System.Collections.Generic;
-// using Fantasy;
-// using Fantasy.DataStructure.Collection;
-// using Fantasy.Entitas;
-//
-// namespace NB.Chat;
-//
-// public class SocialUnitManageComponent : Entity
-// {
-// public readonly Dictionary Units = new();
-//
-// // public List
-// // ///
-// // /// 不在线消息缓存
-// // ///
-// // public readonly OneToManyList NotSendMessage = new();
-// }
\ No newline at end of file
diff --git a/Entity/Generate/ConfigTable/Fish.cs b/Entity/Generate/ConfigTable/Fish.cs
index d28a56a..e7b2813 100644
--- a/Entity/Generate/ConfigTable/Fish.cs
+++ b/Entity/Generate/ConfigTable/Fish.cs
@@ -25,6 +25,7 @@ public sealed partial class Fish : Luban.BeanBase
MinWeight = (int)_obj.GetValue("min_weight");
MaxWeight = (int)_obj.GetValue("max_weight");
Accept = (int)_obj.GetValue("accept");
+ Water = (int)_obj.GetValue("water");
}
public static Fish DeserializeFish(JToken _buf)
@@ -52,6 +53,10 @@ public sealed partial class Fish : Luban.BeanBase
/// 接受的鱼饵配置组
///
public readonly int Accept;
+ ///
+ /// 需要的水
+ ///
+ public readonly int Water;
public const int __ID__ = 2189944;
@@ -69,6 +74,7 @@ public sealed partial class Fish : Luban.BeanBase
+ "minWeight:" + MinWeight + ","
+ "maxWeight:" + MaxWeight + ","
+ "accept:" + Accept + ","
+ + "water:" + Water + ","
+ "}";
}
}
diff --git a/Entity/Generate/ConfigTable/Item.cs b/Entity/Generate/ConfigTable/Item.cs
index 6205232..b563729 100644
--- a/Entity/Generate/ConfigTable/Item.cs
+++ b/Entity/Generate/ConfigTable/Item.cs
@@ -28,6 +28,7 @@ public sealed partial class Item : Luban.BeanBase
Length = (int)_obj.GetValue("length");
Max = (int)_obj.GetValue("max");
AutoUse = (int)_obj.GetValue("auto_use");
+ Effect = (int)_obj.GetValue("effect");
{ var __json0 = _obj.GetValue("result1"); Result1 = new System.Collections.Generic.List((__json0 as JArray).Count); foreach(JToken __e0 in __json0) { int __v0; __v0 = (int)__e0; Result1.Add(__v0); } }
{ var __json0 = _obj.GetValue("result2"); Result2 = new System.Collections.Generic.List((__json0 as JArray).Count); foreach(JToken __e0 in __json0) { string __v0; __v0 = (string)__e0; Result2.Add(__v0); } }
}
@@ -70,6 +71,10 @@ public sealed partial class Item : Luban.BeanBase
///
public readonly int AutoUse;
///
+ /// 使用效果
+ ///
+ public readonly int Effect;
+ ///
/// 使用参数1
///
public readonly System.Collections.Generic.List Result1;
@@ -97,6 +102,7 @@ public sealed partial class Item : Luban.BeanBase
+ "length:" + Length + ","
+ "max:" + Max + ","
+ "autoUse:" + AutoUse + ","
+ + "effect:" + Effect + ","
+ "result1:" + Luban.StringUtil.CollectionToString(Result1) + ","
+ "result2:" + Luban.StringUtil.CollectionToString(Result2) + ","
+ "}";
diff --git a/Entity/Generate/ConfigTable/Leader.cs b/Entity/Generate/ConfigTable/Leader.cs
new file mode 100644
index 0000000..7a6aeb1
--- /dev/null
+++ b/Entity/Generate/ConfigTable/Leader.cs
@@ -0,0 +1,64 @@
+
+//------------------------------------------------------------------------------
+//
+// This code was generated by a tool.
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+//
+//------------------------------------------------------------------------------
+
+using Luban;
+using Newtonsoft.Json.Linq;
+
+
+
+namespace cfg
+{
+
+public sealed partial class Leader : Luban.BeanBase
+{
+ public Leader(JToken _buf)
+ {
+ JObject _obj = _buf as JObject;
+ Id = (int)_obj.GetValue("id");
+ Strength = (int)_obj.GetValue("strength");
+ Size = (int)_obj.GetValue("size");
+ }
+
+ public static Leader DeserializeLeader(JToken _buf)
+ {
+ return new Leader(_buf);
+ }
+
+ ///
+ /// Id
+ ///
+ public readonly int Id;
+ ///
+ /// 强度
+ ///
+ public readonly int Strength;
+ ///
+ /// 尺寸
+ ///
+ public readonly int Size;
+
+
+ public const int __ID__ = -2022887127;
+ public override int GetTypeId() => __ID__;
+
+ public void ResolveRef(Tables tables)
+ {
+ }
+
+ public override string ToString()
+ {
+ return "{ "
+ + "id:" + Id + ","
+ + "strength:" + Strength + ","
+ + "size:" + Size + ","
+ + "}";
+ }
+}
+}
+
diff --git a/Entity/Generate/ConfigTable/Tables.cs b/Entity/Generate/ConfigTable/Tables.cs
index 6ab08f0..5f3cc19 100644
--- a/Entity/Generate/ConfigTable/Tables.cs
+++ b/Entity/Generate/ConfigTable/Tables.cs
@@ -50,6 +50,10 @@ public partial class Tables
///
public TbItem TbItem {get; }
///
+ /// 引线
+ ///
+ public TbLeader TbLeader {get; }
+ ///
/// 鱼线
///
public TbLine TbLine {get; }
@@ -82,6 +86,7 @@ public partial class Tables
TbHook = new TbHook(loader("tbhook"));
TbInitItemConfig = new TbInitItemConfig(loader("tbinititemconfig"));
TbItem = new TbItem(loader("tbitem"));
+ TbLeader = new TbLeader(loader("tbleader"));
TbLine = new TbLine(loader("tbline"));
TbLure = new TbLure(loader("tblure"));
TbReel = new TbReel(loader("tbreel"));
@@ -101,6 +106,7 @@ public partial class Tables
TbHook.ResolveRef(this);
TbInitItemConfig.ResolveRef(this);
TbItem.ResolveRef(this);
+ TbLeader.ResolveRef(this);
TbLine.ResolveRef(this);
TbLure.ResolveRef(this);
TbReel.ResolveRef(this);
diff --git a/Entity/Generate/ConfigTable/TbLeader.cs b/Entity/Generate/ConfigTable/TbLeader.cs
new file mode 100644
index 0000000..2189b0c
--- /dev/null
+++ b/Entity/Generate/ConfigTable/TbLeader.cs
@@ -0,0 +1,58 @@
+
+//------------------------------------------------------------------------------
+//
+// This code was generated by a tool.
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+//
+//------------------------------------------------------------------------------
+
+using Newtonsoft.Json.Linq;
+using Luban;
+
+
+
+namespace cfg
+{
+
+///
+/// 引线
+///
+public partial class TbLeader
+{
+ private readonly System.Collections.Generic.Dictionary _dataMap;
+ private readonly System.Collections.Generic.List _dataList;
+
+ public TbLeader(JArray _buf)
+ {
+ _dataMap = new System.Collections.Generic.Dictionary(_buf.Count);
+ _dataList = new System.Collections.Generic.List(_buf.Count);
+
+ foreach(JObject _ele in _buf)
+ {
+ Leader _v;
+ _v = global::cfg.Leader.DeserializeLeader(_ele);
+ _dataList.Add(_v);
+ _dataMap.Add(_v.Id, _v);
+ }
+ }
+
+
+ public System.Collections.Generic.Dictionary DataMap => _dataMap;
+ public System.Collections.Generic.List DataList => _dataList;
+
+ public Leader GetOrDefault(int key) => _dataMap.TryGetValue(key, out var v) ? v : default;
+ public Leader Get(int key) => _dataMap[key];
+ public Leader this[int key] => _dataMap[key];
+
+ public void ResolveRef(Tables tables)
+ {
+ foreach(var _v in _dataList)
+ {
+ _v.ResolveRef(tables);
+ }
+ }
+
+}
+}
+
diff --git a/Entity/Generate/NetworkProtocol/InnerMessage.cs b/Entity/Generate/NetworkProtocol/InnerMessage.cs
index 6b7cf84..687cff4 100644
--- a/Entity/Generate/NetworkProtocol/InnerMessage.cs
+++ b/Entity/Generate/NetworkProtocol/InnerMessage.cs
@@ -678,4 +678,89 @@ namespace Fantasy
[ProtoMember(1)]
public ChatInfoTree ChatInfoTree { get; set; }
}
+ ///
+ /// 其他服务器发送邮件
+ ///
+////////// ******** 邮件 *******/////////////
+ public partial class Other2Mail_SendMailRequest : AMessage, IAddressRequest
+ {
+ public static Other2Mail_SendMailRequest Create(bool autoReturn = true)
+ {
+ var other2Mail_SendMailRequest = MessageObjectPool.Rent();
+ other2Mail_SendMailRequest.AutoReturn = autoReturn;
+
+ if (!autoReturn)
+ {
+ other2Mail_SendMailRequest.SetIsPool(false);
+ }
+
+ return other2Mail_SendMailRequest;
+ }
+
+ public void Return()
+ {
+ if (!AutoReturn)
+ {
+ SetIsPool(true);
+ AutoReturn = true;
+ }
+ else if (!IsPool())
+ {
+ return;
+ }
+ Dispose();
+ }
+
+ public void Dispose()
+ {
+ if (!IsPool()) return;
+ MailBox = default;
+ MessageObjectPool.Return(this);
+ }
+ public uint OpCode() { return InnerOpcode.Other2Mail_SendMailRequest; }
+ [BsonIgnore]
+ public Mail2Other_SendMailResponse ResponseType { get; set; }
+ public MailBox MailBox { get; set; }
+ }
+ [Serializable]
+ [ProtoContract]
+ public partial class Mail2Other_SendMailResponse : AMessage, IAddressResponse
+ {
+ public static Mail2Other_SendMailResponse Create(bool autoReturn = true)
+ {
+ var mail2Other_SendMailResponse = MessageObjectPool.Rent();
+ mail2Other_SendMailResponse.AutoReturn = autoReturn;
+
+ if (!autoReturn)
+ {
+ mail2Other_SendMailResponse.SetIsPool(false);
+ }
+
+ return mail2Other_SendMailResponse;
+ }
+
+ public void Return()
+ {
+ if (!AutoReturn)
+ {
+ SetIsPool(true);
+ AutoReturn = true;
+ }
+ else if (!IsPool())
+ {
+ return;
+ }
+ Dispose();
+ }
+
+ public void Dispose()
+ {
+ if (!IsPool()) return;
+ ErrorCode = 0;
+ MessageObjectPool.Return(this);
+ }
+ public uint OpCode() { return InnerOpcode.Mail2Other_SendMailResponse; }
+ [ProtoMember(1)]
+ public uint ErrorCode { get; set; }
+ }
}
\ No newline at end of file
diff --git a/Entity/Generate/NetworkProtocol/InnerOpcode.cs b/Entity/Generate/NetworkProtocol/InnerOpcode.cs
index b4ecf8f..55d71e0 100644
--- a/Entity/Generate/NetworkProtocol/InnerOpcode.cs
+++ b/Entity/Generate/NetworkProtocol/InnerOpcode.cs
@@ -20,5 +20,7 @@ namespace Fantasy
public const uint Map2G_ExiRoomResponse = 1207969557;
public const uint Chat2G_ChatMessage = 939534099;
public const uint Other2Chat_ChatMessage = 939534100;
+ public const uint Other2Mail_SendMailRequest = 1082140438;
+ public const uint Mail2Other_SendMailResponse = 1207969558;
}
}
\ No newline at end of file
diff --git a/Entity/Generate/NetworkProtocol/OuterMessage.cs b/Entity/Generate/NetworkProtocol/OuterMessage.cs
index 9e3b230..5736c9c 100644
--- a/Entity/Generate/NetworkProtocol/OuterMessage.cs
+++ b/Entity/Generate/NetworkProtocol/OuterMessage.cs
@@ -1045,6 +1045,804 @@ namespace Fantasy
public uint ErrorCode { get; set; }
}
///
+ /// 测试Mail自定义Route协议
+ ///
+ [Serializable]
+ [ProtoContract]
+ public partial class C2Mail_TestRequest : AMessage, ICustomRouteRequest
+ {
+ public static C2Mail_TestRequest Create(bool autoReturn = true)
+ {
+ var c2Mail_TestRequest = MessageObjectPool.Rent();
+ c2Mail_TestRequest.AutoReturn = autoReturn;
+
+ if (!autoReturn)
+ {
+ c2Mail_TestRequest.SetIsPool(false);
+ }
+
+ return c2Mail_TestRequest;
+ }
+
+ public void Return()
+ {
+ if (!AutoReturn)
+ {
+ SetIsPool(true);
+ AutoReturn = true;
+ }
+ else if (!IsPool())
+ {
+ return;
+ }
+ Dispose();
+ }
+
+ public void Dispose()
+ {
+ if (!IsPool()) return;
+ Tag = default;
+ MessageObjectPool.Return(this);
+ }
+ public uint OpCode() { return OuterOpcode.C2Mail_TestRequest; }
+ [ProtoIgnore]
+ public Mail2C_TestResponse ResponseType { get; set; }
+ [ProtoIgnore]
+ public int RouteType => Fantasy.RouteType.GameRoute;
+ [ProtoMember(1)]
+ public string Tag { get; set; }
+ }
+ [Serializable]
+ [ProtoContract]
+ public partial class Mail2C_TestResponse : AMessage, ICustomRouteResponse
+ {
+ public static Mail2C_TestResponse Create(bool autoReturn = true)
+ {
+ var mail2C_TestResponse = MessageObjectPool.Rent();
+ mail2C_TestResponse.AutoReturn = autoReturn;
+
+ if (!autoReturn)
+ {
+ mail2C_TestResponse.SetIsPool(false);
+ }
+
+ return mail2C_TestResponse;
+ }
+
+ public void Return()
+ {
+ if (!AutoReturn)
+ {
+ SetIsPool(true);
+ AutoReturn = true;
+ }
+ else if (!IsPool())
+ {
+ return;
+ }
+ Dispose();
+ }
+
+ public void Dispose()
+ {
+ if (!IsPool()) return;
+ ErrorCode = 0;
+ Tag = default;
+ MessageObjectPool.Return(this);
+ }
+ public uint OpCode() { return OuterOpcode.Mail2C_TestResponse; }
+ [ProtoMember(1)]
+ public uint ErrorCode { get; set; }
+ [ProtoMember(2)]
+ public string Tag { get; set; }
+ }
+ ///
+ /// 一个邮件的完整信息
+ ///
+ [Serializable]
+ [ProtoContract]
+ public partial class MailInfo : AMessage, IDisposable
+ {
+ public static MailInfo Create(bool autoReturn = true)
+ {
+ var mailInfo = MessageObjectPool.Rent();
+ mailInfo.AutoReturn = autoReturn;
+
+ if (!autoReturn)
+ {
+ mailInfo.SetIsPool(false);
+ }
+
+ return mailInfo;
+ }
+
+ public void Return()
+ {
+ if (!AutoReturn)
+ {
+ SetIsPool(true);
+ AutoReturn = true;
+ }
+ else if (!IsPool())
+ {
+ return;
+ }
+ Dispose();
+ }
+
+ public void Dispose()
+ {
+ if (!IsPool()) return;
+ MailId = default;
+ OwnerId = default;
+ Title = default;
+ Content = default;
+ CreateTime = default;
+ ExpireTime = default;
+ Money = default;
+ MailState = default;
+ MailType = default;
+ Items.Clear();
+ MessageObjectPool.Return(this);
+ }
+ [ProtoMember(1)]
+ public long MailId { get; set; }
+ [ProtoMember(2)]
+ public long OwnerId { get; set; }
+ [ProtoMember(3)]
+ public string Title { get; set; }
+ [ProtoMember(4)]
+ public string Content { get; set; }
+ [ProtoMember(5)]
+ public long CreateTime { get; set; }
+ [ProtoMember(6)]
+ public long ExpireTime { get; set; }
+ [ProtoMember(7)]
+ public int Money { get; set; }
+ [ProtoMember(8)]
+ public int MailState { get; set; }
+ [ProtoMember(9)]
+ public int MailType { get; set; }
+ [ProtoMember(10)]
+ public List Items { get; set; } = new List();
+ }
+ ///
+ /// 一个邮件的简单版消息
+ ///
+ [Serializable]
+ [ProtoContract]
+ public partial class MailSimplifyInfo : AMessage, IDisposable
+ {
+ public static MailSimplifyInfo Create(bool autoReturn = true)
+ {
+ var mailSimplifyInfo = MessageObjectPool.Rent();
+ mailSimplifyInfo.AutoReturn = autoReturn;
+
+ if (!autoReturn)
+ {
+ mailSimplifyInfo.SetIsPool(false);
+ }
+
+ return mailSimplifyInfo;
+ }
+
+ public void Return()
+ {
+ if (!AutoReturn)
+ {
+ SetIsPool(true);
+ AutoReturn = true;
+ }
+ else if (!IsPool())
+ {
+ return;
+ }
+ Dispose();
+ }
+
+ public void Dispose()
+ {
+ if (!IsPool()) return;
+ MailId = default;
+ OwnerId = default;
+ Title = default;
+ Content = default;
+ CreateTime = default;
+ ExpireTime = default;
+ MailState = default;
+ MailType = default;
+ MessageObjectPool.Return(this);
+ }
+ [ProtoMember(1)]
+ public long MailId { get; set; }
+ [ProtoMember(2)]
+ public long OwnerId { get; set; }
+ [ProtoMember(3)]
+ public string Title { get; set; }
+ [ProtoMember(4)]
+ public string Content { get; set; }
+ [ProtoMember(5)]
+ public long CreateTime { get; set; }
+ [ProtoMember(6)]
+ public long ExpireTime { get; set; }
+ [ProtoMember(7)]
+ public int MailState { get; set; }
+ [ProtoMember(8)]
+ public int MailType { get; set; }
+ }
+ ///
+ /// Mail通知客户端有新的邮件
+ ///
+ [Serializable]
+ [ProtoContract]
+ public partial class Mail2C_HaveMail : AMessage, ICustomRouteMessage
+ {
+ public static Mail2C_HaveMail Create(bool autoReturn = true)
+ {
+ var mail2C_HaveMail = MessageObjectPool.Rent();
+ mail2C_HaveMail.AutoReturn = autoReturn;
+
+ if (!autoReturn)
+ {
+ mail2C_HaveMail.SetIsPool(false);
+ }
+
+ return mail2C_HaveMail;
+ }
+
+ public void Return()
+ {
+ if (!AutoReturn)
+ {
+ SetIsPool(true);
+ AutoReturn = true;
+ }
+ else if (!IsPool())
+ {
+ return;
+ }
+ Dispose();
+ }
+
+ public void Dispose()
+ {
+ if (!IsPool()) return;
+ if (Mail != null)
+ {
+ Mail.Dispose();
+ Mail = null;
+ }
+ MessageObjectPool.Return(this);
+ }
+ public uint OpCode() { return OuterOpcode.Mail2C_HaveMail; }
+ [ProtoIgnore]
+ public int RouteType => Fantasy.RouteType.GameRoute;
+ [ProtoMember(1)]
+ public MailSimplifyInfo Mail { get; set; }
+ }
+ ///
+ /// Mail通知客户端邮件状态变化
+ ///
+ [Serializable]
+ [ProtoContract]
+ public partial class Mail2C_MailState : AMessage, ICustomRouteMessage
+ {
+ public static Mail2C_MailState Create(bool autoReturn = true)
+ {
+ var mail2C_MailState = MessageObjectPool.Rent();
+ mail2C_MailState.AutoReturn = autoReturn;
+
+ if (!autoReturn)
+ {
+ mail2C_MailState.SetIsPool(false);
+ }
+
+ return mail2C_MailState;
+ }
+
+ public void Return()
+ {
+ if (!AutoReturn)
+ {
+ SetIsPool(true);
+ AutoReturn = true;
+ }
+ else if (!IsPool())
+ {
+ return;
+ }
+ Dispose();
+ }
+
+ public void Dispose()
+ {
+ if (!IsPool()) return;
+ MailState = default;
+ MailId = default;
+ MessageObjectPool.Return(this);
+ }
+ public uint OpCode() { return OuterOpcode.Mail2C_MailState; }
+ [ProtoIgnore]
+ public int RouteType => Fantasy.RouteType.GameRoute;
+ [ProtoMember(1)]
+ public int MailState { get; set; }
+ [ProtoMember(2)]
+ public long MailId { get; set; }
+ }
+ ///
+ /// 客户端获取档期所有邮件的信息
+ ///
+ [Serializable]
+ [ProtoContract]
+ public partial class C2Mail_GetHaveMailRequest : AMessage, ICustomRouteRequest
+ {
+ public static C2Mail_GetHaveMailRequest Create(bool autoReturn = true)
+ {
+ var c2Mail_GetHaveMailRequest = MessageObjectPool.Rent();
+ c2Mail_GetHaveMailRequest.AutoReturn = autoReturn;
+
+ if (!autoReturn)
+ {
+ c2Mail_GetHaveMailRequest.SetIsPool(false);
+ }
+
+ return c2Mail_GetHaveMailRequest;
+ }
+
+ public void Return()
+ {
+ if (!AutoReturn)
+ {
+ SetIsPool(true);
+ AutoReturn = true;
+ }
+ else if (!IsPool())
+ {
+ return;
+ }
+ Dispose();
+ }
+
+ public void Dispose()
+ {
+ if (!IsPool()) return;
+ MessageObjectPool.Return(this);
+ }
+ public uint OpCode() { return OuterOpcode.C2Mail_GetHaveMailRequest; }
+ [ProtoIgnore]
+ public Mail2C_GetHaveMailResposne ResponseType { get; set; }
+ [ProtoIgnore]
+ public int RouteType => Fantasy.RouteType.GameRoute;
+ }
+ [Serializable]
+ [ProtoContract]
+ public partial class Mail2C_GetHaveMailResposne : AMessage, ICustomRouteResponse
+ {
+ public static Mail2C_GetHaveMailResposne Create(bool autoReturn = true)
+ {
+ var mail2C_GetHaveMailResposne = MessageObjectPool.Rent();
+ mail2C_GetHaveMailResposne.AutoReturn = autoReturn;
+
+ if (!autoReturn)
+ {
+ mail2C_GetHaveMailResposne.SetIsPool(false);
+ }
+
+ return mail2C_GetHaveMailResposne;
+ }
+
+ public void Return()
+ {
+ if (!AutoReturn)
+ {
+ SetIsPool(true);
+ AutoReturn = true;
+ }
+ else if (!IsPool())
+ {
+ return;
+ }
+ Dispose();
+ }
+
+ public void Dispose()
+ {
+ if (!IsPool()) return;
+ ErrorCode = 0;
+ Mails.Clear();
+ MessageObjectPool.Return(this);
+ }
+ public uint OpCode() { return OuterOpcode.Mail2C_GetHaveMailResposne; }
+ [ProtoMember(1)]
+ public uint ErrorCode { get; set; }
+ [ProtoMember(2)]
+ public List Mails { get; set; } = new List();
+ }
+ ///
+ /// 客户端发开一个邮件
+ ///
+ [Serializable]
+ [ProtoContract]
+ public partial class C2Mail_OpenMailRequest : AMessage, ICustomRouteRequest
+ {
+ public static C2Mail_OpenMailRequest Create(bool autoReturn = true)
+ {
+ var c2Mail_OpenMailRequest = MessageObjectPool.Rent();
+ c2Mail_OpenMailRequest.AutoReturn = autoReturn;
+
+ if (!autoReturn)
+ {
+ c2Mail_OpenMailRequest.SetIsPool(false);
+ }
+
+ return c2Mail_OpenMailRequest;
+ }
+
+ public void Return()
+ {
+ if (!AutoReturn)
+ {
+ SetIsPool(true);
+ AutoReturn = true;
+ }
+ else if (!IsPool())
+ {
+ return;
+ }
+ Dispose();
+ }
+
+ public void Dispose()
+ {
+ if (!IsPool()) return;
+ MailId = default;
+ ReturnMailInfo = default;
+ MessageObjectPool.Return(this);
+ }
+ public uint OpCode() { return OuterOpcode.C2Mail_OpenMailRequest; }
+ [ProtoIgnore]
+ public Mail2C_OpenMailResposne ResponseType { get; set; }
+ [ProtoIgnore]
+ public int RouteType => Fantasy.RouteType.GameRoute;
+ [ProtoMember(1)]
+ public long MailId { get; set; }
+ [ProtoMember(2)]
+ public bool ReturnMailInfo { get; set; }
+ }
+ [Serializable]
+ [ProtoContract]
+ public partial class Mail2C_OpenMailResposne : AMessage, ICustomRouteResponse
+ {
+ public static Mail2C_OpenMailResposne Create(bool autoReturn = true)
+ {
+ var mail2C_OpenMailResposne = MessageObjectPool.Rent();
+ mail2C_OpenMailResposne.AutoReturn = autoReturn;
+
+ if (!autoReturn)
+ {
+ mail2C_OpenMailResposne.SetIsPool(false);
+ }
+
+ return mail2C_OpenMailResposne;
+ }
+
+ public void Return()
+ {
+ if (!AutoReturn)
+ {
+ SetIsPool(true);
+ AutoReturn = true;
+ }
+ else if (!IsPool())
+ {
+ return;
+ }
+ Dispose();
+ }
+
+ public void Dispose()
+ {
+ if (!IsPool()) return;
+ ErrorCode = 0;
+ if (MailInfo != null)
+ {
+ MailInfo.Dispose();
+ MailInfo = null;
+ }
+ MessageObjectPool.Return(this);
+ }
+ public uint OpCode() { return OuterOpcode.Mail2C_OpenMailResposne; }
+ [ProtoMember(1)]
+ public uint ErrorCode { get; set; }
+ [ProtoMember(2)]
+ public MailInfo MailInfo { get; set; }
+ }
+ ///
+ /// 客户端领取邮件的附件
+ ///
+ [Serializable]
+ [ProtoContract]
+ public partial class C2Mail_ReceiveMailRequest : AMessage, ICustomRouteRequest
+ {
+ public static C2Mail_ReceiveMailRequest Create(bool autoReturn = true)
+ {
+ var c2Mail_ReceiveMailRequest = MessageObjectPool.Rent();
+ c2Mail_ReceiveMailRequest.AutoReturn = autoReturn;
+
+ if (!autoReturn)
+ {
+ c2Mail_ReceiveMailRequest.SetIsPool(false);
+ }
+
+ return c2Mail_ReceiveMailRequest;
+ }
+
+ public void Return()
+ {
+ if (!AutoReturn)
+ {
+ SetIsPool(true);
+ AutoReturn = true;
+ }
+ else if (!IsPool())
+ {
+ return;
+ }
+ Dispose();
+ }
+
+ public void Dispose()
+ {
+ if (!IsPool()) return;
+ MailId = default;
+ Money = default;
+ ItemId.Clear();
+ MessageObjectPool.Return(this);
+ }
+ public uint OpCode() { return OuterOpcode.C2Mail_ReceiveMailRequest; }
+ [ProtoIgnore]
+ public Mail2C_ReceiveMailResponse ResponseType { get; set; }
+ [ProtoIgnore]
+ public int RouteType => Fantasy.RouteType.GameRoute;
+ [ProtoMember(1)]
+ public long MailId { get; set; }
+ [ProtoMember(2)]
+ public bool Money { get; set; }
+ [ProtoMember(3)]
+ public List ItemId { get; set; } = new List();
+ }
+ [Serializable]
+ [ProtoContract]
+ public partial class Mail2C_ReceiveMailResponse : AMessage, ICustomRouteResponse
+ {
+ public static Mail2C_ReceiveMailResponse Create(bool autoReturn = true)
+ {
+ var mail2C_ReceiveMailResponse = MessageObjectPool.Rent();
+ mail2C_ReceiveMailResponse.AutoReturn = autoReturn;
+
+ if (!autoReturn)
+ {
+ mail2C_ReceiveMailResponse.SetIsPool(false);
+ }
+
+ return mail2C_ReceiveMailResponse;
+ }
+
+ public void Return()
+ {
+ if (!AutoReturn)
+ {
+ SetIsPool(true);
+ AutoReturn = true;
+ }
+ else if (!IsPool())
+ {
+ return;
+ }
+ Dispose();
+ }
+
+ public void Dispose()
+ {
+ if (!IsPool()) return;
+ ErrorCode = 0;
+ MessageObjectPool.Return(this);
+ }
+ public uint OpCode() { return OuterOpcode.Mail2C_ReceiveMailResponse; }
+ [ProtoMember(1)]
+ public uint ErrorCode { get; set; }
+ }
+ ///
+ /// 客户端通知服务器删除一个邮件
+ ///
+ [Serializable]
+ [ProtoContract]
+ public partial class C2Mail_RemoveMailRequest : AMessage, ICustomRouteRequest
+ {
+ public static C2Mail_RemoveMailRequest Create(bool autoReturn = true)
+ {
+ var c2Mail_RemoveMailRequest = MessageObjectPool.Rent();
+ c2Mail_RemoveMailRequest.AutoReturn = autoReturn;
+
+ if (!autoReturn)
+ {
+ c2Mail_RemoveMailRequest.SetIsPool(false);
+ }
+
+ return c2Mail_RemoveMailRequest;
+ }
+
+ public void Return()
+ {
+ if (!AutoReturn)
+ {
+ SetIsPool(true);
+ AutoReturn = true;
+ }
+ else if (!IsPool())
+ {
+ return;
+ }
+ Dispose();
+ }
+
+ public void Dispose()
+ {
+ if (!IsPool()) return;
+ MailId = default;
+ MessageObjectPool.Return(this);
+ }
+ public uint OpCode() { return OuterOpcode.C2Mail_RemoveMailRequest; }
+ [ProtoIgnore]
+ public Mail2C_RemoveMailResponse ResponseType { get; set; }
+ [ProtoIgnore]
+ public int RouteType => Fantasy.RouteType.GameRoute;
+ [ProtoMember(1)]
+ public long MailId { get; set; }
+ }
+ [Serializable]
+ [ProtoContract]
+ public partial class Mail2C_RemoveMailResponse : AMessage, ICustomRouteResponse
+ {
+ public static Mail2C_RemoveMailResponse Create(bool autoReturn = true)
+ {
+ var mail2C_RemoveMailResponse = MessageObjectPool.Rent();
+ mail2C_RemoveMailResponse.AutoReturn = autoReturn;
+
+ if (!autoReturn)
+ {
+ mail2C_RemoveMailResponse.SetIsPool(false);
+ }
+
+ return mail2C_RemoveMailResponse;
+ }
+
+ public void Return()
+ {
+ if (!AutoReturn)
+ {
+ SetIsPool(true);
+ AutoReturn = true;
+ }
+ else if (!IsPool())
+ {
+ return;
+ }
+ Dispose();
+ }
+
+ public void Dispose()
+ {
+ if (!IsPool()) return;
+ ErrorCode = 0;
+ MessageObjectPool.Return(this);
+ }
+ public uint OpCode() { return OuterOpcode.Mail2C_RemoveMailResponse; }
+ [ProtoMember(1)]
+ public uint ErrorCode { get; set; }
+ }
+ ///
+ /// 客户端玩家发送邮件到另外一个玩家
+ ///
+ [Serializable]
+ [ProtoContract]
+ public partial class C2Mail_SendMailRequest : AMessage, ICustomRouteRequest
+ {
+ public static C2Mail_SendMailRequest Create(bool autoReturn = true)
+ {
+ var c2Mail_SendMailRequest = MessageObjectPool.Rent();
+ c2Mail_SendMailRequest.AutoReturn = autoReturn;
+
+ if (!autoReturn)
+ {
+ c2Mail_SendMailRequest.SetIsPool(false);
+ }
+
+ return c2Mail_SendMailRequest;
+ }
+
+ public void Return()
+ {
+ if (!AutoReturn)
+ {
+ SetIsPool(true);
+ AutoReturn = true;
+ }
+ else if (!IsPool())
+ {
+ return;
+ }
+ Dispose();
+ }
+
+ public void Dispose()
+ {
+ if (!IsPool()) return;
+ UserId = default;
+ Title = default;
+ Content = default;
+ Money = default;
+ ItemId.Clear();
+ MessageObjectPool.Return(this);
+ }
+ public uint OpCode() { return OuterOpcode.C2Mail_SendMailRequest; }
+ [ProtoIgnore]
+ public Mail2C_SendMailResponse ResponseType { get; set; }
+ [ProtoIgnore]
+ public int RouteType => Fantasy.RouteType.GameRoute;
+ [ProtoMember(1)]
+ public long UserId { get; set; }
+ [ProtoMember(2)]
+ public string Title { get; set; }
+ [ProtoMember(3)]
+ public string Content { get; set; }
+ [ProtoMember(4)]
+ public int Money { get; set; }
+ [ProtoMember(5)]
+ public List ItemId { get; set; } = new List();
+ }
+ [Serializable]
+ [ProtoContract]
+ public partial class Mail2C_SendMailResponse : AMessage, ICustomRouteResponse
+ {
+ public static Mail2C_SendMailResponse Create(bool autoReturn = true)
+ {
+ var mail2C_SendMailResponse = MessageObjectPool.Rent();
+ mail2C_SendMailResponse.AutoReturn = autoReturn;
+
+ if (!autoReturn)
+ {
+ mail2C_SendMailResponse.SetIsPool(false);
+ }
+
+ return mail2C_SendMailResponse;
+ }
+
+ public void Return()
+ {
+ if (!AutoReturn)
+ {
+ SetIsPool(true);
+ AutoReturn = true;
+ }
+ else if (!IsPool())
+ {
+ return;
+ }
+ Dispose();
+ }
+
+ public void Dispose()
+ {
+ if (!IsPool()) return;
+ ErrorCode = 0;
+ MessageObjectPool.Return(this);
+ }
+ public uint OpCode() { return OuterOpcode.Mail2C_SendMailResponse; }
+ [ProtoMember(1)]
+ public uint ErrorCode { get; set; }
+ }
+ ///
/// 请求创建房间
///
[Serializable]
@@ -2347,499 +3145,6 @@ namespace Fantasy
public long Timestamp { get; set; }
}
///
- /// 会话信息
- ///
-////////// ******** 私聊/邮件 *******/////////////
- [Serializable]
- [ProtoContract]
- public partial class ConversationInfo : AMessage, IDisposable
- {
- public static ConversationInfo Create(bool autoReturn = true)
- {
- var conversationInfo = MessageObjectPool.Rent();
- conversationInfo.AutoReturn = autoReturn;
-
- if (!autoReturn)
- {
- conversationInfo.SetIsPool(false);
- }
-
- return conversationInfo;
- }
-
- public void Return()
- {
- if (!AutoReturn)
- {
- SetIsPool(true);
- AutoReturn = true;
- }
- else if (!IsPool())
- {
- return;
- }
- Dispose();
- }
-
- public void Dispose()
- {
- if (!IsPool()) return;
- if (RoleInfo != null)
- {
- RoleInfo.Dispose();
- RoleInfo = null;
- }
- List.Clear();
- MessageObjectPool.Return(this);
- }
- [ProtoMember(1)]
- public RoleSimpleInfo RoleInfo { get; set; }
- [ProtoMember(2)]
- public List List { get; set; } = new List();
- }
- [Serializable]
- [ProtoContract]
- public partial class MailInfo : AMessage, IDisposable
- {
- public static MailInfo Create(bool autoReturn = true)
- {
- var mailInfo = MessageObjectPool.Rent();
- mailInfo.AutoReturn = autoReturn;
-
- if (!autoReturn)
- {
- mailInfo.SetIsPool(false);
- }
-
- return mailInfo;
- }
-
- public void Return()
- {
- if (!AutoReturn)
- {
- SetIsPool(true);
- AutoReturn = true;
- }
- else if (!IsPool())
- {
- return;
- }
- Dispose();
- }
-
- public void Dispose()
- {
- if (!IsPool()) return;
- Id = default;
- Sender = default;
- Content = default;
- CreateTime = default;
- MailType = default;
- MailState = default;
- Items.Clear();
- MessageObjectPool.Return(this);
- }
- [ProtoMember(1)]
- public long Id { get; set; }
- [ProtoMember(2)]
- public long Sender { get; set; }
- [ProtoMember(3)]
- public string Content { get; set; }
- [ProtoMember(4)]
- public long CreateTime { get; set; }
- [ProtoMember(5)]
- public int MailType { get; set; }
- [ProtoMember(6)]
- public int MailState { get; set; }
- [ProtoMember(7)]
- public List Items { get; set; } = new List();
- }
- ///
- /// 请求会话列表
- ///
- [Serializable]
- [ProtoContract]
- public partial class C2Game_GetConversationsRequest : AMessage, ICustomRouteRequest
- {
- public static C2Game_GetConversationsRequest Create(bool autoReturn = true)
- {
- var c2Game_GetConversationsRequest = MessageObjectPool.Rent();
- c2Game_GetConversationsRequest.AutoReturn = autoReturn;
-
- if (!autoReturn)
- {
- c2Game_GetConversationsRequest.SetIsPool(false);
- }
-
- return c2Game_GetConversationsRequest;
- }
-
- public void Return()
- {
- if (!AutoReturn)
- {
- SetIsPool(true);
- AutoReturn = true;
- }
- else if (!IsPool())
- {
- return;
- }
- Dispose();
- }
-
- public void Dispose()
- {
- if (!IsPool()) return;
- MessageObjectPool.Return(this);
- }
- public uint OpCode() { return OuterOpcode.C2Game_GetConversationsRequest; }
- [ProtoIgnore]
- public Game2C_GetConversationsResponse ResponseType { get; set; }
- [ProtoIgnore]
- public int RouteType => Fantasy.RouteType.GameRoute;
- }
- ///
- /// 请求会话列表响应
- ///
- [Serializable]
- [ProtoContract]
- public partial class Game2C_GetConversationsResponse : AMessage, ICustomRouteResponse
- {
- public static Game2C_GetConversationsResponse Create(bool autoReturn = true)
- {
- var game2C_GetConversationsResponse = MessageObjectPool.Rent();
- game2C_GetConversationsResponse.AutoReturn = autoReturn;
-
- if (!autoReturn)
- {
- game2C_GetConversationsResponse.SetIsPool(false);
- }
-
- return game2C_GetConversationsResponse;
- }
-
- public void Return()
- {
- if (!AutoReturn)
- {
- SetIsPool(true);
- AutoReturn = true;
- }
- else if (!IsPool())
- {
- return;
- }
- Dispose();
- }
-
- public void Dispose()
- {
- if (!IsPool()) return;
- ErrorCode = 0;
- List.Clear();
- MessageObjectPool.Return(this);
- }
- public uint OpCode() { return OuterOpcode.Game2C_GetConversationsResponse; }
- [ProtoMember(1)]
- public uint ErrorCode { get; set; }
- [ProtoMember(2)]
- public List List { get; set; } = new List();
- }
- ///
- /// 发送邮件消息
- ///
- [Serializable]
- [ProtoContract]
- public partial class C2Game_SendMailRequest : AMessage, ICustomRouteRequest
- {
- public static C2Game_SendMailRequest Create(bool autoReturn = true)
- {
- var c2Game_SendMailRequest = MessageObjectPool.Rent();
- c2Game_SendMailRequest.AutoReturn = autoReturn;
-
- if (!autoReturn)
- {
- c2Game_SendMailRequest.SetIsPool(false);
- }
-
- return c2Game_SendMailRequest;
- }
-
- public void Return()
- {
- if (!AutoReturn)
- {
- SetIsPool(true);
- AutoReturn = true;
- }
- else if (!IsPool())
- {
- return;
- }
- Dispose();
- }
-
- public void Dispose()
- {
- if (!IsPool()) return;
- Target = default;
- Content = default;
- Items.Clear();
- MessageObjectPool.Return(this);
- }
- public uint OpCode() { return OuterOpcode.C2Game_SendMailRequest; }
- [ProtoIgnore]
- public Game2C_SendMailResponse ResponseType { get; set; }
- [ProtoIgnore]
- public int RouteType => Fantasy.RouteType.GameRoute;
- [ProtoMember(1)]
- public long Target { get; set; }
- [ProtoMember(2)]
- public string Content { get; set; }
- [ProtoMember(3)]
- public List Items { get; set; } = new List();
- }
- ///
- /// 发送邮件消息响应
- ///
- [Serializable]
- [ProtoContract]
- public partial class Game2C_SendMailResponse : AMessage, ICustomRouteResponse
- {
- public static Game2C_SendMailResponse Create(bool autoReturn = true)
- {
- var game2C_SendMailResponse = MessageObjectPool.Rent();
- game2C_SendMailResponse.AutoReturn = autoReturn;
-
- if (!autoReturn)
- {
- game2C_SendMailResponse.SetIsPool(false);
- }
-
- return game2C_SendMailResponse;
- }
-
- public void Return()
- {
- if (!AutoReturn)
- {
- SetIsPool(true);
- AutoReturn = true;
- }
- else if (!IsPool())
- {
- return;
- }
- Dispose();
- }
-
- public void Dispose()
- {
- if (!IsPool()) return;
- ErrorCode = 0;
- MessageObjectPool.Return(this);
- }
- public uint OpCode() { return OuterOpcode.Game2C_SendMailResponse; }
- [ProtoMember(1)]
- public uint ErrorCode { get; set; }
- }
- ///
- /// 发送删除会话消息
- ///
- [Serializable]
- [ProtoContract]
- public partial class C2Game_DeleteMailRequest : AMessage, ICustomRouteRequest
- {
- public static C2Game_DeleteMailRequest Create(bool autoReturn = true)
- {
- var c2Game_DeleteMailRequest = MessageObjectPool.Rent();
- c2Game_DeleteMailRequest.AutoReturn = autoReturn;
-
- if (!autoReturn)
- {
- c2Game_DeleteMailRequest.SetIsPool(false);
- }
-
- return c2Game_DeleteMailRequest;
- }
-
- public void Return()
- {
- if (!AutoReturn)
- {
- SetIsPool(true);
- AutoReturn = true;
- }
- else if (!IsPool())
- {
- return;
- }
- Dispose();
- }
-
- public void Dispose()
- {
- if (!IsPool()) return;
- Id = default;
- MessageObjectPool.Return(this);
- }
- public uint OpCode() { return OuterOpcode.C2Game_DeleteMailRequest; }
- [ProtoIgnore]
- public Game2C_DeleteMailResponse ResponseType { get; set; }
- [ProtoIgnore]
- public int RouteType => Fantasy.RouteType.GameRoute;
- [ProtoMember(1)]
- public long Id { get; set; }
- }
- ///
- /// 发送删除会话消息响应
- ///
- [Serializable]
- [ProtoContract]
- public partial class Game2C_DeleteMailResponse : AMessage, ICustomRouteResponse
- {
- public static Game2C_DeleteMailResponse Create(bool autoReturn = true)
- {
- var game2C_DeleteMailResponse = MessageObjectPool.Rent();
- game2C_DeleteMailResponse.AutoReturn = autoReturn;
-
- if (!autoReturn)
- {
- game2C_DeleteMailResponse.SetIsPool(false);
- }
-
- return game2C_DeleteMailResponse;
- }
-
- public void Return()
- {
- if (!AutoReturn)
- {
- SetIsPool(true);
- AutoReturn = true;
- }
- else if (!IsPool())
- {
- return;
- }
- Dispose();
- }
-
- public void Dispose()
- {
- if (!IsPool()) return;
- ErrorCode = 0;
- Id = default;
- MessageObjectPool.Return(this);
- }
- public uint OpCode() { return OuterOpcode.Game2C_DeleteMailResponse; }
- [ProtoMember(1)]
- public uint ErrorCode { get; set; }
- [ProtoMember(2)]
- public long Id { get; set; }
- }
- ///
- /// 新邮件推送
- ///
- [Serializable]
- [ProtoContract]
- public partial class Game2C_HaveMail : AMessage, ICustomRouteMessage
- {
- public static Game2C_HaveMail Create(bool autoReturn = true)
- {
- var game2C_HaveMail = MessageObjectPool.Rent();
- game2C_HaveMail.AutoReturn = autoReturn;
-
- if (!autoReturn)
- {
- game2C_HaveMail.SetIsPool(false);
- }
-
- return game2C_HaveMail;
- }
-
- public void Return()
- {
- if (!AutoReturn)
- {
- SetIsPool(true);
- AutoReturn = true;
- }
- else if (!IsPool())
- {
- return;
- }
- Dispose();
- }
-
- public void Dispose()
- {
- if (!IsPool()) return;
- if (Mail != null)
- {
- Mail.Dispose();
- Mail = null;
- }
- Key = default;
- MessageObjectPool.Return(this);
- }
- public uint OpCode() { return OuterOpcode.Game2C_HaveMail; }
- [ProtoIgnore]
- public int RouteType => Fantasy.RouteType.GameRoute;
- [ProtoMember(1)]
- public MailInfo Mail { get; set; }
- [ProtoMember(2)]
- public string Key { get; set; }
- }
- [Serializable]
- [ProtoContract]
- public partial class Game2C_MailState : AMessage, ICustomRouteMessage
- {
- public static Game2C_MailState Create(bool autoReturn = true)
- {
- var game2C_MailState = MessageObjectPool.Rent();
- game2C_MailState.AutoReturn = autoReturn;
-
- if (!autoReturn)
- {
- game2C_MailState.SetIsPool(false);
- }
-
- return game2C_MailState;
- }
-
- public void Return()
- {
- if (!AutoReturn)
- {
- SetIsPool(true);
- AutoReturn = true;
- }
- else if (!IsPool())
- {
- return;
- }
- Dispose();
- }
-
- public void Dispose()
- {
- if (!IsPool()) return;
- MailState = default;
- MailId = default;
- MessageObjectPool.Return(this);
- }
- public uint OpCode() { return OuterOpcode.Game2C_MailState; }
- [ProtoIgnore]
- public int RouteType => Fantasy.RouteType.GameRoute;
- [ProtoMember(1)]
- public int MailState { get; set; }
- [ProtoMember(2)]
- public long MailId { get; set; }
- }
- ///
/// 发送一个聊天消息给Chat服务器,中间是经过Gate中转的
///
////////// ******** 频道聊天 *******/////////////
diff --git a/Entity/Generate/NetworkProtocol/OuterOpcode.cs b/Entity/Generate/NetworkProtocol/OuterOpcode.cs
index d8ca519..845b516 100644
--- a/Entity/Generate/NetworkProtocol/OuterOpcode.cs
+++ b/Entity/Generate/NetworkProtocol/OuterOpcode.cs
@@ -27,63 +27,69 @@ namespace Fantasy
public const uint Game2C_RewardNotify = 2147493651;
public const uint C2Game_GMRequest = 2281711385;
public const uint Game2C_GMResponse = 2415929113;
- public const uint C2Game_CreateRoomRequest = 2281711386;
- public const uint Game2C_CreateRoomResponse = 2415929114;
+ public const uint C2Mail_TestRequest = 2281711386;
+ public const uint Mail2C_TestResponse = 2415929114;
+ public const uint Mail2C_HaveMail = 2147493652;
+ public const uint Mail2C_MailState = 2147493653;
+ public const uint C2Mail_GetHaveMailRequest = 2281711387;
+ public const uint Mail2C_GetHaveMailResposne = 2415929115;
+ public const uint C2Mail_OpenMailRequest = 2281711388;
+ public const uint Mail2C_OpenMailResposne = 2415929116;
+ public const uint C2Mail_ReceiveMailRequest = 2281711389;
+ public const uint Mail2C_ReceiveMailResponse = 2415929117;
+ public const uint C2Mail_RemoveMailRequest = 2281711390;
+ public const uint Mail2C_RemoveMailResponse = 2415929118;
+ public const uint C2Mail_SendMailRequest = 2281711391;
+ public const uint Mail2C_SendMailResponse = 2415929119;
+ public const uint C2Game_CreateRoomRequest = 2281711392;
+ public const uint Game2C_CreateRoomResponse = 2415929120;
public const uint C2G_ExitRoomRequest = 268445457;
public const uint G2C_ExitRoomResponse = 402663185;
public const uint C2G_EnterMapRequest = 268445458;
public const uint G2C_EnterMapResponse = 402663186;
- public const uint Game2C_ChangeMap = 2147493652;
+ public const uint Game2C_ChangeMap = 2147493654;
public const uint C2A_LoginRequest = 268445459;
public const uint A2C_LoginResponse = 402663187;
public const uint C2G_LoginRequest = 268445460;
public const uint G2C_LoginResponse = 402663188;
public const uint G2C_RepeatLogin = 134227729;
- public const uint C2Game_GetRoleInfoRequest = 2281711387;
- public const uint Game2C_GetRoleInfoResponse = 2415929115;
- public const uint Game2C_RoleEnterRoomNotify = 2147493653;
- public const uint Game2C_RoleExitRoomNotify = 2147493654;
- public const uint C2Game_TakeItemRequest = 2281711388;
- public const uint Game2C_TakeItemResponse = 2415929116;
- public const uint C2Game_RolePropertyChange = 2147493655;
- public const uint Game2C_RoleStateNotify = 2147493656;
- public const uint Game2C_RoleGearChangeNotify = 2147493657;
- public const uint Game2C_RolePropertyChangeNotify = 2147493658;
- public const uint C2Game_Move = 2147493659;
- public const uint C2Game_Look = 2147493660;
- public const uint Game2C_MoveNotify = 2147493661;
- public const uint Game2C_LookeNotify = 2147493662;
- public const uint C2Game_GetConversationsRequest = 2281711389;
- public const uint Game2C_GetConversationsResponse = 2415929117;
- public const uint C2Game_SendMailRequest = 2281711390;
- public const uint Game2C_SendMailResponse = 2415929118;
- public const uint C2Game_DeleteMailRequest = 2281711391;
- public const uint Game2C_DeleteMailResponse = 2415929119;
- public const uint Game2C_HaveMail = 2147493663;
- public const uint Game2C_MailState = 2147493664;
- public const uint C2Game_SendMessageRequest = 2281711392;
- public const uint Game2C_SendMessageResponse = 2415929120;
+ public const uint C2Game_GetRoleInfoRequest = 2281711393;
+ public const uint Game2C_GetRoleInfoResponse = 2415929121;
+ public const uint Game2C_RoleEnterRoomNotify = 2147493655;
+ public const uint Game2C_RoleExitRoomNotify = 2147493656;
+ public const uint C2Game_TakeItemRequest = 2281711394;
+ public const uint Game2C_TakeItemResponse = 2415929122;
+ public const uint C2Game_RolePropertyChange = 2147493657;
+ public const uint Game2C_RoleStateNotify = 2147493658;
+ public const uint Game2C_RoleGearChangeNotify = 2147493659;
+ public const uint Game2C_RolePropertyChangeNotify = 2147493660;
+ public const uint C2Game_Move = 2147493661;
+ public const uint C2Game_Look = 2147493662;
+ public const uint Game2C_MoveNotify = 2147493663;
+ public const uint Game2C_LookeNotify = 2147493664;
+ public const uint C2Game_SendMessageRequest = 2281711395;
+ public const uint Game2C_SendMessageResponse = 2415929123;
public const uint Game2C_Message = 2147493665;
- public const uint C2Game_CreateChannelRequest = 2281711393;
- public const uint Game2C_CreateChannelResponse = 2415929121;
- public const uint C2Game_JoinChannelRequest = 2281711394;
- public const uint Game2C_JoinChannelResponse = 2415929122;
- public const uint C2Game_CreateClubRequest = 2281711395;
- public const uint Game2C_CreateClubResponse = 2415929123;
- public const uint C2Game_GetClubInfoRequest = 2281711396;
- public const uint Game2C_GetClubInfoResponse = 2415929124;
- public const uint C2Game_GetMemberListRequest = 2281711397;
- public const uint Game2C_GetMemberListResponse = 2415929125;
- public const uint C2Game_GetClubListRequest = 2281711398;
- public const uint Game2C_GetClubListResponse = 2415929126;
- public const uint C2Game_JoinClubRequest = 2281711399;
- public const uint Game2C_JoinClubResponse = 2415929127;
- public const uint C2Game_LeaveClubRequest = 2281711400;
- public const uint Game2C_LeaveClubResponse = 2415929128;
- public const uint C2Game_DissolveClubRequest = 2281711401;
- public const uint Game2C_DissolveClubResponse = 2415929129;
- public const uint C2Game_DisposeJoinRequest = 2281711402;
- public const uint Game2C_DisposeJoinResponse = 2415929130;
+ public const uint C2Game_CreateChannelRequest = 2281711396;
+ public const uint Game2C_CreateChannelResponse = 2415929124;
+ public const uint C2Game_JoinChannelRequest = 2281711397;
+ public const uint Game2C_JoinChannelResponse = 2415929125;
+ public const uint C2Game_CreateClubRequest = 2281711398;
+ public const uint Game2C_CreateClubResponse = 2415929126;
+ public const uint C2Game_GetClubInfoRequest = 2281711399;
+ public const uint Game2C_GetClubInfoResponse = 2415929127;
+ public const uint C2Game_GetMemberListRequest = 2281711400;
+ public const uint Game2C_GetMemberListResponse = 2415929128;
+ public const uint C2Game_GetClubListRequest = 2281711401;
+ public const uint Game2C_GetClubListResponse = 2415929129;
+ public const uint C2Game_JoinClubRequest = 2281711402;
+ public const uint Game2C_JoinClubResponse = 2415929130;
+ public const uint C2Game_LeaveClubRequest = 2281711403;
+ public const uint Game2C_LeaveClubResponse = 2415929131;
+ public const uint C2Game_DissolveClubRequest = 2281711404;
+ public const uint Game2C_DissolveClubResponse = 2415929132;
+ public const uint C2Game_DisposeJoinRequest = 2281711405;
+ public const uint Game2C_DisposeJoinResponse = 2415929133;
public const uint Game2C_ClubChange = 2147493666;
}
}
\ No newline at end of file
diff --git a/Hotfix/Game/Social/Chat/Handler/Inner/G2Chat_LoginRequestHandler.cs b/Hotfix/Game/Chat/Handler/Inner/G2Chat_LoginRequestHandler.cs
similarity index 100%
rename from Hotfix/Game/Social/Chat/Handler/Inner/G2Chat_LoginRequestHandler.cs
rename to Hotfix/Game/Chat/Handler/Inner/G2Chat_LoginRequestHandler.cs
diff --git a/Hotfix/Game/Social/Chat/Handler/Inner/G2Chat_OfflineRequestHandler.cs b/Hotfix/Game/Chat/Handler/Inner/G2Chat_OfflineRequestHandler.cs
similarity index 100%
rename from Hotfix/Game/Social/Chat/Handler/Inner/G2Chat_OfflineRequestHandler.cs
rename to Hotfix/Game/Chat/Handler/Inner/G2Chat_OfflineRequestHandler.cs
diff --git a/Hotfix/Game/Social/Chat/Handler/Inner/Other2Chat_ChatMessageHandler.cs b/Hotfix/Game/Chat/Handler/Inner/Other2Chat_ChatMessageHandler.cs
similarity index 100%
rename from Hotfix/Game/Social/Chat/Handler/Inner/Other2Chat_ChatMessageHandler.cs
rename to Hotfix/Game/Chat/Handler/Inner/Other2Chat_ChatMessageHandler.cs
diff --git a/Hotfix/Game/Social/Chat/Handler/Outer/C2Chat_SendMessageRequestHandler.cs b/Hotfix/Game/Chat/Handler/Outer/C2Chat_SendMessageRequestHandler.cs
similarity index 100%
rename from Hotfix/Game/Social/Chat/Handler/Outer/C2Chat_SendMessageRequestHandler.cs
rename to Hotfix/Game/Chat/Handler/Outer/C2Chat_SendMessageRequestHandler.cs
diff --git a/Hotfix/Game/Social/Chat/Helper/ChatChannelCenterHelper.cs b/Hotfix/Game/Chat/Helper/ChatChannelCenterHelper.cs
similarity index 100%
rename from Hotfix/Game/Social/Chat/Helper/ChatChannelCenterHelper.cs
rename to Hotfix/Game/Chat/Helper/ChatChannelCenterHelper.cs
diff --git a/Hotfix/Game/Social/Chat/Helper/ChatHelper.cs b/Hotfix/Game/Chat/Helper/ChatHelper.cs
similarity index 100%
rename from Hotfix/Game/Social/Chat/Helper/ChatHelper.cs
rename to Hotfix/Game/Chat/Helper/ChatHelper.cs
diff --git a/Hotfix/Game/Social/Chat/Helper/ChatNodeFactory.cs b/Hotfix/Game/Chat/Helper/ChatNodeFactory.cs
similarity index 100%
rename from Hotfix/Game/Social/Chat/Helper/ChatNodeFactory.cs
rename to Hotfix/Game/Chat/Helper/ChatNodeFactory.cs
diff --git a/Hotfix/Game/Social/Chat/Helper/ChatSceneHelper.cs b/Hotfix/Game/Chat/Helper/ChatSceneHelper.cs
similarity index 100%
rename from Hotfix/Game/Social/Chat/Helper/ChatSceneHelper.cs
rename to Hotfix/Game/Chat/Helper/ChatSceneHelper.cs
diff --git a/Hotfix/Game/Social/Chat/Helper/ChatTreeFactory.cs b/Hotfix/Game/Chat/Helper/ChatTreeFactory.cs
similarity index 100%
rename from Hotfix/Game/Social/Chat/Helper/ChatTreeFactory.cs
rename to Hotfix/Game/Chat/Helper/ChatTreeFactory.cs
diff --git a/Hotfix/Game/Social/Chat/System/ChatChannelCenterComponentSystem.cs b/Hotfix/Game/Chat/System/ChatChannelCenterComponentSystem.cs
similarity index 100%
rename from Hotfix/Game/Social/Chat/System/ChatChannelCenterComponentSystem.cs
rename to Hotfix/Game/Chat/System/ChatChannelCenterComponentSystem.cs
diff --git a/Hotfix/Game/Social/Chat/System/ChatChannelComponentSystem.cs b/Hotfix/Game/Chat/System/ChatChannelComponentSystem.cs
similarity index 100%
rename from Hotfix/Game/Social/Chat/System/ChatChannelComponentSystem.cs
rename to Hotfix/Game/Chat/System/ChatChannelComponentSystem.cs
diff --git a/Hotfix/Game/Social/Chat/System/ChatUnitManageComponentSystem.cs b/Hotfix/Game/Chat/System/ChatUnitManageComponentSystem.cs
similarity index 100%
rename from Hotfix/Game/Social/Chat/System/ChatUnitManageComponentSystem.cs
rename to Hotfix/Game/Chat/System/ChatUnitManageComponentSystem.cs
diff --git a/Hotfix/Game/Item/Helper/ItemUseHelper.cs b/Hotfix/Game/Item/Helper/ItemUseHelper.cs
new file mode 100644
index 0000000..00b9d25
--- /dev/null
+++ b/Hotfix/Game/Item/Helper/ItemUseHelper.cs
@@ -0,0 +1,74 @@
+namespace NB.Game;
+
+public static class ItemUseHelper
+{
+ // public static uint UseBagItem(Account account, long itemId, int count)
+ // {
+ // return UseItem(account, ContainerType.Bag, itemId, count);
+ // }
+ //
+ // public static uint CanUseBagItem(Account account, long itemId, int count, out Container container, out ItemConfig itemConfig, out ItemUseComponent itemUseComponent)
+ // {
+ // return CanUseItem(account, ContainerType.Bag, itemId, count, out container, out itemConfig, out itemUseComponent);
+ // }
+ //
+ // public static uint UseItem(Account account, ContainerType containerType, long itemId, int count)
+ // {
+ // var errorCode = CanUseItem(account, containerType, itemId, count, out var container, out var itemConfig, out var itemUseComponent);
+ //
+ // if (errorCode != 0)
+ // {
+ // return errorCode;
+ // }
+ //
+ // errorCode = container.RemoveItem(itemId, count, ItemReason.ItemUse, true);
+ //
+ // if (errorCode != 0)
+ // {
+ // return errorCode;
+ // }
+ //
+ // itemUseComponent.Use(account, itemConfig, ref count);
+ // return 0;
+ // }
+ //
+
+ // public static uint CanUseItem(Player account, long itemId, int count, out cfg.Item itemConfig,
+ // out ItemUseComponent itemUseComponent)
+ // {
+ // itemConfig = null;
+ // itemUseComponent = null;
+ // var errorCode = ContainerHelper.TryGetContainer(account, containerType, out container);
+ //
+ // if (errorCode != 0)
+ // {
+ // return errorCode;
+ // }
+ //
+ // if (!container.GetItemById(itemId, out var item))
+ // {
+ // // 这里是找不到该物品的错误码。
+ // return 1;
+ // }
+ //
+ // if (item.Count < count)
+ // {
+ // // 这里是物品数量不足的错误码。
+ // return 2;
+ // }
+ //
+ // itemConfig = item.Config;
+ //
+ // if (itemConfig.Params.Length <= 0)
+ // {
+ // // 这里是物品没有配置参数的错误码。
+ // return 3;
+ // }
+ //
+ // // 这里还可以增加一些其他的判定,比如物品是否过期,物品是否被锁定等。
+ // // 甚至还有物品使用的CD。
+ // // 使用物品效果来判定
+ // itemUseComponent = account.Scene.GetComponent();
+ // return itemUseComponent.CanUse(account, item.Config, ref count);
+ // }
+}
\ No newline at end of file
diff --git a/Hotfix/Game/Item/UseEffect/ItemUse_Drug_AddAttr.cs b/Hotfix/Game/Item/UseEffect/ItemUse_Drug_AddAttr.cs
new file mode 100644
index 0000000..8169816
--- /dev/null
+++ b/Hotfix/Game/Item/UseEffect/ItemUse_Drug_AddAttr.cs
@@ -0,0 +1,51 @@
+using Fantasy;
+
+namespace NB.Game;
+
+[ItemUse(ItemUseEffect.AddAttr)]
+public class ItemUse_Drug_AddAttr : IItemUse
+{
+ // public uint CanUse(Account account, ItemConfig config, ref int count)
+ // {
+ // if (config.Params.Length < 2)
+ // {
+ // Log.Error($"configId:{config.Id} config.Params.Length({config.Params.Length}) < 2");
+ // return 1;
+ // }
+ //
+ // Log.Debug($"CanUse 使用了药品增加属性 configId:{config.Id} count:{count}");
+ // return 0;
+ // }
+ //
+ // public void Use(Account account, ItemConfig config, ref int count)
+ // {
+ // for (int i = 0; i < config.Params.Length; i += 2)
+ // {
+ // var attrKey = config.Params[i];
+ // var attrValue = config.Params[i + 1];
+ // Log.Debug($"Use 使用了药品增加属性 configId:{config.Id} attrKey:{attrKey} attrValue:{attrValue}");
+ // }
+ // }
+ public uint CanUse(Player player, cfg.Item config, ref int count)
+ {
+ // if (config.Params.Length < 2)
+ // {
+ // Log.Error($"configId:{config.Id} config.Params.Length({config.Params.Length}) < 2");
+ // return 1;
+ // }
+ //
+ Log.Debug($"CanUse 使用了药品增加属性 configId:{config.Id} count:{count}");
+ return 0;
+ }
+
+ public void Use(Player player, cfg.Item config, ref int count)
+ {
+ // for (int i = 0; i < config.Params.Length; i += 2)
+ // {
+ // var attrKey = config.Params[i];
+ // var attrValue = config.Params[i + 1];
+ // Log.Debug($"Use 使用了药品增加属性 configId:{config.Id} attrKey:{attrKey} attrValue:{attrValue}");
+ // }
+ Log.Debug($"Use 使用了药品增加属性 configId:{config.Id} count:{count}");
+ }
+}
\ No newline at end of file
diff --git a/Hotfix/Game/Item/UseEffect/ItemUse_Equip_Equip.cs b/Hotfix/Game/Item/UseEffect/ItemUse_Equip_Equip.cs
new file mode 100644
index 0000000..5ada7c0
--- /dev/null
+++ b/Hotfix/Game/Item/UseEffect/ItemUse_Equip_Equip.cs
@@ -0,0 +1,18 @@
+using Fantasy;
+
+namespace NB.Game;
+
+[ItemUse(ItemUseEffect.Equip)]
+public class ItemUse_Equip_Equip : IItemUse
+{
+ public uint CanUse(Player player, cfg.Item config, ref int count)
+ {
+ Log.Debug($"CanUse 使用了装备装备到身上 configId:{config.Id} count:{count}");
+ return 0;
+ }
+
+ public void Use(Player player, cfg.Item config, ref int count)
+ {
+ Log.Debug($"Use 使用了装备装备到身上 configId:{config.Id} count:{count}");
+ }
+}
\ No newline at end of file
diff --git a/Hotfix/Game/Mail/Handler/Inner/Other2Mail_SendRequestHandler.cs b/Hotfix/Game/Mail/Handler/Inner/Other2Mail_SendRequestHandler.cs
new file mode 100644
index 0000000..acd29b9
--- /dev/null
+++ b/Hotfix/Game/Mail/Handler/Inner/Other2Mail_SendRequestHandler.cs
@@ -0,0 +1,14 @@
+using Fantasy;
+using Fantasy.Async;
+using Fantasy.Network.Interface;
+using NBF;
+
+namespace NB;
+
+public class Other2Mail_SendRequestHandler : AddressRPC
+{
+ protected override async FTask Run(Scene scene, Other2Mail_SendMailRequest request, Mail2Other_SendMailResponse response, Action reply)
+ {
+ await MailHelper.Send(scene, request.MailBox);
+ }
+}
\ No newline at end of file
diff --git a/Hotfix/Game/Mail/Handler/Outer/C2Mail_GetHaveMailRequestHandler.cs b/Hotfix/Game/Mail/Handler/Outer/C2Mail_GetHaveMailRequestHandler.cs
new file mode 100644
index 0000000..8053661
--- /dev/null
+++ b/Hotfix/Game/Mail/Handler/Outer/C2Mail_GetHaveMailRequestHandler.cs
@@ -0,0 +1,29 @@
+using Fantasy;
+using Fantasy.Async;
+using Fantasy.Network.Interface;
+using NB.Game;
+using NBF;
+
+// ReSharper disable ConditionIsAlwaysTrueOrFalseAccordingToNullableAPIContract
+
+namespace NB;
+
+public sealed class C2Mail_GetHaveMailRequestHandler : AddressRPC
+{
+ protected override async FTask Run(Player mailUnit, C2Mail_GetHaveMailRequest request, Mail2C_GetHaveMailResposne response, Action reply)
+ {
+ var mailComponent = mailUnit.GetComponent();
+
+ // 这个mailComponent是不是可能会为空?答案是可能的。
+ // 那如果是空的怎么办呢,这样情况只能是别人恶意发包了。
+
+ if (mailComponent == null)
+ {
+ return;
+ }
+ // 检查是否有超时的邮件。如果有那就清楚掉
+ await mailComponent.CheckTimeOut();
+ // 领取当前的邮件
+ mailComponent.GetMailSimplifyInfos(response.Mails);
+ }
+}
\ No newline at end of file
diff --git a/Hotfix/Game/Mail/Handler/Outer/C2Mail_OpenMailRequestHandler.cs b/Hotfix/Game/Mail/Handler/Outer/C2Mail_OpenMailRequestHandler.cs
new file mode 100644
index 0000000..e3df313
--- /dev/null
+++ b/Hotfix/Game/Mail/Handler/Outer/C2Mail_OpenMailRequestHandler.cs
@@ -0,0 +1,35 @@
+using Fantasy.Async;
+using Fantasy.Network.Interface;
+using NB;
+using NB.Game;
+using NBF;
+
+namespace Fantasy;
+
+public class C2Mail_OpenMailRequestHandler : AddressRPC
+{
+ protected override async FTask Run(Player mailUnit, C2Mail_OpenMailRequest request, Mail2C_OpenMailResposne response, Action reply)
+ {
+ if (request.MailId <= 0)
+ {
+ response.ErrorCode = 100;
+ return;
+ }
+
+ // 根据这个MailId来拿到邮件的详细信息
+ var (errorCode, mail) = await mailUnit.GetComponent().OpenMail(request.MailId);
+
+ if (errorCode != 0)
+ {
+ response.ErrorCode = errorCode;
+ return;
+ }
+
+ if (!request.ReturnMailInfo)
+ {
+ return;
+ }
+
+ response.MailInfo = mail.ToMailInfo();
+ }
+}
\ No newline at end of file
diff --git a/Hotfix/Game/Mail/Handler/Outer/C2Mail_ReceiveMailRequestHandler.cs b/Hotfix/Game/Mail/Handler/Outer/C2Mail_ReceiveMailRequestHandler.cs
new file mode 100644
index 0000000..029f585
--- /dev/null
+++ b/Hotfix/Game/Mail/Handler/Outer/C2Mail_ReceiveMailRequestHandler.cs
@@ -0,0 +1,22 @@
+using Fantasy.Async;
+using Fantasy.Network.Interface;
+using NB;
+using NB.Game;
+using NBF;
+
+namespace Fantasy;
+
+public class C2Mail_ReceiveMailRequestHandler : AddressRPC
+{
+ protected override async FTask Run(Player mailUnit, C2Mail_ReceiveMailRequest request, Mail2C_ReceiveMailResponse response, Action reply)
+ {
+ if (request.MailId <= 0)
+ {
+ response.ErrorCode = 100;
+ return;
+ }
+
+ response.ErrorCode = await mailUnit.GetComponent()
+ .Receive(request.MailId, request.Money, request.ItemId, true);
+ }
+}
\ No newline at end of file
diff --git a/Hotfix/Game/Mail/Handler/Outer/C2Mail_RemoveMailRequestHandler.cs b/Hotfix/Game/Mail/Handler/Outer/C2Mail_RemoveMailRequestHandler.cs
new file mode 100644
index 0000000..29eebd8
--- /dev/null
+++ b/Hotfix/Game/Mail/Handler/Outer/C2Mail_RemoveMailRequestHandler.cs
@@ -0,0 +1,24 @@
+using Fantasy.Async;
+using Fantasy.Network.Interface;
+using NB;
+using NB.Game;
+using NBF;
+
+namespace Fantasy;
+
+public class C2Mail_RemoveMailRequestHandler : AddressRPC
+{
+ protected override async FTask Run(Player mailUnit, C2Mail_RemoveMailRequest request, Mail2C_RemoveMailResponse response, Action reply)
+ {
+ if (request.MailId <= 0)
+ {
+ // 这里的1代表MailId不正确。
+ response.ErrorCode = 1;
+ return;
+ }
+
+ response.ErrorCode = await mailUnit.GetComponent()
+ .Remove(request.MailId, MailRemoveActionType.Remove, true);
+
+ }
+}
\ No newline at end of file
diff --git a/Hotfix/Game/Mail/Handler/Outer/C2Mail_SendMailRequestHandler.cs b/Hotfix/Game/Mail/Handler/Outer/C2Mail_SendMailRequestHandler.cs
new file mode 100644
index 0000000..ba1eebc
--- /dev/null
+++ b/Hotfix/Game/Mail/Handler/Outer/C2Mail_SendMailRequestHandler.cs
@@ -0,0 +1,73 @@
+using Fantasy.Async;
+using Fantasy.DataStructure.Collection;
+using Fantasy.Network.Interface;
+using NB;
+using NB.Game;
+using NBF;
+
+namespace Fantasy;
+
+public class C2Mail_SendMailRequestHandler : AddressRPC
+{
+ protected override async FTask Run(Player mailUnit, C2Mail_SendMailRequest request,
+ Mail2C_SendMailResponse response, Action reply)
+ {
+ if (request.UserId < 1)
+ {
+ // 这里的1代表的是发送的接收玩家名字不正确。
+ response.ErrorCode = 1;
+ return;
+ }
+
+ if (string.IsNullOrEmpty(request.Title) || string.IsNullOrEmpty(request.Content))
+ {
+ // 这里的2代表的是发送的邮件标题或者内容不正确。
+ response.ErrorCode = 2;
+ return;
+ }
+
+ if (request.ItemId.Count > 10)
+ {
+ // 这里的3代表的是发送的邮件附件超出了最大范围。
+ response.ErrorCode = 3;
+ return;
+ }
+
+ if (!mailUnit.Scene.GetComponent().TryGet(request.UserId, out var receiveMailUnit))
+ {
+ // 这里的4代表的是没有该玩家。
+ response.ErrorCode = 4;
+ return;
+ }
+
+ if (request.Money > 0)
+ {
+ // 如果大于0,就要调用某一个接口去货币所在的服务器上面去扣除玩家的钱。
+ // var moneyResposne = await MoneyHelper.Cost(mailUnit.Scene, request.Money);
+ // if (moneyResposne.ErrorCode != 0)
+ // {
+ // response.ErrorCode = moneyResposne.ErrorCode;
+ // return;
+ // }
+ }
+
+ using var mailItems = ListPool
- .Create();
+ if (request.ItemId.Count > 0)
+ {
+ // var itemResposne = await BagHelper.Get(mailUnit.Scene, request.ItemId);
+ // if (itemResposne.ErrorCode != 0)
+ // {
+ // response.ErrorCode = itemResposne.ErrorCode;
+ // return;
+ // }
+ // mailItems.AddRange(itemResposne.Items);
+ }
+
+ var accountId = ListPool.Create(receiveMailUnit.Id);
+ var mail = MailFactory.Create(mailUnit.Scene, MailType.User, request.Title, request.Content, request.Money,
+ mailItems);
+ var mailBox = MailBoxFactory.Create(mailUnit.Scene, MailBoxType.Specify, mailUnit.Id, mail,
+ 1000 * 60 * 60, accountId);
+ await MailHelper.Send(mailUnit.Scene, mailBox);
+ }
+}
\ No newline at end of file
diff --git a/Hotfix/Game/Mail/Handler/Outer/C2Mail_TestRequestHandler.cs b/Hotfix/Game/Mail/Handler/Outer/C2Mail_TestRequestHandler.cs
new file mode 100644
index 0000000..a91ef9d
--- /dev/null
+++ b/Hotfix/Game/Mail/Handler/Outer/C2Mail_TestRequestHandler.cs
@@ -0,0 +1,22 @@
+using Fantasy.Async;
+using Fantasy.DataStructure.Collection;
+using Fantasy.Network.Interface;
+using NB;
+using NB.Game;
+using NBF;
+
+namespace Fantasy;
+
+public class C2Mail_TestRequestHandler : AddressRPC
+{
+ protected override async FTask Run(Player mailUnit, C2Mail_TestRequest request, Mail2C_TestResponse response, Action reply)
+ {
+ Log.Debug($"这是一个测试的自定义消息协议 Tag:{mailUnit.Id}");
+ response.Tag = "666";
+ // using var accountId = ListPool.Create(65491190472245249);
+ var mail = MailFactory.Create(mailUnit.Scene, MailType.System, "测试所有人指定日期玩家邮件", "测试所有人指定日期玩家邮件内容", 9991);
+ var mailBox = MailBoxFactory.Create(mailUnit.Scene, MailBoxType.AllToDate, mailUnit.Id, mail,
+ 1000 * 60 * 60);
+ await MailHelper.Send(mailUnit.Scene, mailBox);
+ }
+}
\ No newline at end of file
diff --git a/Hotfix/Game/Mail/Helper/MailBoxFactory.cs b/Hotfix/Game/Mail/Helper/MailBoxFactory.cs
new file mode 100644
index 0000000..4e65afe
--- /dev/null
+++ b/Hotfix/Game/Mail/Helper/MailBoxFactory.cs
@@ -0,0 +1,65 @@
+using Fantasy;
+using Fantasy.Entitas;
+using Fantasy.Helper;
+using NB;
+using NB.Game;
+
+namespace NBF;
+
+public static class MailBoxFactory
+{
+ ///
+ /// 创建一个邮件箱
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ public static MailBox Create(Scene scene, MailBoxType mailBoxType, long sendAccountId, Mail mail, int expireTime,
+ List accountId = null)
+ {
+ var mailBox = Entity.Create(scene, true, true);
+ mailBox.SendAccountId = sendAccountId;
+ mailBox.Mail = mail;
+ mailBox.MailBoxType = mailBoxType;
+ mailBox.CreateTime = TimeHelper.Now;
+ mailBox.ExpireTime = mailBox.CreateTime + expireTime;
+
+ if (accountId == null || accountId.Count <= 0)
+ {
+ return mailBox;
+ }
+
+ foreach (var raId in accountId)
+ {
+ mailBox.AccountId.Add(raId);
+ }
+
+ return mailBox;
+ }
+
+ ///
+ /// 创建一个邮件箱
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ public static MailBox Create(Scene scene, MailType mailType, MailBoxType mailBoxType, string title, string content,
+ int money, List
- items,
+ long sendAccountId, int expireTime, List accountId = null)
+ {
+ var mail = MailFactory.Create(scene, mailType, title, content, money, items);
+ return Create(scene, mailBoxType, sendAccountId, mail, expireTime, accountId);
+ }
+}
\ No newline at end of file
diff --git a/Hotfix/Game/Mail/Helper/MailFactory.cs b/Hotfix/Game/Mail/Helper/MailFactory.cs
new file mode 100644
index 0000000..f8958f6
--- /dev/null
+++ b/Hotfix/Game/Mail/Helper/MailFactory.cs
@@ -0,0 +1,45 @@
+using Fantasy;
+using Fantasy.Entitas;
+using Fantasy.Serialize;
+using NB;
+using NB.Game;
+
+namespace NBF;
+
+public static class MailFactory
+{
+ ///
+ /// 创建一个基础的邮件
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ public static Mail Create(Scene scene, MailType mailType, string title, string content, int money = 0,
+ List
- items = null)
+ {
+ var mail = Entity.Create(scene, true, true);
+ mail.Title = title;
+ mail.Content = content;
+ mail.Money = money;
+ mail.MailType = mailType;
+ mail.MailState = MailState.Unread;
+
+
+ if (items != null && items.Count > 0)
+ {
+ foreach (var item in items)
+ {
+ // 最好的是要个这个Item给克隆出一份来。
+ // 这样就可以保证,无论外面怎么改变也不会影响这个邮件的东西了。
+ var cloneItem = SerializerManager.BsonPack.CloneEntity(item);
+ mail.Items.Add(cloneItem);
+ }
+ }
+
+ return mail;
+ }
+}
\ No newline at end of file
diff --git a/Hotfix/Game/Mail/Helper/MailHelper.cs b/Hotfix/Game/Mail/Helper/MailHelper.cs
new file mode 100644
index 0000000..97f9d96
--- /dev/null
+++ b/Hotfix/Game/Mail/Helper/MailHelper.cs
@@ -0,0 +1,205 @@
+using Fantasy;
+using Fantasy.Async;
+using Fantasy.DataStructure.Collection;
+using Fantasy.Platform.Net;
+using Fantasy.Serialize;
+using NB;
+using NB.Game;
+
+namespace NBF;
+
+///
+/// 发送邮件的唯一接口
+/// 如果不是通过这个接口发送的邮件、出现任何问题,后果自负
+///
+public static class MailHelper
+{
+ ///
+ /// 发送邮件
+ ///
+ ///
+ /// 发送完成后,记着一定要销毁这个MailBox,不然会有GC。
+ public static async FTask Send(Scene scene, MailBox mailBox)
+ {
+ if (scene.SceneType == SceneType.Game)
+ {
+ await InnerSend(scene, mailBox);
+ return;
+ }
+
+ // 如果不在同一个Scene下,就需要发送内部的网络消息给这个Scene了
+ var mailSceneConfig = SceneConfigData.Instance.GetSceneBySceneType(SceneType.Game)[0];
+ // await scene.NetworkMessagingComponent.CallInnerRoute(mailSceneConfig.RouteId, new Other2Mail_SendMailRequest()
+ // {
+ // MailBox = mailBox
+ // });
+ scene.NetworkMessagingComponent.Send(mailSceneConfig.Address, new Other2Mail_SendMailRequest()
+ {
+ MailBox = mailBox
+ });
+ }
+
+ ///
+ /// 发送邮件
+ ///
+ ///
+ ///
+ ///
+ private static async FTask InnerSend(Scene scene, MailBox mailBox)
+ {
+ // 现在的情况,这个接口只能是在Mail这个服务器下可以操作
+ // 但是真实的情况,其他同时开发的逻辑,调用这个接口一般都是在其他的服务器。
+ // 这个问题其实很好解决,只需要判定当前Scene不是Mail、那就做一个协议,自动发送到这个MailScene就可以了。
+
+ if (mailBox.MailBoxType == MailBoxType.None)
+ {
+ Log.Error("MailBoxType MailBoxType.None not support!");
+ return;
+ }
+
+ var playerManageComponent = scene.GetComponent();
+ var mailBoxManageComponent = scene.GetComponent();
+ mailBoxManageComponent.MailBoxes.Add(mailBox.Id, mailBox);
+
+ switch (mailBox.MailBoxType)
+ {
+ case MailBoxType.Specify:
+ {
+ if (mailBox.AccountId.Count <= 0)
+ {
+ Log.Error($"{mailBox.Id} AccountId is 0!");
+ return;
+ }
+
+ // 这里可能有几种情况
+ // 1、AccountId里面可能只有一个人。
+ // 2、AccountId里面有多个人。
+
+ using var sendAccountIds = ListPool.Create();
+
+ foreach (var accountId in mailBox.AccountId)
+ {
+ if (!playerManageComponent.TryGet(accountId, out var mailUnit))
+ {
+ // 如果没有的话,代表这个用户根本不存在。
+ // 那这样的情况就不需要做任何处理。
+ continue;
+ }
+
+ // 如果有的话,那么就给这个用户发送邮件。
+ // 这个玩家是否在线?
+ var mailComponent = mailUnit.GetComponent();
+ // 在线的话,就直接发送邮件给这个玩家就可以了。
+ if (mailComponent != null)
+ {
+ await mailComponent.Add(SerializerManager.BsonPack.CloneEntity(mailBox.Mail), true);
+ sendAccountIds.Add(accountId);
+ }
+ else
+ {
+ // 不在线
+ // 首先
+ // 1、如果玩家不在线,那就把这个邮件在数据库中拿出来,然后把邮件插入到玩家的邮件列表里。然后再保存
+ // 这样的做法是不推荐的,因为咱们游戏所有的东西都是有状态的,但是你拿出来的邮件是没有状态的。这样可能会导致一些问题的出现。
+ // 正确的做做法:
+ // 把这个邮件方法一个地方,比如是一个处理中心,当玩家上线的时候,主动去这个中心领取这个邮件。
+ // 快递驿站、菜鸟、
+ mailBoxManageComponent.MailsByAccount.Add(accountId, mailBox);
+ Log.Debug("发送离线邮件成功,用户上线第一时间会领取这个邮件。");
+ }
+ }
+
+ // 移除掉发送成功的账号。
+
+ foreach (var sendAccountId in sendAccountIds)
+ {
+ mailBox.AccountId.Remove(sendAccountId);
+ }
+
+ // 如果没有任何收件人了、就可以把这个邮箱给删除了。
+
+ if (mailBox.AccountId.Count <= 0)
+ {
+ mailBox.Dispose();
+ }
+ else
+ {
+ // 当这个邮件箱还有没有接收的玩家时候,要保存到数据库中,方便下次停服维护再重新启动的时候,加载这个邮件箱。
+ await scene.World.Database.Save(mailBox);
+ Log.Debug("保存离线邮件成功");
+ }
+
+ break;
+ }
+ case MailBoxType.Online:
+ {
+ // // 这里有个问题,如何知道在线的人呢?
+ // foreach (var (_, mailUnit) in mailUnitManageComponent.UnitByAccountId)
+ // {
+ // var mailComponent = mailUnit.GetComponent();
+ // if (mailComponent == null)
+ // {
+ // continue;
+ // }
+ // // 能指定到这里的都是在线的玩家。
+ // await mailComponent.Add(MailFactory.Serializer.Clone(mailBox.Mail), true);
+ // }
+ try
+ {
+ foreach (var (_, mailUnit) in playerManageComponent.Players)
+ {
+ await mailUnit.GetComponent()
+ .Add(SerializerManager.BsonPack.CloneEntity(mailBox.Mail), true);
+ }
+ }
+ finally
+ {
+ mailBox.Dispose();
+ }
+
+ break;
+ }
+ case MailBoxType.All:
+ {
+ // 要保证这个邮件一定要有一个生命周期。并且这个周期一定要短,如果是想要实现永久的,可以比如30天发送一次。
+ mailBoxManageComponent.MailsByMailBoxType.Add((int)MailBoxType.All, mailBox);
+ // 首先给所有在线的玩家发送。
+ foreach (var (_, mailUnit) in playerManageComponent.Players)
+ {
+ await mailUnit.GetComponent()
+ .Add(SerializerManager.BsonPack.CloneEntity(mailBox.Mail), true);
+ // 在邮件盒子中记录下玩家领取的记录,避免重复领取。
+ mailBox.Received.Add(mailUnit.Id);
+ }
+
+ // 保存邮件箱到数据库。
+ await scene.World.Database.Save(mailBox);
+ break;
+ }
+ case MailBoxType.AllToDate:
+ {
+ mailBoxManageComponent.MailsByMailBoxType.Add((int)MailBoxType.AllToDate, mailBox);
+ foreach (var (_, player) in playerManageComponent.Players)
+ {
+ if (player.CreateTime > mailBox.CreateTime)
+ {
+ // 如果执行到这里,表示这里用户是这个邮件创建之后的用户。这个就不要发送了
+ continue;
+ }
+
+ // 所以这个邮件类型的逻辑就是,给当前邮件创建时间之前的玩家发送。
+ await player.GetComponent()
+ .Add(SerializerManager.BsonPack.CloneEntity(mailBox.Mail), true);
+ // 在邮件盒子中记录下玩家领取的记录,避免重复领取。
+ mailBox.Received.Add(player.Id);
+ }
+
+ // 保存邮件箱到数据库。
+ await scene.World.Database.Save(mailBox);
+ break;
+ }
+ // 根据玩家等级、等等这样的邮件箱类型,都可以自行扩展了
+ // 课下作业、自己实现一个起来类型的邮箱。
+ }
+ }
+}
\ No newline at end of file
diff --git a/Hotfix/Game/Mail/System/MailBoxManageComponentSystem.cs b/Hotfix/Game/Mail/System/MailBoxManageComponentSystem.cs
new file mode 100644
index 0000000..5e3d13d
--- /dev/null
+++ b/Hotfix/Game/Mail/System/MailBoxManageComponentSystem.cs
@@ -0,0 +1,230 @@
+using Fantasy;
+using Fantasy.Async;
+using Fantasy.DataStructure.Collection;
+using Fantasy.Entitas.Interface;
+using Fantasy.Helper;
+using Fantasy.Serialize;
+using NB;
+using NB.Game;
+
+namespace NBF;
+
+
+public class MailBoxManageComponentDestroySystem : DestroySystem
+{
+ protected override void Destroy(MailBoxManageComponent self)
+ {
+ if (self.TimerId != 0)
+ {
+ self.Scene.TimerComponent.Net.Remove(ref self.TimerId);
+ }
+
+ foreach (var (_, mailBox) in self.MailBoxes)
+ {
+ mailBox.Dispose();
+ }
+
+ self.MinTime = 0;
+ self.MailsByAccount.Clear();
+ self.MailsByMailBoxType.Clear();
+ self.Timers.Clear();
+ self.TimeOutQueue.Clear();
+ }
+}
+
+public static class MailBoxManageComponentSystem
+{
+ public static async FTask Init(this MailBoxManageComponent self)
+ {
+ // 获取数据库中所有的没有处理完成的MailBox
+
+ var mailBoxes = await self.Scene.World.Database.Query(d => true);
+
+ foreach (var mailBox in mailBoxes)
+ {
+ self.MailBoxes.Add(mailBox.Id, mailBox);
+
+ switch (mailBox.MailBoxType)
+ {
+ case MailBoxType.Specify:
+ {
+ foreach (var accountId in mailBox.AccountId)
+ {
+ self.MailsByAccount.Add(accountId, mailBox);
+ }
+
+ break;
+ }
+ case MailBoxType.All:
+ case MailBoxType.AllToDate:
+ {
+ self.MailsByMailBoxType.Add((int)mailBox.MailBoxType, mailBox);
+ break;
+ }
+ }
+ }
+
+ self.TimerId = self.Scene.TimerComponent.Net.RepeatedTimer(MailBoxManageComponent.MailCheckTIme, self.Timeout);
+ }
+
+ private static void Timeout(this MailBoxManageComponent self)
+ {
+ var currentTime = TimeHelper.Now;
+
+ if (currentTime < self.MinTime)
+ {
+ return;
+ }
+
+ // 检查当然时候有过期的邮件箱需要处理
+
+ foreach (var (timeKey, _) in self.Timers)
+ {
+ if (timeKey > currentTime)
+ {
+ self.MinTime = timeKey;
+ break;
+ }
+
+ self.TimeOutQueue.Enqueue(timeKey);
+ }
+
+ while (self.TimeOutQueue.TryDequeue(out var timeKey))
+ {
+ foreach (var mailBoxId in self.Timers[timeKey])
+ {
+ Log.Info($"MailBox:{mailBoxId} 过期了!");
+ self.Remove(mailBoxId).Coroutine();
+ }
+
+ self.Timers.RemoveKey(timeKey);
+ }
+ }
+
+ public static async FTask Remove(this MailBoxManageComponent self, long mailBoxId)
+ {
+ if (!self.MailBoxes.Remove(mailBoxId, out var mailBox))
+ {
+ return;
+ }
+
+ // 先删除按照分类存储的邮箱
+ self.MailsByMailBoxType.RemoveValue((int)mailBox.MailBoxType, mailBox);
+ // 删除个人邮件的邮件箱
+ self.MailsByAccount.RemoveValue(mailBoxId, mailBox);
+ // 在数据库中删除这个邮件
+ await self.Scene.World.Database.Remove(mailBoxId);
+ // 销毁这个MailBox
+ mailBox.Dispose();
+ }
+
+ public static async FTask GetHaveMail(this MailBoxManageComponent self, Player mailUnit, bool sync)
+ {
+ var now = TimeHelper.Now;
+ var worldDataBase = self.Scene.World.Database;
+ var mailComponent = mailUnit.GetComponent();
+
+ // 玩家领取范围邮件的逻辑处理
+
+ foreach (var (mailBoxType, mailBoxList) in self.MailsByMailBoxType)
+ {
+ using var removeMailBox = ListPool.Create();
+ switch ((MailBoxType)mailBoxType)
+ {
+ // 发送给所有人的邮件
+ case MailBoxType.All:
+ {
+ foreach (var mailBox in mailBoxList)
+ {
+ if (!mailBox.Received.Contains(mailUnit.Id))
+ {
+ // 如果是没有领取过这个邮件,首先要把自己添加到领取过的名单中。
+ mailBox.Received.Add(mailUnit.Id);
+ // 发送给自己的邮件列表里添加邮件。
+ await mailUnit.GetComponent().Add(SerializerManager.BsonPack.CloneEntity(mailBox.Mail), true);
+ }
+
+ if (mailBox.ExpireTime <= now)
+ {
+ // 邮件已经过期了,要进行清理这个邮件的操作了
+ removeMailBox.Add(mailBox);
+ continue;
+ }
+
+ // 保存邮件箱状态到数据库中。
+ await worldDataBase.Save(mailBox);
+ }
+
+ foreach (var mailBox in removeMailBox)
+ {
+ await self.Remove(mailBox.Id);
+ }
+
+ // 这里有一个小的细节要处理,这里大家课下自己实现一下。
+ break;
+ }
+ case MailBoxType.AllToDate:
+ {
+ foreach (var mailBox in mailBoxList)
+ {
+ Log.Debug($"mailBox.CreateTime >= mailUnit.CreateTime {mailBox.CreateTime} >= {mailUnit.CreateTime}");
+ if (mailBox.CreateTime >= mailUnit.CreateTime && !mailBox.Received.Contains(mailUnit.Id))
+ {
+ // 如果是没有领取过这个邮件,首先要把自己添加到领取过的名单中。
+ mailBox.Received.Add(mailUnit.Id);
+ // 发送给自己的邮件列表里添加邮件。
+ await mailUnit.GetComponent().Add(SerializerManager.BsonPack.CloneEntity(mailBox.Mail), true);
+ }
+
+ if (mailBox.ExpireTime <= now)
+ {
+ // 邮件已经过期了,要进行清理这个邮件的操作了
+ removeMailBox.Add(mailBox);
+ continue;
+ }
+
+ // 保存邮件箱状态到数据库中。
+ await worldDataBase.Save(mailBox);
+ }
+
+ foreach (var mailBox in removeMailBox)
+ {
+ await self.Remove(mailBox.Id);
+ }
+
+ break;
+ }
+ }
+ }
+
+
+ if (self.MailsByAccount.TryGetValue(mailUnit.Id, out var mailBoxes))
+ {
+ using var removeMailBox = ListPool.Create();
+ foreach (var mailBox in mailBoxes)
+ {
+ var cloneMail = SerializerManager.BsonPack.CloneEntity(mailBox.Mail);
+ await mailComponent.Add(cloneMail, sync);
+ mailBox.AccountId.Remove(mailUnit.Id);
+ Log.Debug($"领取了一个离线邮件 MailId:{cloneMail.Id}");
+
+ if (mailBox.AccountId.Count <= 0)
+ {
+ // 当邮件箱里没有要发送的玩家了,就表示这个邮件箱已经没有用处,可以删除了。
+ removeMailBox.Add(mailBox);
+ }
+ }
+
+ foreach (var mailBox in removeMailBox)
+ {
+ await self.Remove(mailBox.Id);
+ }
+
+ if (mailBoxes.Count <= 0)
+ {
+ // 如果MailsByAccount里的邮件箱已经没有邮件了,就删除这个邮件箱的缓存。
+ self.MailsByAccount.Remove(mailUnit.Id);
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/Hotfix/Game/Social/Mail/System/MailBoxSystem.cs b/Hotfix/Game/Mail/System/MailBoxSystem.cs
similarity index 76%
rename from Hotfix/Game/Social/Mail/System/MailBoxSystem.cs
rename to Hotfix/Game/Mail/System/MailBoxSystem.cs
index 0019f06..ccde623 100644
--- a/Hotfix/Game/Social/Mail/System/MailBoxSystem.cs
+++ b/Hotfix/Game/Mail/System/MailBoxSystem.cs
@@ -1,6 +1,8 @@
-using Fantasy.Entitas.Interface;
+using Fantasy;
+using Fantasy.Entitas.Interface;
+using NB;
-namespace NB.Chat;
+namespace NBF;
public class MailBoxDestroySystem : DestroySystem
{
@@ -12,7 +14,7 @@ public class MailBoxDestroySystem : DestroySystem
self.Mail = null;
}
- self.BoxType = MailBoxType.None;
+ self.MailBoxType = MailBoxType.None;
self.CreateTime = 0;
self.ExpireTime = 0;
self.SendAccountId = 0;
diff --git a/Hotfix/Game/Mail/System/MailComponentSystem.cs b/Hotfix/Game/Mail/System/MailComponentSystem.cs
new file mode 100644
index 0000000..b6dd590
--- /dev/null
+++ b/Hotfix/Game/Mail/System/MailComponentSystem.cs
@@ -0,0 +1,234 @@
+using Fantasy;
+using Fantasy.Async;
+using Fantasy.DataStructure.Collection;
+using Fantasy.Entitas.Interface;
+using Fantasy.Helper;
+using NB;
+using NB.Game;
+
+namespace NBF;
+
+public class MailComponentDestroySystem : DestroySystem
+{
+ protected override void Destroy(MailComponent self)
+ {
+ foreach (var (_, mail) in self.Mails)
+ {
+ mail.Dispose();
+ }
+
+ self.Mails.Clear();
+ self.Timer.Clear();
+ }
+}
+
+public class MailComponentDeserializeSystem : DeserializeSystem
+{
+ protected override void Deserialize(MailComponent self)
+ {
+ self.Timer.Clear();
+ foreach (var (_, mail) in self.Mails)
+ {
+ self.Timer.Add(mail.ExpireTime, mail.Id);
+ }
+ }
+}
+
+public static class MailComponentSystem
+{
+ public static async FTask Add(this MailComponent self, Mail mail, bool sync)
+ {
+ mail.CreateTime = TimeHelper.Now;
+ mail.ExpireTime = mail.CreateTime + MailComponent.MailExpireTime;
+
+ // 如果身上的邮件数量,大于了设置的最大数量怎么办?
+ // 先不用考虑,稍后咱们再解决问题。
+ if (self.Mails.Count >= MailComponent.MaxMailCount)
+ {
+ // 删除最老的邮件。
+ var (_, value) = self.Timer.First();
+ var removeId = value[0];
+ await self.Remove(removeId, MailRemoveActionType.Overtop, sync);
+ }
+
+ self.Mails.Add(mail.Id, mail);
+ self.Timer.Add(mail.ExpireTime, mail.Id);
+
+ if (sync)
+ {
+ // 同步邮件状态给客户端。
+ self.Scene.NetworkMessagingComponent.Send(self.GetParent().SessionRunTimeId,
+ new Mail2C_HaveMail()
+ {
+ Mail = mail.ToMailSimplifyInfo()
+ });
+ }
+
+ // 这里的保存,也可以不用,这里看情况而定。
+ await self.Scene.World.Database.Save(self);
+ Log.Info($"MailComponentSystem Add {mail.Id} Count:{self.Mails.Count}");
+ }
+
+ public static async FTask Remove(this MailComponent self, long mailId,
+ MailRemoveActionType mailRemoveActionType, bool sync)
+ {
+ if (!self.Mails.Remove(mailId, out var mail))
+ {
+ // 这里的1代表的没有找到对应邮件。
+ return 1;
+ }
+
+ self.Timer.RemoveValue(mail.ExpireTime, mail.Id);
+ mail.Dispose();
+
+ if (sync)
+ {
+ // 同步给客户端,邮件删除的消息。
+ self.Scene.NetworkMessagingComponent.Send(self.GetParent().SessionRunTimeId,
+ new Mail2C_MailState()
+ {
+ MailState = (int)mailRemoveActionType, MailId = mailId
+ });
+ }
+
+ // 保存下数据库。
+ await self.Scene.World.Database.Save(self);
+ Log.Info(
+ $"MailComponentSystem Remove {mailId} mailRemoveActionType:{mailRemoveActionType} Count:{self.Mails.Count}");
+ return 0;
+ }
+
+ public static async FTask CheckTimeOut(this MailComponent self)
+ {
+ var now = TimeHelper.Now;
+ using var listPool = ListPool.Create();
+
+ foreach (var (_, mail) in self.Mails)
+ {
+ if (mail.ExpireTime > now)
+ {
+ continue;
+ }
+
+ listPool.Add(mail.Id);
+ }
+
+ foreach (var mailId in listPool)
+ {
+ await self.Remove(mailId, MailRemoveActionType.ExpireTimeRemove, false);
+ }
+
+ Log.Info($"MailComponentSystem CheckTimeOut Count:{listPool.Count}");
+ }
+
+ public static async FTask<(uint ErrorCode, Mail mail)> OpenMail(this MailComponent self, long mailId)
+ {
+ if (!self.Mails.TryGetValue(mailId, out var mail))
+ {
+ // 这个1代表的是没有找到对应邮件
+ return (1, null);
+ }
+
+ if (mail.ExpireTime < TimeHelper.Now)
+ {
+ // 如果邮件已经过期了,需要清楚这个邮件。
+ await self.Remove(mailId, MailRemoveActionType.ExpireTimeRemove, true);
+ // 这里2代表的是邮件已经过期。
+ return (2, null);
+ }
+
+ mail.MailState = MailState.HaveRead;
+ // 这个保存数据库不是必须要保存的,因为一个邮件的查看状态并不能影响游戏的逻辑。
+ // 这里的话,大家看自己的需求而定。
+ await self.Scene.World.Database.Save(self);
+ return (0, mail);
+ }
+
+ public static void GetMailSimplifyInfos(this MailComponent self, ICollection mailSimplifyInfos)
+ {
+ foreach (var (_, mail) in self.Mails)
+ {
+ mailSimplifyInfos.Add(mail.ToMailSimplifyInfo());
+ }
+ }
+
+ public static void GetMailSimplifyInfos(this MailComponent self, ICollection mailSimplifyInfos,
+ int pageIndex, int pageSize)
+ {
+ foreach (var (_, mail) in self.Mails.Skip((pageIndex - 1) * pageSize).Take(pageSize))
+ {
+ mailSimplifyInfos.Add(mail.ToMailSimplifyInfo());
+ }
+ }
+
+ public static async FTask Receive(this MailComponent self, long mailId, bool money, List item,
+ bool sync)
+ {
+ if (!self.Mails.TryGetValue(mailId, out var mail))
+ {
+ // 这里的1代表是没有找到该邮件。
+ return 1;
+ }
+
+ var needSave = false;
+
+ if (money && mail.Money > 0)
+ {
+ // 领取金钱一般都是在玩家身上,但现在咱们所在的服务器是Mail服务器,玩家并不在这个服务器.
+ // 所以一般金钱的操作会有一个专用的接口来操作。这个接口无论在什么服务器上,都会正确的发送到用户所在的服务器上进行金钱操作。
+ // 假设下面的增加金钱的一个异步接口。
+ // var resposne = await MoneyHelper.Add(self.Scene, mail.Money, sync);
+ // if (resposne.ErrorCode != 0)
+ // {
+ // // 这里的2代表的是金钱添加失败。
+ // return 2;
+ // }
+ // 再假设增加金钱是成功的,那么咱们就要处理邮件相关信息了。
+ mail.Money = 0;
+ needSave = true;
+ }
+
+ if (item != null && item.Count > 0)
+ {
+ using var listItem = ListPool
- .Create();
+ foreach (var itemId in item)
+ {
+ var rItem = mail.Items.FirstOrDefault(d => d.Id == itemId);
+ if (rItem == null)
+ {
+ continue;
+ }
+
+ listItem.Add(rItem);
+ }
+
+ // 假设背包在其他服务器,需要调用某一个接口来添加物品到目标服务器的背包身上。
+ // var response = await BagHelper.Add(self.Scene, listItem, sync);
+ // if (response.ErrorCode != 0)
+ // {
+ // return 2;
+ // }
+ // 还有一种情况,就是背包里的空间只有一个空余位置了,也就是只能放进一个物品了,但是邮件领取的是2个物品.
+ // 会有下面2中情况,当然这个情况是要策划来决定怎么处理:
+ // 1、只领取一个物品到背包中,另外一个不领取,然后提示用户背包已满。
+ // 2、一个都不领取,直接提示用户背包已满。
+ // 如果是是第一种情况下,把BagHelper.Add接口,就需要返回添加成功的物品ID,方便邮件来处理。
+ // 假设全部物品都领取成功了,就可以执行下面的逻辑了。
+
+ foreach (var item1 in listItem)
+ {
+ mail.Items.Remove(item1);
+ item1.Dispose();
+ }
+
+ needSave = true;
+ }
+
+ if (needSave)
+ {
+ await self.Scene.World.Database.Save(self);
+ }
+
+ return 0;
+ }
+}
\ No newline at end of file
diff --git a/Hotfix/Game/Mail/System/MailSystem.cs b/Hotfix/Game/Mail/System/MailSystem.cs
new file mode 100644
index 0000000..f56c3dd
--- /dev/null
+++ b/Hotfix/Game/Mail/System/MailSystem.cs
@@ -0,0 +1,77 @@
+using Fantasy;
+using Fantasy.Entitas.Interface;
+using NB;
+
+namespace NBF;
+
+
+public sealed class MailDestroySystem : DestroySystem
+{
+ protected override void Destroy(Mail self)
+ {
+ self.OwnerId = 0;
+ self.Title = null;
+ self.Content = null;
+ self.CreateTime = 0;
+ self.ExpireTime = 0;
+ self.Money = 0;
+ self.MailState = MailState.None;
+ self.MailType = MailType.None;
+
+ foreach (var selfItem in self.Items)
+ {
+ selfItem.Dispose();
+ }
+
+ self.Items.Clear();
+ }
+}
+
+public static class MailSystem
+{
+ public static MailSimplifyInfo ToMailSimplifyInfo(this Mail self)
+ {
+ return new MailSimplifyInfo()
+ {
+ MailId = self.Id,
+ OwnerId = self.OwnerId,
+ Title = self.Title,
+ Content = self.Content,
+ CreateTime = self.CreateTime,
+ ExpireTime = self.ExpireTime,
+ MailState = (int)self.MailState,
+ MailType = (int)self.MailType
+ };
+ }
+
+ public static MailInfo ToMailInfo(this Mail self)
+ {
+ var mailInfo = new MailInfo()
+ {
+ MailId = self.Id,
+ OwnerId = self.OwnerId,
+ Title = self.Title,
+ Content = self.Content,
+ CreateTime = self.CreateTime,
+ ExpireTime = self.ExpireTime,
+ Money = self.Money,
+ MailState = (int)self.MailState,
+ MailType = (int)self.MailType
+ };
+
+ foreach (var selfItem in self.Items)
+ {
+ mailInfo.Items.Add(new ItemInfo()
+ {
+ Id = selfItem.Id,
+ ConfigId = selfItem.ConfigId,
+ Count = selfItem.Count,
+ ExpirationTime = selfItem.ExpirationTime,
+ GetTime = selfItem.GetTime,
+ Abrasion = selfItem.Abrasion
+ });
+ }
+
+ return mailInfo;
+ }
+}
\ No newline at end of file
diff --git a/Hotfix/Game/Map/System/RoomManageComponentSystem.cs b/Hotfix/Game/Map/System/RoomManageComponentSystem.cs
index 9214a63..3288e43 100644
--- a/Hotfix/Game/Map/System/RoomManageComponentSystem.cs
+++ b/Hotfix/Game/Map/System/RoomManageComponentSystem.cs
@@ -42,7 +42,6 @@ public static class RoomManageComponentSystem
return null;
}
- // roomManageComponent.on
var room = Entity.Create(self.Scene, true, true);
room.Owner = ownerId;
room.RoomId = roomId;
diff --git a/Hotfix/Game/Player/Components/PlayerManageComponentSystem.cs b/Hotfix/Game/Player/Components/PlayerManageComponentSystem.cs
index 6bb3d1b..3c93030 100644
--- a/Hotfix/Game/Player/Components/PlayerManageComponentSystem.cs
+++ b/Hotfix/Game/Player/Components/PlayerManageComponentSystem.cs
@@ -91,7 +91,7 @@ public static class PlayerManageComponentSystem
return null;
}
}
-
+
// account.Statistics.LoginTime = TimeHelper.Now;
// account.SetTestData();
@@ -157,6 +157,7 @@ public static class PlayerManageComponentSystem
player.Country = "cn";
player.Exp = 999;
player.Head = "xxx.png";
+ player.CreateTime = TimeHelper.Now;
// var list = InitConfig.GetList();
var list = Configs.Tables.TbInitItemConfig.DataList;
diff --git a/Hotfix/Game/Player/Entity/PlayerSystem.cs b/Hotfix/Game/Player/Entity/PlayerSystem.cs
index 77f936d..5ceff2b 100644
--- a/Hotfix/Game/Player/Entity/PlayerSystem.cs
+++ b/Hotfix/Game/Player/Entity/PlayerSystem.cs
@@ -5,6 +5,7 @@ using Fantasy.Async;
using Fantasy.Entitas;
using Fantasy.Entitas.Interface;
using Fantasy.Helper;
+using NB.Chat;
#pragma warning disable CS8625 // 无法将 null 字面量转换为非 null 的引用类型。
@@ -31,6 +32,16 @@ public sealed class PlayerDestroySystem : DestroySystem
// self.Statistics.Dispose();
// self.Statistics = null;
+ // 退出当前ChatUnit拥有的所有频道
+ foreach (var (_, chatChannelComponent) in self.Channels)
+ {
+ chatChannelComponent.ExitChannel(self.Id, false);
+ }
+
+ // 理论情况下,这个self.Channels不会存在因为数据的,因为上面已经给清空掉了。
+ // 但是self.Channels.Clear();还是加上吧,防止以后忘记了。
+ self.Channels.Clear();
+
self.SessionRunTimeId = 0;
}
}
@@ -47,7 +58,6 @@ public static class PlayerSystem
///
public static async FTask AddItems(this Player self, Dictionary items)
{
-
var itemContainer = self.GetComponent();
HashSet addType = new HashSet();
foreach (var (key, value) in items)
@@ -64,7 +74,7 @@ public static class PlayerSystem
}
#endregion
-
+
public static MapUnitInfo ToMapUnitInfo(this Player self)
{
var ret = new MapUnitInfo()
@@ -79,11 +89,11 @@ public static class PlayerSystem
ret.Position.x = mapUnit.Position.x;
ret.Position.y = mapUnit.Position.y;
ret.Position.z = mapUnit.Position.z;
-
+
ret.Rotation.x = mapUnit.Rotation.x;
ret.Rotation.y = mapUnit.Rotation.y;
ret.Rotation.z = mapUnit.Rotation.z;
-
+
// ret.Gears
return ret;
diff --git a/Hotfix/Game/Social/Mail/Handler/C2Game_DeleteMailRequestHandler.cs b/Hotfix/Game/Social/Mail/Handler/C2Game_DeleteMailRequestHandler.cs
deleted file mode 100644
index 55f6603..0000000
--- a/Hotfix/Game/Social/Mail/Handler/C2Game_DeleteMailRequestHandler.cs
+++ /dev/null
@@ -1,46 +0,0 @@
-using System;
-using Fantasy;
-using Fantasy.Async;
-using Fantasy.Network.Interface;
-using NB.Game;
-
-namespace NB.Chat;
-
-public class C2Game_DeleteMailRequestHandler : AddressRPC
-{
- protected override async FTask Run(Player entity, C2Game_DeleteMailRequest request,
- Game2C_DeleteMailResponse response, Action reply)
- {
- if (request.Id < 1)
- {
- response.ErrorCode = ErrorCode.ErrArgs;
- return;
- }
-
- var mailManageComponent = entity.Scene.GetComponent();
- if (mailManageComponent == null)
- {
- Log.Error("组件不存在 MailManageComponent");
- response.ErrorCode = ErrorCode.ErrServer;
- return;
- }
-
- var conversation = await mailManageComponent.GetConversation(entity.Id, request.Id);
- if (conversation == null)
- {
- response.ErrorCode = ErrorCode.ErrArgs;
- return;
- }
-
- conversation.RemoveId.Add(entity.Id);
- if (conversation.RemoveId.Count > 1)
- {
- //都删除了,则吧会话直接移除掉
- await mailManageComponent.DeleteConversation(entity.Id, request.Id);
- }
- else
- {
- await conversation.Save();
- }
- }
-}
\ No newline at end of file
diff --git a/Hotfix/Game/Social/Mail/Handler/C2Game_GetConversationsRequestHandler.cs b/Hotfix/Game/Social/Mail/Handler/C2Game_GetConversationsRequestHandler.cs
deleted file mode 100644
index 6f011a2..0000000
--- a/Hotfix/Game/Social/Mail/Handler/C2Game_GetConversationsRequestHandler.cs
+++ /dev/null
@@ -1,24 +0,0 @@
-using System;
-using System.Diagnostics;
-using Fantasy;
-using Fantasy.Async;
-using Fantasy.Network.Interface;
-using NB.Game;
-
-namespace NB.Chat;
-
-public class
- C2Game_GetConversationsRequestHandler : AddressRPC
-{
- protected override async FTask Run(Player entity, C2Game_GetConversationsRequest request,
- Game2C_GetConversationsResponse response, Action reply)
- {
- Stopwatch stopwatch = new Stopwatch();
- stopwatch.Start();
- var mailManageComponent = entity.Scene.GetComponent();
- var list = await mailManageComponent.GetConversations(entity.Id);
- response.List = await list.ToInfo(entity.Scene, entity.Id);
- stopwatch.Stop();
- Log.Info($"查询会话列表耗时={stopwatch.ElapsedMilliseconds}");
- }
-}
\ No newline at end of file
diff --git a/Hotfix/Game/Social/Mail/Handler/C2Game_SendMailRequestHandler.cs b/Hotfix/Game/Social/Mail/Handler/C2Game_SendMailRequestHandler.cs
deleted file mode 100644
index 5280cbd..0000000
--- a/Hotfix/Game/Social/Mail/Handler/C2Game_SendMailRequestHandler.cs
+++ /dev/null
@@ -1,70 +0,0 @@
-using System;
-using Fantasy;
-using Fantasy.Async;
-using Fantasy.Network.Interface;
-using NB.Game;
-
-namespace NB.Chat;
-
-public class C2Game_SendMailRequestHandler : AddressRPC
-{
- protected override async FTask Run(Player entity, C2Game_SendMailRequest request, Game2C_SendMailResponse response,
- Action reply)
- {
- if (request.Target < 1)
- {
- response.ErrorCode = ErrorCode.ErrArgs;
- return;
- }
-
- var mailManageComponent = entity.Scene.GetComponent();
- if (mailManageComponent == null)
- {
- Log.Error("组件不存在 MailManageComponent");
- response.ErrorCode = ErrorCode.ErrServer;
- return;
- }
-
- var chatUnitManage = entity.Scene.GetComponent();
- if (chatUnitManage == null)
- {
- Log.Error("组件不存在 SocialUnitManageComponent");
- response.ErrorCode = ErrorCode.ErrServer;
- return;
- }
-
- var conversation = await mailManageComponent.GetConversation(entity.Id, request.Target);
- if (conversation == null)
- {
- response.ErrorCode = ErrorCode.ErrArgs;
- return;
- }
- //检查是否可以发消息,如果会话只有一句,则不允许再发
- if (!conversation.CanSend(entity.Id))
- {
- response.ErrorCode = ErrorCode.MailNotReply;
- return;
- }
-
- var mail = MailFactory.Create(entity.Scene, request.Content);
- mail.Sender = entity.Id;
- mail.OwnerId = request.Target;
- await conversation.Add(mail);
-
- var res = new Game2C_HaveMail()
- {
- Mail = mail.ToMailInfo(),
- Key = conversation.Key
- };
- //同步客户端
- entity.Scene.NetworkMessagingComponent.Send(entity.SessionRunTimeId, res);
-
- // var chatUnit = chatUnitManage.Get(request.Target);
- //
- // if (chatUnit != null)
- // {
- // //对方在线
- // entity.Scene.NetworkMessagingComponent.Send(chatUnit.GateRouteId, res);
- // }
- }
-}
\ No newline at end of file
diff --git a/Hotfix/Game/Social/Mail/Helper/MailBoxFactory.cs b/Hotfix/Game/Social/Mail/Helper/MailBoxFactory.cs
deleted file mode 100644
index 2725b8d..0000000
--- a/Hotfix/Game/Social/Mail/Helper/MailBoxFactory.cs
+++ /dev/null
@@ -1,56 +0,0 @@
-using System.Collections.Generic;
-using Fantasy;
-using Fantasy.Entitas;
-using Fantasy.Helper;
-using NB.Game;
-
-namespace NB.Chat;
-
-public static class MailBoxFactory
-{
- ///
- /// 创建一个邮件箱
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- public static MailBox Create(Scene scene, long sendAccountId, Mail mail, int expireTime, List accountIds)
- {
- var mailBox = Entity.Create(scene, true, true);
- mailBox.SendAccountId = sendAccountId;
- mailBox.Mail = mail;
- mailBox.ExpireTime = TimeHelper.Now + expireTime;
- mailBox.CreateTime = TimeHelper.Now;
- if (accountIds == null || accountIds.Count <= 0)
- {
- return mailBox;
- }
-
- foreach (var accountId in accountIds)
- {
- mailBox.AccountId.Add(accountId);
- }
-
- return mailBox;
- }
-
- ///
- /// 创建一个邮件箱
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- public static MailBox Create(Scene scene, long sendAccountId, int expireTime, List accountIds,
- string content, List items = null)
- {
- var mail = MailFactory.Create(scene, content, items);
- return Create(scene, sendAccountId, mail, expireTime, accountIds);
- }
-}
\ No newline at end of file
diff --git a/Hotfix/Game/Social/Mail/Helper/MailConversationHelper.cs b/Hotfix/Game/Social/Mail/Helper/MailConversationHelper.cs
deleted file mode 100644
index 56696df..0000000
--- a/Hotfix/Game/Social/Mail/Helper/MailConversationHelper.cs
+++ /dev/null
@@ -1,38 +0,0 @@
-using Fantasy;
-using Fantasy.Async;
-using NB.Game;
-
-namespace NB.Chat;
-
-public static class MailConversationHelper
-{
- ///
- /// 从数据库中读取GameAccount
- ///
- ///
- ///
- ///
- ///
- public static async FTask LoadDataBase(Scene scene, long firstId, long secondId)
- {
- var conversation =
- await scene.World.Database.First(d => d.FirstId == firstId && d.SecondId == secondId);
- if (conversation == null)
- {
- return null;
- }
-
- conversation.Deserialize(scene);
- return conversation;
- }
-
- ///
- /// 从数据库中移除
- ///
- ///
- ///
- public static async FTask DeleteDataBase(Scene scene,long id)
- {
- await scene.World.Database.Remove(id);
- }
-}
\ No newline at end of file
diff --git a/Hotfix/Game/Social/Mail/Helper/MailFactory.cs b/Hotfix/Game/Social/Mail/Helper/MailFactory.cs
deleted file mode 100644
index 6f5a372..0000000
--- a/Hotfix/Game/Social/Mail/Helper/MailFactory.cs
+++ /dev/null
@@ -1,32 +0,0 @@
-using System.Collections.Generic;
-using Fantasy;
-using Fantasy.Entitas;
-using Fantasy.Helper;
-using Fantasy.Serialize;
-using NB.Game;
-
-namespace NB.Chat;
-
-public static class MailFactory
-{
- private static readonly ISerialize _serializer = SerializerManager.BsonPack;
-
- public static Mail Create(Scene scene, string content, List items = null)
- {
-
- var mail = Entity.Create(scene, true, true);
- mail.Content = content;
- mail.State = MailState.Unread;
- mail.CreateTime = TimeHelper.Now;
-
- if (items != null && items.Count > 0)
- {
- foreach (var item in items)
- {
- // mail.Items.Add(_serializer.Clone(item));
- }
- }
-
- return mail;
- }
-}
\ No newline at end of file
diff --git a/Hotfix/Game/Social/Mail/Helper/MailHelper.cs b/Hotfix/Game/Social/Mail/Helper/MailHelper.cs
deleted file mode 100644
index 3ae20fd..0000000
--- a/Hotfix/Game/Social/Mail/Helper/MailHelper.cs
+++ /dev/null
@@ -1,32 +0,0 @@
-using Fantasy;
-using Fantasy.Async;
-
-namespace NB.Chat;
-
-///
-/// 发送邮件接口
-///
-public static class MailHelper
-{
-
- public static async FTask Send(Scene scene, MailBox mailBox)
- {
- if (mailBox.BoxType == MailBoxType.None)
- {
- Log.Error("不支持的邮件类型");
- return;
- }
-
- switch (mailBox.BoxType)
- {
- case MailBoxType.All:
- {
- break;
- }
- case MailBoxType.Specify:
- {
- break;
- }
- }
- }
-}
\ No newline at end of file
diff --git a/Hotfix/Game/Social/Mail/System/MailComponentSystem.cs b/Hotfix/Game/Social/Mail/System/MailComponentSystem.cs
deleted file mode 100644
index ee3b54f..0000000
--- a/Hotfix/Game/Social/Mail/System/MailComponentSystem.cs
+++ /dev/null
@@ -1,80 +0,0 @@
-using System.Linq;
-using Fantasy;
-using Fantasy.Async;
-using Fantasy.Entitas.Interface;
-using Fantasy.Helper;
-
-namespace NB.Chat;
-
-public class MailComponentDestroySystem : DestroySystem
-{
- protected override void Destroy(MailComponent self)
- {
- foreach (var (_, mail) in self.Mails)
- {
- mail.Dispose();
- }
-
- self.Mails.Clear();
- self.Timer.Clear();
- }
-}
-
-public static class MailComponentSystem
-{
- public static async FTask Add(this MailComponent self, Mail mail, bool sync)
- {
- mail.CreateTime = TimeHelper.Now;
- mail.ExpireTime = TimeHelper.Now + MailComponent.MaxExpireTime;
-
- if (self.Mails.Count >= MailComponent.MaxMailCount)
- {
- //删除最老的邮件
- var (_, value) = self.Timer.First();
- foreach (var removeId in value)
- {
- await self.Remove(removeId, sync);
- }
- }
-
- self.Mails.Add(mail.Id, mail);
- self.Timer.Add(mail.ExpireTime, mail.Id);
-
- if (sync)
- {
- //同步客户端
- self.Scene.NetworkMessagingComponent.Send(0,new Game2C_HaveMail()
- {
- Mail = mail.ToMailInfo(),
- });
- }
-
- await self.Scene.World.Database.Save(self);
- Log.Info($"MailComponent Add id:{self.Id} mailId:{mail.Id} count:{self.Mails.Count}");
- }
-
- public static async FTask Remove(this MailComponent self, long mailId, bool sync)
- {
- if (!self.Mails.Remove(mailId, out var mail))
- {
- return 1;
- }
-
- self.Timer.RemoveValue(mail.ExpireTime, mail.Id);
- mail.Dispose();
-
- if (sync)
- {
- //同步客户端
- self.Scene.NetworkMessagingComponent.Send(0,new Game2C_MailState()
- {
- MailState = (int)MailState.Deleted,
- MailId = mailId,
- });
- }
-
- await self.Scene.World.Database.Save(self);
- Log.Info($"MailComponent Remove id:{self.Id} mailId:{mail.Id} count:{self.Mails.Count}");
- return 0;
- }
-}
\ No newline at end of file
diff --git a/Hotfix/Game/Social/Mail/System/MailConversationSystem.cs b/Hotfix/Game/Social/Mail/System/MailConversationSystem.cs
deleted file mode 100644
index 82909f3..0000000
--- a/Hotfix/Game/Social/Mail/System/MailConversationSystem.cs
+++ /dev/null
@@ -1,128 +0,0 @@
-using System.Collections.Generic;
-using System.Linq;
-using Fantasy;
-using Fantasy.Async;
-using Fantasy.Entitas.Interface;
-using Fantasy.Helper;
-using NB.Game;
-
-namespace NB.Chat;
-
-public class MailConversationDeserializeSystem : DeserializeSystem
-{
- protected override void Deserialize(MailConversation self)
- {
- self.Key = $"{self.FirstId}-{self.SecondId}";
- }
-}
-
-public class MailConversationDestroySystem : DestroySystem
-{
- protected override void Destroy(MailConversation self)
- {
- foreach (var mail in self.Mails)
- {
- mail.Dispose();
- }
-
- self.Mails.Clear();
- self.FirstId = 0;
- self.SecondId = 0;
- self.Key = string.Empty;
- }
-}
-
-public static class MailConversationSystem
-{
- public static async FTask Add(this MailConversation self, Mail mail)
- {
- self.Mails.Add(mail);
- if (self.Mails.Count > AppConfig.MaxConversationCount)
- {
- self.Mails.RemoveAt(0);
- }
-
- if (mail.Items != null && mail.Items.Count > 0)
- {
- //有附件需要立马保存
- await self.Save(true);
- }
- else
- {
- await self.Save(false);
- }
- }
-
- public static async FTask Save(this MailConversation self, bool forceSave = true)
- {
- // self.NeedSave = true;
- // self.NeedSaveTime = TimeHelper.Now + AppConfig.PlayerDataAutoSaveTime;
- if (forceSave)
- {
- self.UpdateTime = TimeHelper.Now;
- await self.Scene.World.Database.Save(self);
- }
- else
- {
- self.NeedSave = true;
- self.NeedSaveTime = TimeHelper.Now + AppConfig.ChatDataAutoSaveTime;
- }
- }
-
- ///
- /// 是否可以发送邮件
- ///
- ///
- ///
- ///
- public static bool CanSend(this MailConversation self, long sendId)
- {
- if (self.Mails.Count < 1) return true;
- foreach (var mail in self.Mails)
- {
- if (mail.Sender != sendId)
- {
- return true;
- }
- }
-
- return false;
- }
-
- #region 转换
-
- public static async FTask
> ToInfo(this List self, Scene scene, long selfId)
- {
- List ret = new List();
- HashSet ids = new HashSet();
- foreach (var conversation in self)
- {
- if (conversation.RemoveId.Contains(selfId)) continue;
- ids.Add(conversation.FirstId);
- ids.Add(conversation.SecondId);
- }
-
- ids.Remove(selfId);
-
- var infos = await CacheHandler.GetPlayerBasicCacheInfos(scene, ids.ToList());
- foreach (var conversation in self)
- {
- if (conversation.RemoveId.Contains(selfId)) continue;
- var item = new ConversationInfo();
- item.List = conversation.Mails.ToMailInfo();
- var otherId = conversation.FirstId == selfId ? conversation.SecondId : conversation.FirstId;
- var info = infos.Find(t => t.RoleId == otherId);
- if (info != null)
- {
- item.RoleInfo = info;
- }
-
- ret.Add(item);
- }
-
-
- return ret;
- }
-
- #endregion
-}
\ No newline at end of file
diff --git a/Hotfix/Game/Social/Mail/System/MailManageComponentSystem.cs b/Hotfix/Game/Social/Mail/System/MailManageComponentSystem.cs
deleted file mode 100644
index 48212bf..0000000
--- a/Hotfix/Game/Social/Mail/System/MailManageComponentSystem.cs
+++ /dev/null
@@ -1,94 +0,0 @@
-using System.Collections.Generic;
-using Fantasy;
-using Fantasy.Async;
-using Fantasy.Entitas;
-using Fantasy.Entitas.Interface;
-using Fantasy.Helper;
-using NB.Game;
-
-namespace NB.Chat;
-
-public class MailManageComponentDestroySystem : DestroySystem
-{
- protected override void Destroy(MailManageComponent self)
- {
- foreach (var (_, conversation) in self.Conversations)
- {
- conversation.Dispose();
- }
-
- self.Conversations.Clear();
- }
-}
-
-public static class MailManageComponentSystem
-{
- public static async FTask DeleteConversation(this MailManageComponent self, long selfId, long otherId)
- {
- var firstId = selfId;
- var secondId = otherId;
- if (otherId < selfId)
- {
- firstId = otherId;
- secondId = selfId;
- }
-
- var key = $"{firstId}-{secondId}";
-
- if (self.Conversations.Remove(key, out var conversation))
- {
- await MailConversationHelper.DeleteDataBase(conversation.Scene, conversation.Id);
- conversation.Dispose();
- }
- }
-
- public static async FTask GetConversation(this MailManageComponent self, long selfId,
- long otherId)
- {
- var firstId = selfId;
- var secondId = otherId;
- if (otherId < selfId)
- {
- firstId = otherId;
- secondId = selfId;
- }
-
- var key = $"{firstId}-{secondId}";
- if (!self.Conversations.TryGetValue(key, out var conversation))
- {
- //检查数据库中是否存在
- conversation = await MailConversationHelper.LoadDataBase(self.Scene, firstId, secondId);
- if (conversation == null)
- {
- //检查id是否合法
- var roleInfo = await CacheHandler.GetPlayerBasicCacheInfo(self.Scene, otherId);
- if (roleInfo == null)
- {
- return null;
- }
-
- conversation = Entity.Create(self.Scene, true, true);
-
- conversation.FirstId = firstId;
- conversation.SecondId = secondId;
-
- conversation.Key = key;
- await conversation.Save(false);
- }
-
- self.Conversations.Add(key, conversation);
- }
-
- return conversation;
- }
-
- public static async FTask> GetConversations(this MailManageComponent self, long id)
- {
- List players =
- await self.Scene.World.Database.QueryByPageOrderBy(
- d => d.FirstId == id || d.SecondId == id, 1, 50,
- d => d.UpdateTime);
-
- return players;
- }
-}
\ No newline at end of file
diff --git a/Hotfix/Game/Social/Mail/System/MailSystem.cs b/Hotfix/Game/Social/Mail/System/MailSystem.cs
deleted file mode 100644
index f73f1d4..0000000
--- a/Hotfix/Game/Social/Mail/System/MailSystem.cs
+++ /dev/null
@@ -1,53 +0,0 @@
-using System.Collections.Generic;
-using Fantasy;
-using Fantasy.Entitas.Interface;
-using NB.Game;
-
-namespace NB.Chat;
-
-public class MailDestroySystem : DestroySystem
-{
- protected override void Destroy(Mail self)
- {
- self.OwnerId = 0;
- self.Sender = 0;
- self.Content = string.Empty;
- self.ExpireTime = 0;
- self.CreateTime = 0;
- self.State = MailState.None;
- self.MailType = MailType.None;
- foreach (var item in self.Items)
- {
- item.Dispose();
- }
-
- self.Items.Clear();
- }
-}
-
-public static class MailSystem
-{
- public static MailInfo ToMailInfo(this Mail mail)
- {
- return new MailInfo()
- {
- Id = mail.Id,
- Content = mail.Content,
- CreateTime = mail.CreateTime,
- MailState = (int)mail.State,
- MailType = (int)mail.MailType,
- Items = mail.Items.ToAwardInfo()
- };
- }
-
- public static List ToMailInfo(this List mails)
- {
- var list = new List();
- foreach (var mail in mails)
- {
- list.Add(mail.ToMailInfo());
- }
-
- return list;
- }
-}
\ No newline at end of file
diff --git a/Hotfix/Game/Social/SocialUnitManageComponentSystem.cs b/Hotfix/Game/Social/SocialUnitManageComponentSystem.cs
deleted file mode 100644
index ea637b0..0000000
--- a/Hotfix/Game/Social/SocialUnitManageComponentSystem.cs
+++ /dev/null
@@ -1,146 +0,0 @@
-// using Fantasy;
-// using Fantasy.Async;
-// using Fantasy.Entitas;
-// using Fantasy.Entitas.Interface;
-// using NB.Chat;
-//
-// namespace NBF.Social;
-//
-// public sealed class ChatUnitManageComponentDestroySystem : DestroySystem
-// {
-// protected override void Destroy(SocialUnitManageComponent self)
-// {
-// foreach (var chatUnit in self.Units.Values.ToArray())
-// {
-// chatUnit.Dispose();
-// }
-//
-// self.Units.Clear();
-// }
-// }
-//
-// public static class SocialUnitManageComponentSystem
-// {
-// #region 消息缓存
-//
-// ///
-// /// 离线消息,进入待领取队列
-// ///
-// ///
-// ///
-// ///
-// public static void SaveOfflineMessage(this SocialUnitManageComponent self, long targetId, ChatMessageInfo message)
-// {
-// // self.NotSendMessage.Add(targetId, message);
-// }
-//
-// #endregion
-//
-// #region 上线下线
-//
-// ///
-// /// 玩家上线
-// ///
-// ///
-// ///
-// ///
-// ///
-// public static async FTask Online(this SocialUnitManageComponent self, Scene scene,
-// long accountId,
-// long gateRouteId)
-// {
-// // var accountId = roleSimpleInfo.RoleId;
-// if (!self.TryGet(accountId, out var account))
-// {
-// account = Entity.Create(scene, accountId, true, true);
-// self.Add(account);
-// }
-//
-// if (account != null)
-// {
-// await account.TryComponent();
-// account.GateRouteId = gateRouteId;
-// // account.Role = roleSimpleInfo;
-// }
-//
-// await FTask.CompletedTask;
-// return account;
-// }
-//
-// public static async FTask Offline(this SocialUnitManageComponent self, Scene scene, long accountId,
-// long gateRouteId)
-// {
-// if (self.TryGet(accountId, out var unit) && unit != null)
-// {
-// if (unit.GateRouteId == gateRouteId)
-// {
-// Log.Info("退出当前聊天服==");
-// self.Remove(accountId); //如果当前网关和下线的网关一致
-// }
-// }
-//
-// await FTask.CompletedTask;
-// }
-//
-// #endregion
-//
-// #region 获取&移除
-//
-// public static void Add(this SocialUnitManageComponent self, SocialUnit account)
-// {
-// self.Units.Add(account.Id, account);
-// }
-//
-// public static SocialUnit? Get(this SocialUnitManageComponent self, long accountId)
-// {
-// return self.Units.GetValueOrDefault(accountId);
-// }
-//
-// public static bool TryGet(this SocialUnitManageComponent self, long accountId, out SocialUnit? account)
-// {
-// return self.Units.TryGetValue(accountId, out account);
-// }
-//
-// public static void Remove(this SocialUnitManageComponent self, long accountId, bool isDispose = true)
-// {
-// if (!self.Units.Remove(accountId, out var account))
-// {
-// return;
-// }
-//
-// if (!isDispose)
-// {
-// return;
-// }
-//
-// account.Dispose();
-// }
-//
-// #endregion
-//
-// #region 组件
-//
-// ///
-// /// 尝试给增加相关组件
-// ///
-// ///
-// ///
-// public static async FTask TryComponent(this SocialUnit socialUnit) where T : Entity, new()
-// {
-// if (socialUnit.GetComponent() == null)
-// {
-// var mailComponent = await socialUnit.Scene.World.Database.Query(socialUnit.Id, true);
-// if (mailComponent == null)
-// {
-// //如果没有邮件组件
-// socialUnit.AddComponent();
-// }
-// else
-// {
-// socialUnit.AddComponent(mailComponent);
-// }
-// }
-// }
-//
-// #endregion
-// }
\ No newline at end of file
diff --git a/Hotfix/Game/Social/SocialUnitSystem.cs b/Hotfix/Game/Social/SocialUnitSystem.cs
deleted file mode 100644
index 9828fc0..0000000
--- a/Hotfix/Game/Social/SocialUnitSystem.cs
+++ /dev/null
@@ -1,22 +0,0 @@
-// using Fantasy.Entitas.Interface;
-// #pragma warning disable CS8625 // Cannot convert null literal to non-nullable reference type.
-//
-// namespace NB.Chat;
-//
-// public sealed class SocialUnitDestroySystem : DestroySystem
-// {
-// protected override void Destroy(SocialUnit self)
-// {
-// self.Role?.Return();
-// self.Role = null;
-// self.GateRouteId = 0;
-// // 退出当前ChatUnit拥有的所有频道
-// foreach (var (_,chatChannelComponent) in self.Channels)
-// {
-// chatChannelComponent.ExitChannel(self.Id, false);
-// }
-// // 理论情况下,这个self.Channels不会存在因为数据的,因为上面已经给清空掉了。
-// // 但是self.Channels.Clear();还是加上吧,防止以后忘记了。
-// self.Channels.Clear();
-// }
-// }
\ No newline at end of file
diff --git a/Hotfix/Hotfix.csproj b/Hotfix/Hotfix.csproj
index e60aa11..eeee4d2 100644
--- a/Hotfix/Hotfix.csproj
+++ b/Hotfix/Hotfix.csproj
@@ -12,4 +12,9 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/Hotfix/OnCreateSceneEvent.cs b/Hotfix/OnCreateSceneEvent.cs
index 6713703..5a2464c 100644
--- a/Hotfix/OnCreateSceneEvent.cs
+++ b/Hotfix/OnCreateSceneEvent.cs
@@ -138,10 +138,9 @@ public sealed class OnCreateSceneEvent : AsyncEventSystem
private async FTask InitializeSocialScene(Scene scene)
{
- Log.Info($"初始化 Social 场景: {scene.Id}");
- //用于管理玩家的组件
- scene.AddComponent();
- //聊天
+ // Log.Info($"初始化 Social 场景: {scene.Id}");
+ // 离线邮件箱管理组件。
+ await scene.AddComponent().Init();
// 聊天频道中控中心组件。
scene.AddComponent();
await FTask.CompletedTask;
@@ -154,7 +153,7 @@ public sealed class OnCreateSceneEvent : AsyncEventSystem
//用于管理玩家的组件
scene.AddComponent();
scene.AddComponent();
-
+ await scene.AddComponent().Initialize();
Log.Info("创建地图场景===");
var roomManageComponent = scene.AddComponent();
diff --git a/Main/Main.csproj b/Main/Main.csproj
index 5290c58..c9e56ef 100644
--- a/Main/Main.csproj
+++ b/Main/Main.csproj
@@ -66,5 +66,8 @@
Always
+
+ Always
+
\ No newline at end of file
diff --git a/Main/cfg/tbfish.json b/Main/cfg/tbfish.json
index 737c9b0..6150612 100644
--- a/Main/cfg/tbfish.json
+++ b/Main/cfg/tbfish.json
@@ -4,27 +4,31 @@
"name": "鲤鱼",
"min_weight": 1,
"max_weight": 34,
- "accept": 2100001
+ "accept": 2100001,
+ "water": 0
},
{
"id": 210002,
"name": "金鲫",
"min_weight": 1,
"max_weight": 34,
- "accept": 2100001
+ "accept": 2100001,
+ "water": 0
},
{
"id": 210003,
"name": "银鲫",
"min_weight": 1,
"max_weight": 34,
- "accept": 2100001
+ "accept": 2100001,
+ "water": 0
},
{
"id": 210004,
"name": "拟鲤",
"min_weight": 1,
"max_weight": 34,
- "accept": 2100001
+ "accept": 2100001,
+ "water": 0
}
]
\ No newline at end of file
diff --git a/Main/cfg/tbitem.json b/Main/cfg/tbitem.json
index 4f91c4e..2667de9 100644
--- a/Main/cfg/tbitem.json
+++ b/Main/cfg/tbitem.json
@@ -8,6 +8,7 @@
"length": 0,
"max": 0,
"auto_use": 0,
+ "effect": 0,
"result1": [],
"result2": []
},
@@ -20,6 +21,7 @@
"length": 0,
"max": 0,
"auto_use": 0,
+ "effect": 0,
"result1": [],
"result2": []
},
@@ -32,6 +34,7 @@
"length": 0,
"max": 0,
"auto_use": 0,
+ "effect": 0,
"result1": [],
"result2": []
},
@@ -44,6 +47,7 @@
"length": 0,
"max": 0,
"auto_use": 0,
+ "effect": 0,
"result1": [],
"result2": []
},
@@ -56,6 +60,7 @@
"length": 0,
"max": 0,
"auto_use": 0,
+ "effect": 0,
"result1": [],
"result2": []
},
@@ -68,6 +73,7 @@
"length": 0,
"max": 0,
"auto_use": 0,
+ "effect": 0,
"result1": [],
"result2": []
},
@@ -80,6 +86,7 @@
"length": 0,
"max": 0,
"auto_use": 0,
+ "effect": 0,
"result1": [],
"result2": []
},
@@ -92,6 +99,7 @@
"length": 0,
"max": 0,
"auto_use": 0,
+ "effect": 0,
"result1": [],
"result2": []
},
@@ -104,6 +112,7 @@
"length": 0,
"max": 0,
"auto_use": 0,
+ "effect": 0,
"result1": [],
"result2": []
},
@@ -116,6 +125,7 @@
"length": 0,
"max": 0,
"auto_use": 0,
+ "effect": 0,
"result1": [],
"result2": []
},
@@ -128,6 +138,7 @@
"length": 0,
"max": 0,
"auto_use": 0,
+ "effect": 0,
"result1": [],
"result2": []
},
@@ -140,6 +151,7 @@
"length": 0,
"max": 0,
"auto_use": 0,
+ "effect": 0,
"result1": [],
"result2": []
},
@@ -152,6 +164,7 @@
"length": 0,
"max": 0,
"auto_use": 0,
+ "effect": 0,
"result1": [],
"result2": []
},
@@ -164,6 +177,7 @@
"length": 0,
"max": 0,
"auto_use": 0,
+ "effect": 0,
"result1": [],
"result2": []
},
@@ -176,6 +190,7 @@
"length": 0,
"max": 0,
"auto_use": 0,
+ "effect": 0,
"result1": [],
"result2": []
},
@@ -188,6 +203,7 @@
"length": 0,
"max": 0,
"auto_use": 0,
+ "effect": 0,
"result1": [],
"result2": []
},
@@ -200,6 +216,7 @@
"length": 0,
"max": 0,
"auto_use": 0,
+ "effect": 0,
"result1": [],
"result2": []
},
@@ -212,6 +229,7 @@
"length": 0,
"max": 0,
"auto_use": 0,
+ "effect": 0,
"result1": [],
"result2": []
},
@@ -224,6 +242,7 @@
"length": 0,
"max": 0,
"auto_use": 0,
+ "effect": 0,
"result1": [],
"result2": []
},
@@ -236,6 +255,7 @@
"length": 0,
"max": 0,
"auto_use": 0,
+ "effect": 0,
"result1": [],
"result2": []
},
@@ -248,6 +268,7 @@
"length": 0,
"max": 0,
"auto_use": 0,
+ "effect": 0,
"result1": [],
"result2": []
},
@@ -260,6 +281,7 @@
"length": 0,
"max": 0,
"auto_use": 0,
+ "effect": 0,
"result1": [],
"result2": []
},
@@ -272,6 +294,7 @@
"length": 0,
"max": 0,
"auto_use": 0,
+ "effect": 0,
"result1": [],
"result2": []
},
@@ -284,6 +307,7 @@
"length": 0,
"max": 0,
"auto_use": 0,
+ "effect": 0,
"result1": [],
"result2": []
},
@@ -296,6 +320,7 @@
"length": 0,
"max": 0,
"auto_use": 0,
+ "effect": 0,
"result1": [],
"result2": []
},
@@ -308,6 +333,7 @@
"length": 0,
"max": 0,
"auto_use": 0,
+ "effect": 0,
"result1": [],
"result2": []
},
@@ -320,6 +346,7 @@
"length": 0,
"max": 0,
"auto_use": 0,
+ "effect": 0,
"result1": [],
"result2": []
},
@@ -332,6 +359,7 @@
"length": 0,
"max": 0,
"auto_use": 0,
+ "effect": 0,
"result1": [],
"result2": []
},
@@ -344,6 +372,7 @@
"length": 0,
"max": 0,
"auto_use": 0,
+ "effect": 0,
"result1": [],
"result2": []
},
@@ -356,6 +385,7 @@
"length": 0,
"max": 0,
"auto_use": 0,
+ "effect": 0,
"result1": [],
"result2": []
},
@@ -368,6 +398,7 @@
"length": 0,
"max": 0,
"auto_use": 0,
+ "effect": 0,
"result1": [],
"result2": []
},
@@ -380,6 +411,7 @@
"length": 0,
"max": 0,
"auto_use": 0,
+ "effect": 0,
"result1": [],
"result2": []
},
@@ -392,6 +424,7 @@
"length": 0,
"max": 0,
"auto_use": 0,
+ "effect": 0,
"result1": [],
"result2": []
},
@@ -404,6 +437,7 @@
"length": 0,
"max": 0,
"auto_use": 0,
+ "effect": 0,
"result1": [],
"result2": []
},
@@ -416,6 +450,7 @@
"length": 0,
"max": 0,
"auto_use": 0,
+ "effect": 0,
"result1": [],
"result2": []
},
@@ -428,6 +463,7 @@
"length": 0,
"max": 0,
"auto_use": 0,
+ "effect": 0,
"result1": [],
"result2": []
},
@@ -440,6 +476,7 @@
"length": 0,
"max": 0,
"auto_use": 0,
+ "effect": 0,
"result1": [],
"result2": []
},
@@ -452,6 +489,7 @@
"length": 0,
"max": 0,
"auto_use": 0,
+ "effect": 0,
"result1": [],
"result2": []
},
@@ -464,6 +502,7 @@
"length": 0,
"max": 0,
"auto_use": 0,
+ "effect": 0,
"result1": [],
"result2": []
},
@@ -476,6 +515,7 @@
"length": 0,
"max": 0,
"auto_use": 0,
+ "effect": 0,
"result1": [],
"result2": []
},
@@ -488,6 +528,7 @@
"length": 0,
"max": 0,
"auto_use": 0,
+ "effect": 0,
"result1": [],
"result2": []
},
@@ -500,6 +541,7 @@
"length": 0,
"max": 0,
"auto_use": 0,
+ "effect": 0,
"result1": [],
"result2": []
},
@@ -512,6 +554,7 @@
"length": 0,
"max": 0,
"auto_use": 0,
+ "effect": 0,
"result1": [],
"result2": []
},
@@ -524,6 +567,7 @@
"length": 0,
"max": 0,
"auto_use": 0,
+ "effect": 0,
"result1": [],
"result2": []
},
@@ -536,6 +580,7 @@
"length": 0,
"max": 0,
"auto_use": 0,
+ "effect": 0,
"result1": [],
"result2": []
},
@@ -548,6 +593,7 @@
"length": 0,
"max": 0,
"auto_use": 0,
+ "effect": 0,
"result1": [],
"result2": []
},
@@ -560,6 +606,7 @@
"length": 0,
"max": 0,
"auto_use": 0,
+ "effect": 0,
"result1": [],
"result2": []
},
@@ -572,6 +619,7 @@
"length": 0,
"max": 0,
"auto_use": 0,
+ "effect": 0,
"result1": [],
"result2": []
},
@@ -584,6 +632,7 @@
"length": 0,
"max": 0,
"auto_use": 0,
+ "effect": 0,
"result1": [],
"result2": []
},
@@ -596,6 +645,7 @@
"length": 0,
"max": 0,
"auto_use": 0,
+ "effect": 0,
"result1": [],
"result2": []
},
@@ -608,6 +658,7 @@
"length": 0,
"max": 0,
"auto_use": 0,
+ "effect": 0,
"result1": [],
"result2": []
},
@@ -620,6 +671,7 @@
"length": 0,
"max": 0,
"auto_use": 0,
+ "effect": 0,
"result1": [],
"result2": []
},
@@ -632,6 +684,7 @@
"length": 0,
"max": 0,
"auto_use": 0,
+ "effect": 0,
"result1": [],
"result2": []
},
@@ -644,6 +697,7 @@
"length": 0,
"max": 0,
"auto_use": 0,
+ "effect": 0,
"result1": [],
"result2": []
},
@@ -656,6 +710,7 @@
"length": 0,
"max": 0,
"auto_use": 0,
+ "effect": 0,
"result1": [],
"result2": []
},
@@ -668,6 +723,7 @@
"length": 0,
"max": 0,
"auto_use": 0,
+ "effect": 0,
"result1": [],
"result2": []
},
@@ -680,6 +736,7 @@
"length": 0,
"max": 0,
"auto_use": 0,
+ "effect": 0,
"result1": [],
"result2": []
},
@@ -692,6 +749,7 @@
"length": 0,
"max": 0,
"auto_use": 0,
+ "effect": 0,
"result1": [],
"result2": []
},
@@ -704,6 +762,7 @@
"length": 0,
"max": 0,
"auto_use": 0,
+ "effect": 0,
"result1": [],
"result2": []
},
@@ -716,6 +775,7 @@
"length": 0,
"max": 0,
"auto_use": 0,
+ "effect": 0,
"result1": [],
"result2": []
},
@@ -728,6 +788,7 @@
"length": 0,
"max": 0,
"auto_use": 0,
+ "effect": 0,
"result1": [],
"result2": []
},
@@ -740,6 +801,7 @@
"length": 0,
"max": 0,
"auto_use": 0,
+ "effect": 0,
"result1": [],
"result2": []
},
@@ -752,6 +814,7 @@
"length": 0,
"max": 0,
"auto_use": 0,
+ "effect": 0,
"result1": [],
"result2": []
},
@@ -764,6 +827,7 @@
"length": 0,
"max": 0,
"auto_use": 0,
+ "effect": 0,
"result1": [],
"result2": []
},
@@ -776,6 +840,7 @@
"length": 0,
"max": 0,
"auto_use": 0,
+ "effect": 0,
"result1": [],
"result2": []
},
@@ -788,6 +853,7 @@
"length": 0,
"max": 0,
"auto_use": 0,
+ "effect": 0,
"result1": [],
"result2": []
},
@@ -800,6 +866,7 @@
"length": 0,
"max": 0,
"auto_use": 0,
+ "effect": 0,
"result1": [],
"result2": []
},
@@ -812,6 +879,7 @@
"length": 0,
"max": 0,
"auto_use": 0,
+ "effect": 0,
"result1": [],
"result2": []
},
@@ -824,6 +892,7 @@
"length": 0,
"max": 0,
"auto_use": 0,
+ "effect": 0,
"result1": [],
"result2": []
},
@@ -836,6 +905,7 @@
"length": 0,
"max": 0,
"auto_use": 0,
+ "effect": 0,
"result1": [],
"result2": []
},
@@ -848,6 +918,7 @@
"length": 0,
"max": 0,
"auto_use": 0,
+ "effect": 0,
"result1": [],
"result2": []
},
@@ -860,6 +931,7 @@
"length": 0,
"max": 0,
"auto_use": 0,
+ "effect": 0,
"result1": [],
"result2": []
},
@@ -872,6 +944,7 @@
"length": 0,
"max": 0,
"auto_use": 0,
+ "effect": 0,
"result1": [],
"result2": []
},
@@ -884,6 +957,7 @@
"length": 0,
"max": 0,
"auto_use": 0,
+ "effect": 0,
"result1": [],
"result2": []
},
@@ -896,6 +970,7 @@
"length": 0,
"max": 0,
"auto_use": 0,
+ "effect": 0,
"result1": [],
"result2": []
},
@@ -908,6 +983,7 @@
"length": 0,
"max": 0,
"auto_use": 0,
+ "effect": 0,
"result1": [],
"result2": []
},
@@ -920,6 +996,7 @@
"length": 0,
"max": 0,
"auto_use": 0,
+ "effect": 0,
"result1": [],
"result2": []
},
@@ -932,6 +1009,7 @@
"length": 0,
"max": 0,
"auto_use": 0,
+ "effect": 0,
"result1": [],
"result2": []
},
@@ -944,6 +1022,7 @@
"length": 0,
"max": 0,
"auto_use": 0,
+ "effect": 0,
"result1": [],
"result2": []
},
@@ -956,6 +1035,7 @@
"length": 0,
"max": 0,
"auto_use": 0,
+ "effect": 0,
"result1": [],
"result2": []
},
@@ -968,6 +1048,7 @@
"length": 0,
"max": 0,
"auto_use": 0,
+ "effect": 0,
"result1": [],
"result2": []
},
@@ -980,6 +1061,7 @@
"length": 0,
"max": 0,
"auto_use": 0,
+ "effect": 0,
"result1": [],
"result2": []
},
@@ -992,6 +1074,7 @@
"length": 0,
"max": 0,
"auto_use": 0,
+ "effect": 0,
"result1": [],
"result2": []
},
@@ -1004,6 +1087,7 @@
"length": 0,
"max": 0,
"auto_use": 0,
+ "effect": 0,
"result1": [],
"result2": []
},
@@ -1016,6 +1100,7 @@
"length": 0,
"max": 0,
"auto_use": 0,
+ "effect": 0,
"result1": [],
"result2": []
},
@@ -1028,6 +1113,7 @@
"length": 0,
"max": 0,
"auto_use": 0,
+ "effect": 0,
"result1": [],
"result2": []
},
@@ -1040,6 +1126,7 @@
"length": 0,
"max": 0,
"auto_use": 0,
+ "effect": 0,
"result1": [],
"result2": []
},
@@ -1052,6 +1139,7 @@
"length": 0,
"max": 0,
"auto_use": 0,
+ "effect": 0,
"result1": [],
"result2": []
},
@@ -1064,6 +1152,7 @@
"length": 0,
"max": 0,
"auto_use": 0,
+ "effect": 0,
"result1": [],
"result2": []
},
@@ -1076,6 +1165,7 @@
"length": 0,
"max": 0,
"auto_use": 0,
+ "effect": 0,
"result1": [],
"result2": []
},
@@ -1088,6 +1178,7 @@
"length": 0,
"max": 0,
"auto_use": 0,
+ "effect": 0,
"result1": [],
"result2": []
},
@@ -1100,6 +1191,7 @@
"length": 0,
"max": 0,
"auto_use": 0,
+ "effect": 0,
"result1": [],
"result2": []
},
@@ -1112,6 +1204,7 @@
"length": 0,
"max": 0,
"auto_use": 0,
+ "effect": 0,
"result1": [],
"result2": []
}
diff --git a/Main/cfg/tbleader.json b/Main/cfg/tbleader.json
new file mode 100644
index 0000000..8b604fe
--- /dev/null
+++ b/Main/cfg/tbleader.json
@@ -0,0 +1,12 @@
+[
+ {
+ "id": 60001,
+ "strength": 40,
+ "size": 1
+ },
+ {
+ "id": 60002,
+ "strength": 40,
+ "size": 1
+ }
+]
\ No newline at end of file
diff --git a/Server.sln.DotSettings.user b/Server.sln.DotSettings.user
index b72c42f..7252f81 100644
--- a/Server.sln.DotSettings.user
+++ b/Server.sln.DotSettings.user
@@ -4,13 +4,20 @@
ForceIncluded
ForceIncluded
ForceIncluded
+ ForceIncluded
ForceIncluded
ForceIncluded
+ ForceIncluded
+ ForceIncluded
+ ForceIncluded
ForceIncluded
ForceIncluded
ForceIncluded
+ ForceIncluded
ForceIncluded
ForceIncluded
+ ForceIncluded
+ ForceIncluded
ForceIncluded
ForceIncluded
ForceIncluded
diff --git a/Tools/NetworkProtocol/Inner/InnerMessage.proto b/Tools/NetworkProtocol/Inner/InnerMessage.proto
index 73925c7..fdf9564 100644
--- a/Tools/NetworkProtocol/Inner/InnerMessage.proto
+++ b/Tools/NetworkProtocol/Inner/InnerMessage.proto
@@ -98,3 +98,14 @@ message Other2Chat_ChatMessage // IAddressMessage
ChatInfoTree ChatInfoTree = 1;
}
+////////////// ******** 邮件 *******/////////////
+/// 其他服务器发送邮件
+// Protocol Bson
+message Other2Mail_SendMailRequest // IAddressRequest,Mail2Other_SendMailResponse
+{
+ MailBox MailBox = 1;
+}
+message Mail2Other_SendMailResponse // IAddressResponse
+{
+
+}
\ No newline at end of file
diff --git a/Tools/NetworkProtocol/Outer/MailMessage.proto b/Tools/NetworkProtocol/Outer/MailMessage.proto
new file mode 100644
index 0000000..383ed6e
--- /dev/null
+++ b/Tools/NetworkProtocol/Outer/MailMessage.proto
@@ -0,0 +1,102 @@
+syntax = "proto3";
+package Fantasy.Network.Message;
+
+/// 测试Mail自定义Route协议
+message C2Mail_TestRequest // ICustomRouteRequest,Mail2C_TestResponse,GameRoute
+{
+ string Tag = 1;
+}
+message Mail2C_TestResponse // ICustomRouteResponse
+{
+ string Tag = 1;
+}
+/// 一个邮件的完整信息
+message MailInfo
+{
+ int64 MailId = 1;
+ int64 OwnerId = 2;
+ string Title = 3;
+ string Content = 4;
+ int64 CreateTime = 5;
+ int64 ExpireTime = 6;
+ int32 Money = 7;
+ int32 MailState = 8;
+ int32 MailType = 9;
+ repeated ItemInfo Items = 10;
+}
+/// 一个邮件的简单版消息
+message MailSimplifyInfo
+{
+ int64 MailId = 1;
+ int64 OwnerId = 2;
+ string Title = 3;
+ string Content = 4;
+ int64 CreateTime = 5;
+ int64 ExpireTime = 6;
+ int32 MailState = 7;
+ int32 MailType = 8;
+
+}
+/// Mail通知客户端有新的邮件
+message Mail2C_HaveMail // ICustomRouteMessage,GameRoute
+{
+ MailSimplifyInfo Mail = 1;
+}
+/// Mail通知客户端邮件状态变化
+message Mail2C_MailState // ICustomRouteMessage,GameRoute
+{
+ int32 MailState = 1;
+ int64 MailId = 2;
+}
+/// 客户端获取档期所有邮件的信息
+message C2Mail_GetHaveMailRequest // ICustomRouteRequest,Mail2C_GetHaveMailResposne,GameRoute
+{
+
+}
+message Mail2C_GetHaveMailResposne // ICustomRouteResponse
+{
+ repeated MailSimplifyInfo Mails = 1;
+}
+/// 客户端发开一个邮件
+message C2Mail_OpenMailRequest // ICustomRouteRequest,Mail2C_OpenMailResposne,GameRoute
+{
+ int64 MailId = 1;
+ bool ReturnMailInfo = 2;
+}
+message Mail2C_OpenMailResposne // ICustomRouteResponse
+{
+ MailInfo MailInfo = 1;
+}
+/// 客户端领取邮件的附件
+message C2Mail_ReceiveMailRequest // ICustomRouteRequest,Mail2C_ReceiveMailResponse,GameRoute
+{
+ int64 MailId = 1;
+ bool Money = 2;
+ repeated int64 ItemId = 3;
+}
+message Mail2C_ReceiveMailResponse // ICustomRouteResponse
+{
+
+}
+/// 客户端通知服务器删除一个邮件
+message C2Mail_RemoveMailRequest // ICustomRouteRequest,Mail2C_RemoveMailResponse,GameRoute
+{
+ int64 MailId = 1;
+}
+message Mail2C_RemoveMailResponse // ICustomRouteResponse
+{
+
+}
+/// 客户端玩家发送邮件到另外一个玩家
+message C2Mail_SendMailRequest // ICustomRouteRequest,Mail2C_SendMailResponse,GameRoute
+{
+ int64 UserId = 1;
+ string Title = 2;
+ string Content = 3;
+ int32 Money = 4;
+ repeated int64 ItemId = 5;
+}
+message Mail2C_SendMailResponse // ICustomRouteResponse
+{
+
+}
\ No newline at end of file
diff --git a/Tools/NetworkProtocol/Outer/SocialMessage.proto b/Tools/NetworkProtocol/Outer/SocialMessage.proto
index d86d08d..ffa9574 100644
--- a/Tools/NetworkProtocol/Outer/SocialMessage.proto
+++ b/Tools/NetworkProtocol/Outer/SocialMessage.proto
@@ -1,79 +1,6 @@
syntax = "proto3";
package Fantasy.Network.Message;
-////////////// ******** 私聊/邮件 *******/////////////
-
-/// 会话信息
-message ConversationInfo
-{
- RoleSimpleInfo RoleInfo = 1; //对方信息
- repeated MailInfo List = 2;//对话列表
-}
-
-message MailInfo
-{
- int64 Id = 1; //邮件id
- int64 Sender = 2; //发送者
- string Content = 3; //内容
- int64 CreateTime = 4; //发送时间
- int32 MailType = 5; //邮件类型
- int32 MailState = 6; //邮件状态
- repeated AwardInfo Items = 7; //附件列表
-}
-
-
-///请求会话列表
-message C2Game_GetConversationsRequest // ICustomRouteRequest,Game2C_GetConversationsResponse,GameRoute
-{
-
-}
-
-///请求会话列表响应
-message Game2C_GetConversationsResponse // ICustomRouteResponse
-{
- repeated ConversationInfo List = 1;
-}
-
-///发送邮件消息
-message C2Game_SendMailRequest // ICustomRouteRequest,Game2C_SendMailResponse,GameRoute
-{
- int64 Target = 1; //目标id
- string Content = 2; //内容
- repeated AwardInfo Items = 3; //附件列表
-}
-
-///发送邮件消息响应
-message Game2C_SendMailResponse // ICustomRouteResponse
-{
-
-}
-
-///发送删除会话消息
-message C2Game_DeleteMailRequest // ICustomRouteRequest,Game2C_DeleteMailResponse,GameRoute
-{
- int64 Id = 1; //会话id
-}
-
-///发送删除会话消息响应
-message Game2C_DeleteMailResponse // ICustomRouteResponse
-{
- int64 Id = 1; //会话id
-}
-
-
-///新邮件推送
-message Game2C_HaveMail // ICustomRouteMessage,GameRoute
-{
- MailInfo Mail = 1;
- string Key = 2;
-}
-
-message Game2C_MailState // ICustomRouteMessage,GameRoute
-{
- int32 MailState = 1;
- int64 MailId = 2;
-}
-
////////////// ******** 频道聊天 *******/////////////
/// 发送一个聊天消息给Chat服务器,中间是经过Gate中转的