1。添加 频道 中心组件 (增加 申请, 移除 等 功能)
This commit is contained in:
parent
fe97e4ee3f
commit
5d0f1791a5
@ -0,0 +1,8 @@
|
||||
|
||||
|
||||
using Fantasy.Entitas;
|
||||
|
||||
public class ChatChannel : Entity
|
||||
{
|
||||
public readonly HashSet<EntityReference<ChatUnit>> ChatUnits = new HashSet<EntityReference<ChatUnit>>();
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
|
||||
|
||||
using Fantasy.Entitas;
|
||||
|
||||
public class ChatChannelCenterComponent : Entity
|
||||
{
|
||||
public Dictionary<long,ChatChannel> ChatChannels = new Dictionary<long, ChatChannel>();
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
using Fantasy.Entitas;
|
||||
using Fantasy.Entitas.Interface;
|
||||
|
||||
namespace Hotfix;
|
||||
|
||||
|
||||
public class ChatChannelCenterComponentDestroySystem : DestroySystem<ChatChannelCenterComponent>
|
||||
{
|
||||
protected override void Destroy(ChatChannelCenterComponent self)
|
||||
{
|
||||
foreach (var channel in self.ChatChannels.Values.ToArray())
|
||||
{
|
||||
channel.Dispose();
|
||||
}
|
||||
self.ChatChannels.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
public static class ChatChannelCenterComponentSystem
|
||||
{
|
||||
public static ChatChannel Apply(this ChatChannelCenterComponent self, long chatChannelId)
|
||||
{
|
||||
if (self.ChatChannels.TryGetValue(chatChannelId, out var channel))
|
||||
{
|
||||
return channel;
|
||||
}
|
||||
|
||||
channel = Entity.Create<ChatChannel>(self.Scene,chatChannelId,true,true);
|
||||
return channel;
|
||||
}
|
||||
|
||||
public static bool TryGetChannel(this ChatChannelCenterComponent self, long chatChannelId, out ChatChannel channel)
|
||||
{
|
||||
return self.ChatChannels.TryGetValue(chatChannelId, out channel);
|
||||
}
|
||||
|
||||
public static bool RemoveChannel(this ChatChannelCenterComponent self, long chatChannelId)
|
||||
{
|
||||
if (!self.ChatChannels.Remove(chatChannelId, out var channel))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
channel.Dispose();
|
||||
return true;
|
||||
}
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
namespace Hotfix;
|
||||
|
||||
|
||||
|
||||
|
||||
public class ChatChannelSystem
|
||||
{
|
||||
|
||||
}
|
@ -6,7 +6,7 @@ public class ChatComponentDestroySystem : DestroySystem<ChatComponent>
|
||||
{
|
||||
protected override void Destroy(ChatComponent self)
|
||||
{
|
||||
foreach (var chatUnit in self.ChatUnits.Values)
|
||||
foreach (var chatUnit in self.ChatUnits.Values.ToArray())
|
||||
{
|
||||
chatUnit.Dispose();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user