diff --git a/GameServer/Server/Entity/Model/Chat/ChatChannel/ChatChannel.cs b/GameServer/Server/Entity/Model/Chat/ChatChannel/ChatChannel.cs new file mode 100644 index 00000000..654b26b8 --- /dev/null +++ b/GameServer/Server/Entity/Model/Chat/ChatChannel/ChatChannel.cs @@ -0,0 +1,8 @@ + + +using Fantasy.Entitas; + +public class ChatChannel : Entity +{ + public readonly HashSet> ChatUnits = new HashSet>(); +} \ No newline at end of file diff --git a/GameServer/Server/Entity/Model/Chat/ChatChannel/ChatChannelCenterComponent.cs b/GameServer/Server/Entity/Model/Chat/ChatChannel/ChatChannelCenterComponent.cs new file mode 100644 index 00000000..822ec506 --- /dev/null +++ b/GameServer/Server/Entity/Model/Chat/ChatChannel/ChatChannelCenterComponent.cs @@ -0,0 +1,8 @@ + + +using Fantasy.Entitas; + +public class ChatChannelCenterComponent : Entity +{ + public Dictionary ChatChannels = new Dictionary(); +} \ No newline at end of file diff --git a/GameServer/Server/Hotfix/Outter/Chat/ChatChannel/ChatChannelCenterComponentSystem.cs b/GameServer/Server/Hotfix/Outter/Chat/ChatChannel/ChatChannelCenterComponentSystem.cs new file mode 100644 index 00000000..bea13cad --- /dev/null +++ b/GameServer/Server/Hotfix/Outter/Chat/ChatChannel/ChatChannelCenterComponentSystem.cs @@ -0,0 +1,46 @@ +using Fantasy.Entitas; +using Fantasy.Entitas.Interface; + +namespace Hotfix; + + +public class ChatChannelCenterComponentDestroySystem : DestroySystem +{ + protected override void Destroy(ChatChannelCenterComponent self) + { + foreach (var channel in self.ChatChannels.Values.ToArray()) + { + channel.Dispose(); + } + self.ChatChannels.Clear(); + } +} + +public static class ChatChannelCenterComponentSystem +{ + public static ChatChannel Apply(this ChatChannelCenterComponent self, long chatChannelId) + { + if (self.ChatChannels.TryGetValue(chatChannelId, out var channel)) + { + return channel; + } + + channel = Entity.Create(self.Scene,chatChannelId,true,true); + return channel; + } + + public static bool TryGetChannel(this ChatChannelCenterComponent self, long chatChannelId, out ChatChannel channel) + { + return self.ChatChannels.TryGetValue(chatChannelId, out channel); + } + + public static bool RemoveChannel(this ChatChannelCenterComponent self, long chatChannelId) + { + if (!self.ChatChannels.Remove(chatChannelId, out var channel)) + { + return false; + } + channel.Dispose(); + return true; + } +} \ No newline at end of file diff --git a/GameServer/Server/Hotfix/Outter/Chat/ChatChannel/ChatChannelSystem.cs b/GameServer/Server/Hotfix/Outter/Chat/ChatChannel/ChatChannelSystem.cs new file mode 100644 index 00000000..9d719732 --- /dev/null +++ b/GameServer/Server/Hotfix/Outter/Chat/ChatChannel/ChatChannelSystem.cs @@ -0,0 +1,9 @@ +namespace Hotfix; + + + + +public class ChatChannelSystem +{ + +} \ No newline at end of file diff --git a/GameServer/Server/Hotfix/Outter/Chat/ChatComponentSystem.cs b/GameServer/Server/Hotfix/Outter/Chat/ChatComponentSystem.cs index 247df490..2051b1ea 100644 --- a/GameServer/Server/Hotfix/Outter/Chat/ChatComponentSystem.cs +++ b/GameServer/Server/Hotfix/Outter/Chat/ChatComponentSystem.cs @@ -6,7 +6,7 @@ public class ChatComponentDestroySystem : DestroySystem { protected override void Destroy(ChatComponent self) { - foreach (var chatUnit in self.ChatUnits.Values) + foreach (var chatUnit in self.ChatUnits.Values.ToArray()) { chatUnit.Dispose(); }