聊天频道相关

This commit is contained in:
bob
2025-08-08 18:21:11 +08:00
parent 61496d4616
commit 7a93c0f8f1
23 changed files with 256 additions and 95 deletions

View File

@@ -1,23 +1,27 @@
using Fantasy.Entitas;
using Fantasy.Helper;
namespace NB.Chat;
public static class ChatChannelCenterComponentSystem
{
/// <summary>
/// 申请
/// 申请创建一个频道
/// </summary>
/// <param name="self"></param>
/// <param name="unit"></param>
/// <param name="channelId"></param>
/// <returns></returns>
public static ChatChannelComponent Apply(this ChatChannelCenterComponent self, long channelId)
public static ChatChannel Apply(this ChatChannelCenterComponent self, ChatUnit unit, long channelId)
{
if (self.Channels.TryGetValue(channelId, out var channel))
{
return channel;
}
channel = Entity.Create<ChatChannelComponent>(self.Scene, channelId, true, true);
channel = Entity.Create<ChatChannel>(self.Scene, channelId, true, true);
channel.Creator = unit.RoleId;
channel.CreateTime = TimeHelper.Now;
self.Channels.Add(channelId, channel);
return channel;
}
@@ -29,7 +33,7 @@ public static class ChatChannelCenterComponentSystem
/// <param name="channelId"></param>
/// <param name="channel"></param>
/// <returns></returns>
public static bool TryGet(this ChatChannelCenterComponent self, long channelId, out ChatChannelComponent? channel)
public static bool TryGet(this ChatChannelCenterComponent self, long channelId, out ChatChannel? channel)
{
return self.Channels.TryGetValue(channelId, out channel);
}