using Fantasy.Entitas; using Fantasy.Entitas.Interface; namespace Hotfix; public class ChatChannelCenterComponentDestroySystem : DestroySystem { 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(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; } }