聊天频道相关
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -13,21 +13,29 @@ public static class ChatUnitManageComponentSystem
|
||||
/// </summary>
|
||||
/// <param name="self"></param>
|
||||
/// <param name="scene"></param>
|
||||
/// <param name="accountId"></param>
|
||||
/// <param name="roleSimpleInfo"></param>
|
||||
/// <param name="gateRouteId"></param>
|
||||
public static async FTask<ChatUnit> Online(this ChatUnitManageComponent self, Scene scene, long accountId,
|
||||
public static async FTask<ChatUnit?> Online(this ChatUnitManageComponent self, Scene scene, RoleSimpleInfo roleSimpleInfo,
|
||||
long gateRouteId)
|
||||
{
|
||||
var accountId = roleSimpleInfo.RoleId;
|
||||
if (!self.TryGet(accountId, out var account))
|
||||
{
|
||||
account = ChatUnitFactory.Create(scene, accountId);
|
||||
self.Add(account);
|
||||
}
|
||||
|
||||
account.GateRouteId = gateRouteId;
|
||||
|
||||
if (account != null)
|
||||
{
|
||||
account.GateRouteId = gateRouteId;
|
||||
account.RoleId = accountId;
|
||||
account.Head = roleSimpleInfo.Head;
|
||||
account.Level = roleSimpleInfo.Level;
|
||||
account.NickName = roleSimpleInfo.NickName;
|
||||
account.Country = roleSimpleInfo.Country;
|
||||
}
|
||||
|
||||
await FTask.CompletedTask;
|
||||
|
||||
return account;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user