using Fantasy.Entitas;
namespace NB.Chat;
public static class ChatChannelCenterComponentSystem
{
///
/// 申请
///
///
///
///
public static ChatChannelComponent Apply(this ChatChannelCenterComponent self, long channelId)
{
if (self.Channels.TryGetValue(channelId, out var channel))
{
return channel;
}
channel = Entity.Create(self.Scene, channelId, true, true);
self.Channels.Add(channelId, channel);
return channel;
}
///
/// 获取
///
///
///
///
///
public static bool TryGet(this ChatChannelCenterComponent self, long channelId, out ChatChannelComponent? channel)
{
return self.Channels.TryGetValue(channelId, out channel);
}
///
/// 解散
///
///
///
public static void Disband(this ChatChannelCenterComponent self, long channelId)
{
if (self.Channels.Remove(channelId, out var channel))
{
return;
}
channel?.Dispose();
}
}