58 lines
1.3 KiB
C#
58 lines
1.3 KiB
C#
using Fantasy;
|
|
|
|
namespace Hotfix;
|
|
|
|
|
|
|
|
|
|
public static class ChatChannelSystem
|
|
{
|
|
|
|
public static void SendMessage(this ChatChannel self, string message)
|
|
{
|
|
var chatUnitManage = self.Scene.GetComponent<ChatManageComponent>();
|
|
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// 进入聊天频道
|
|
/// </summary>
|
|
/// <param name="self"></param>
|
|
/// <param name="chatUnitId"></param>
|
|
/// <returns></returns>
|
|
public static bool JoinChatChannel(this ChatChannel self, long chatUnitId)
|
|
{
|
|
var chatUnitManage = self.Scene.GetComponent<ChatManageComponent>();
|
|
|
|
if (!chatUnitManage.ChatUnits.TryGetValue(chatUnitId,out _))
|
|
{
|
|
return false;
|
|
}
|
|
|
|
self.ChatUnits.Add(chatUnitId);
|
|
return true;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 退出聊天频道
|
|
/// </summary>
|
|
/// <param name="self"></param>
|
|
/// <param name="chatUnitId"></param>
|
|
public static void ExitChatChannel(this ChatChannel self, long chatUnitId)
|
|
{
|
|
var chatUnitManage = self.Scene.GetComponent<ChatManageComponent>();
|
|
|
|
if (!self.ChatUnits.Contains(chatUnitId))
|
|
{
|
|
return;
|
|
}
|
|
self.ChatUnits.Remove(chatUnitId);
|
|
|
|
if (self.ChatUnits.Count == 0)
|
|
{
|
|
self.Dispose();
|
|
}
|
|
}
|
|
|
|
} |