协议定义
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using Fantasy.Entitas;
|
||||
using Fantasy.Async;
|
||||
using Fantasy.Entitas;
|
||||
using Fantasy.Entitas.Interface;
|
||||
using Fantasy.Helper;
|
||||
|
||||
@@ -22,15 +23,22 @@ public class ChatChannelCenterComponentDestroySystem : DestroySystem<ChatChannel
|
||||
public static class ChatChannelCenterComponentSystem
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取
|
||||
/// 获取一个频道
|
||||
/// </summary>
|
||||
/// <param name="self"></param>
|
||||
/// <param name="channelId"></param>
|
||||
/// <param name="channel"></param>
|
||||
/// <returns></returns>
|
||||
public static bool TryGet(this ChatChannelCenterComponent self, long channelId, out ChatChannel? channel)
|
||||
public static async FTask<ChatChannel?> Get(this ChatChannelCenterComponent self, long channelId)
|
||||
{
|
||||
return self.Channels.TryGetValue(channelId, out channel);
|
||||
if (self.Channels.TryGetValue(channelId, out var channel))
|
||||
{
|
||||
return channel;
|
||||
}
|
||||
|
||||
//查数据库
|
||||
channel = await self.Scene.World.DataBase.Query<ChatChannel>(channelId, true);
|
||||
self.Channels.Add(channel.Id, channel);
|
||||
return channel;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -38,22 +46,20 @@ public static class ChatChannelCenterComponentSystem
|
||||
/// </summary>
|
||||
/// <param name="self"></param>
|
||||
/// <param name="unit"></param>
|
||||
/// <param name="channelId"></param>
|
||||
/// <returns></returns>
|
||||
public static ChatChannel Apply(this ChatChannelCenterComponent self, ChatUnit unit, long channelId)
|
||||
public static async FTask<ChatChannel> Create(this ChatChannelCenterComponent self, ChatUnit unit)
|
||||
{
|
||||
if (self.Channels.TryGetValue(channelId, out var channel))
|
||||
{
|
||||
return channel;
|
||||
}
|
||||
|
||||
channel = Entity.Create<ChatChannel>(self.Scene, channelId, true, true);
|
||||
var channel = Entity.Create<ChatChannel>(self.Scene, true, true);
|
||||
channel.Creator = unit.Role.RoleId;
|
||||
channel.CreateTime = TimeHelper.Now;
|
||||
self.Channels.Add(channelId, channel);
|
||||
self.Channels.Add(channel.Id, channel);
|
||||
//保存到数据库
|
||||
await self.Scene.World.DataBase.Save(channel);
|
||||
|
||||
return channel;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 解散
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user