提交示例代码
This commit is contained in:
21
聊天系统课程代码/Server/Hotfix/Chat/System/ChatUnitSystem.cs
Normal file
21
聊天系统课程代码/Server/Hotfix/Chat/System/ChatUnitSystem.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using Fantasy.Entitas.Interface;
|
||||
#pragma warning disable CS8625 // Cannot convert null literal to non-nullable reference type.
|
||||
|
||||
namespace Fantasy;
|
||||
|
||||
public sealed class ChatUnitDestroySystem : DestroySystem<ChatUnit>
|
||||
{
|
||||
protected override void Destroy(ChatUnit self)
|
||||
{
|
||||
self.UserName = null;
|
||||
self.GateRouteId = 0;
|
||||
// 退出当前ChatUnit拥有的所有频道
|
||||
foreach (var (_,chatChannelComponent) in self.Channels)
|
||||
{
|
||||
chatChannelComponent.ExitChannel(self.Id, false);
|
||||
}
|
||||
// 理论情况下,这个self.Channels不会存在因为数据的,因为上面已经给清空掉了。
|
||||
// 但是self.Channels.Clear();还是加上吧,防止以后忘记了。
|
||||
self.Channels.Clear();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user