添加chat组件 管理 当前chat服务器中运行的 chatUnit

This commit is contained in:
SnowShow 2025-04-16 11:11:08 +08:00
parent 93d69c1ff6
commit fe97e4ee3f
20 changed files with 106 additions and 46 deletions

View File

@ -219,8 +219,8 @@ MonoBehaviour:
y: 0
width: 288
height: 554
m_MinSize: {x: 200, y: 200}
m_MaxSize: {x: 4000, y: 4000}
m_MinSize: {x: 202, y: 226}
m_MaxSize: {x: 4002, y: 4026}
m_ActualView: {fileID: 17}
m_Panes:
- {fileID: 17}
@ -298,8 +298,8 @@ MonoBehaviour:
y: 0
width: 131
height: 379
m_MinSize: {x: 100, y: 100}
m_MaxSize: {x: 4000, y: 4000}
m_MinSize: {x: 101, y: 126}
m_MaxSize: {x: 4001, y: 4026}
m_ActualView: {fileID: 18}
m_Panes:
- {fileID: 18}
@ -405,7 +405,7 @@ MonoBehaviour:
m_Pos:
serializedVersion: 2
x: 0
y: 79
y: 24
width: 432
height: 528
m_SerializedDataModeController:
@ -422,7 +422,7 @@ MonoBehaviour:
m_SceneHierarchy:
m_TreeViewState:
scrollPos: {x: 0, y: 0}
m_SelectedIDs: 20280100
m_SelectedIDs:
m_LastClickedID: 0
m_ExpandedIDs: e6f5ffff6ef9ffff
m_RenameOverlay:
@ -470,8 +470,8 @@ MonoBehaviour:
m_TextWithWhitespace: "Scene\u200B"
m_Pos:
serializedVersion: 2
x: 433
y: 79
x: 434
y: 24
width: 286
height: 528
m_SerializedDataModeController:
@ -1028,7 +1028,7 @@ MonoBehaviour:
m_AudioPlay: 0
m_DebugDrawModesUseInteractiveLightBakingData: 0
m_Position:
m_Target: {x: 0, y: 0, z: 0}
m_Target: {x: 0.41235045, y: 0.22231065, z: -0.004500015}
speed: 2
m_Value: {x: 0, y: 0, z: 0}
m_RenderMode: 0
@ -1080,7 +1080,7 @@ MonoBehaviour:
speed: 2
m_Value: {x: 0, y: 0, z: 0, w: 1}
m_Size:
m_Target: 10
m_Target: 10.45
speed: 2
m_Value: 10
m_Ortho:
@ -1100,7 +1100,7 @@ MonoBehaviour:
m_FarClip: 10000
m_DynamicClip: 1
m_OcclusionCulling: 0
m_LastSceneViewRotation: {x: 0.04206977, y: -0.95709133, z: 0.20865029, w: 0.19665778}
m_LastSceneViewRotation: {x: -0.08717229, y: 0.89959055, z: -0.21045254, w: -0.3726226}
m_LastSceneViewOrtho: 0
m_Viewpoint:
m_SceneView: {fileID: 17}
@ -1135,7 +1135,7 @@ MonoBehaviour:
m_Pos:
serializedVersion: 2
x: 0
y: 633
y: 24
width: 130
height: 353
m_SerializedDataModeController:
@ -1170,8 +1170,8 @@ MonoBehaviour:
m_TextWithWhitespace: "Project\u200B"
m_Pos:
serializedVersion: 2
x: 131
y: 633
x: 132
y: 24
width: 789
height: 353
m_SerializedDataModeController:
@ -1215,7 +1215,7 @@ MonoBehaviour:
scrollPos: {x: 0, y: 0}
m_SelectedIDs: ba240100
m_LastClickedID: 74938
m_ExpandedIDs: 000000008a170100bc230100be230100c0230100c2230100c4230100c8230100ca230100cc230100ce230100d0230100d2230100d4230100d6230100d8230100da230100dc230100de230100e0230100e2230100e4230100e6230100e8230100ea230100ec230100ee230100f0230100f2230100f4230100f6230100f8230100fa230100fc230100fe23010000240100022401000424010006240100082401000a2401000c2401000e24010010240100122401001424010016240100182401001a2401001e240100202401002224010024240100262401002824010000ca9a3bffffff7f
m_ExpandedIDs: 00000000382201003a2201003c2201003e22010040220100422201004422010046220100482201004a2201004c2201004e22010050220100522201005422010056220100582201005a2201005c2201005e22010060220100622201006422010066220100682201006a2201006c2201006e22010070220100722201007422010076220100782201007a2201007c2201007e22010080220100822201008422010086220100882201008a2201008c2201008e22010090220100922201009422010096220100982201009a2201009c2201009e220100a0220100a2220100
m_RenameOverlay:
m_UserAcceptedRename: 0
m_Name:
@ -1244,7 +1244,7 @@ MonoBehaviour:
scrollPos: {x: 0, y: 0}
m_SelectedIDs:
m_LastClickedID: 0
m_ExpandedIDs: 000000008a170100bc230100be230100c0230100c2230100c4230100c6230100c8230100ca230100cc230100ce230100d0230100d2230100d4230100d6230100d8230100da230100dc230100de230100e0230100e2230100e4230100e6230100e8230100ea230100ec230100ee230100f0230100f2230100f4230100f6230100f8230100fa230100fc230100fe23010000240100022401000424010006240100082401000a2401000c2401000e24010010240100122401001424010016240100182401001a2401001c2401001e2401002024010022240100242401002624010028240100
m_ExpandedIDs: 00000000382201003a2201003c2201003e22010040220100422201004422010046220100482201004a2201004c2201004e22010050220100522201005422010056220100582201005a2201005c2201005e22010060220100622201006422010066220100682201006a2201006c2201006e22010070220100722201007422010076220100782201007a2201007c2201007e22010080220100822201008422010086220100882201008a2201008c2201008e22010090220100922201009422010096220100982201009a2201009c2201009e220100a0220100a2220100
m_RenameOverlay:
m_UserAcceptedRename: 0
m_Name:
@ -1323,8 +1323,8 @@ MonoBehaviour:
m_TextWithWhitespace: "Project\u200B"
m_Pos:
serializedVersion: 2
x: 922
y: 633
x: 923
y: 24
width: 481
height: 353
m_SerializedDataModeController:
@ -1368,7 +1368,7 @@ MonoBehaviour:
scrollPos: {x: 0, y: 0}
m_SelectedIDs: 7c250100
m_LastClickedID: 75132
m_ExpandedIDs: 000000008a170100bc230100be230100c0230100c2230100c4230100c6230100c8230100ca230100cc230100ce230100d0230100d2230100d4230100d6230100d8230100da230100dc230100de230100e0230100e2230100e4230100e6230100e8230100ea230100ec230100ee230100f0230100f2230100f4230100f6230100f8230100fa230100fc230100fe23010000240100022401000424010006240100082401000a2401000c2401000e24010010240100122401001424010016240100182401001a2401001c2401001e24010020240100222401002424010026240100282401009224010000ca9a3bffffff7f
m_ExpandedIDs: 00000000382201003a2201003c2201003e22010040220100422201004422010046220100482201004a2201004c2201004e22010050220100522201005422010056220100582201005a2201005c2201005e22010060220100622201006422010066220100682201006a2201006c2201006e22010070220100722201007422010076220100782201007a2201007c2201007e22010080220100822201008422010086220100882201008a2201008c2201008e22010090220100922201009422010096220100982201009a2201009c2201009e220100a0220100a2220100
m_RenameOverlay:
m_UserAcceptedRename: 0
m_Name:
@ -1397,7 +1397,7 @@ MonoBehaviour:
scrollPos: {x: 0, y: 0}
m_SelectedIDs:
m_LastClickedID: 0
m_ExpandedIDs: 000000008a170100bc230100be230100c0230100c2230100c4230100c6230100c8230100ca230100cc230100ce230100d0230100d2230100d4230100d6230100d8230100da230100dc230100de230100e0230100e2230100e4230100e6230100e8230100ea230100ec230100ee230100f0230100f2230100f4230100f6230100f8230100fa230100fc230100fe23010000240100022401000424010006240100082401000a2401000c2401000e24010010240100122401001424010016240100182401001a2401001c2401001e2401002024010022240100242401002624010028240100
m_ExpandedIDs: 00000000382201003a2201003c2201003e22010040220100422201004422010046220100482201004a2201004c2201004e22010050220100522201005422010056220100582201005a2201005c2201005e22010060220100622201006422010066220100682201006a2201006c2201006e22010070220100722201007422010076220100782201007a2201007c2201007e22010080220100822201008422010086220100882201008a2201008c2201008e22010090220100922201009422010096220100982201009a2201009c2201009e220100a0220100a2220100
m_RenameOverlay:
m_UserAcceptedRename: 0
m_Name:
@ -1476,8 +1476,8 @@ MonoBehaviour:
m_TextWithWhitespace: "Inspector\u200B"
m_Pos:
serializedVersion: 2
x: 1405
y: 79
x: 1406
y: 24
width: 514
height: 907
m_SerializedDataModeController:
@ -1525,8 +1525,8 @@ MonoBehaviour:
m_TextWithWhitespace: "Game\u200B"
m_Pos:
serializedVersion: 2
x: 721
y: 79
x: 722
y: 24
width: 682
height: 528
m_SerializedDataModeController:

View File

@ -13,7 +13,7 @@ using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("APlugins")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+c3ad3113cf20a8ab062c6e6255582c0100b715d4")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+93d69c1ff6fc3ec58a9401445592c13d80a5e8fc")]
[assembly: System.Reflection.AssemblyProductAttribute("APlugins")]
[assembly: System.Reflection.AssemblyTitleAttribute("APlugins")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]

View File

@ -1 +1 @@
43e0e398ae5e32ca33bc9471ee513ad5e696e66cc472ec5ec0a9f87ef8721ace
e921ce1fc41926ac48960caf7a6b4f93b4fa3ac39e90c5379537c824ab3c0aef

View File

@ -1 +1 @@
17445925597721448
17446243488696810

View File

@ -0,0 +1,8 @@

using Fantasy.Entitas;
public class ChatComponent : Entity
{
public readonly Dictionary<long,ChatUnit> ChatUnits = new Dictionary<long, ChatUnit>();
}

View File

@ -1,8 +0,0 @@

using Fantasy.Entitas;
public class ChatManagementComponent : Entity
{
}

View File

@ -13,7 +13,7 @@ using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("Entity")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+c3ad3113cf20a8ab062c6e6255582c0100b715d4")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+93d69c1ff6fc3ec58a9401445592c13d80a5e8fc")]
[assembly: System.Reflection.AssemblyProductAttribute("Entity")]
[assembly: System.Reflection.AssemblyTitleAttribute("Entity")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]

View File

@ -1 +1 @@
13f3104b25ee7b72457ad6eda84a41b94fdf1d507da74741102c9e9ab8783363
9be4d22e32a3ffa9d6c641e983868b53bbfa8e5b7da48cd1ff9ebc76bff7099d

View File

@ -1 +1 @@
17445925597890487
17446243488702004

View File

@ -22,7 +22,7 @@ public class OnCreateScene_InitEvent : AsyncEventSystem<OnCreateScene>
break;
case SceneType.Chat:
scene.AddComponent<ChatManagementComponent>();
scene.AddComponent<ChatComponent>();
break;
}

View File

@ -0,0 +1,39 @@
using Fantasy;
using Fantasy.Entitas.Interface;
namespace Hotfix;
public class ChatComponentDestroySystem : DestroySystem<ChatComponent>
{
protected override void Destroy(ChatComponent self)
{
foreach (var chatUnit in self.ChatUnits.Values)
{
chatUnit.Dispose();
}
self.ChatUnits.Clear();
}
}
public static class ChatComponentSystem
{
public static void AddChatUnit(this ChatComponent self,ChatUnit chatUnit)
{
if (self.ChatUnits.ContainsKey(chatUnit.RuntimeId))
{
Log.Debug($" chat unit already added: {chatUnit.AccountId} {chatUnit.GameName} ");
return;
}
self.ChatUnits.Add(chatUnit.RuntimeId, chatUnit);
}
public static void RemoveChatUnit(this ChatComponent self, long accountId)
{
if (!self.ChatUnits.Remove(accountId,out var chatUnit))
{
Log.Debug($" chat unit is not exist: {accountId} ");
return;
}
chatUnit.Dispose();
}
}

View File

@ -16,8 +16,11 @@ public class G2Chat_LoginRequestHandler : RouteRPC<Scene,G2Chat_LoginRequest,Cha
response.ErrorCode = GameErrorCode.Success;
response.ChatRouteId = chatUnit.RuntimeId;
Log.Info($"登录聊天服务器成功 {request.GameName} AccountId {request.AccountId } GateRoutedId { request.GateRoutedId}");
Log.Info($"登录聊天服务器成功 {request.GameName} AccountId {request.AccountId } GateRoutedId { request.GateRoutedId}");
ChatComponentHelper.AddChatUnit(scene,chatUnit);
await FTask.CompletedTask;
}
}

View File

@ -12,6 +12,7 @@ public class G2Chat_OfflineRequestHandler : RouteRPC<ChatUnit,G2Chat_OfflineRequ
chatUnit.Dispose();
response.ErrorCode = GameErrorCode.Success;
ChatComponentHelper.RemoveChatUnit(chatUnit.Scene,chatUnit.RuntimeId);
await FTask.CompletedTask;
}
}

View File

@ -0,0 +1,17 @@
using Fantasy;
namespace Hotfix;
public class ChatComponentHelper
{
public static void AddChatUnit(Scene scene,ChatUnit chatUnit)
{
scene.GetComponent<ChatComponent>().AddChatUnit(chatUnit);
}
public static void RemoveChatUnit(Scene scene,long accountId)
{
scene.GetComponent<ChatComponent>().RemoveChatUnit(accountId);
}
}

View File

@ -13,7 +13,7 @@ using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("Hotfix")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+c3ad3113cf20a8ab062c6e6255582c0100b715d4")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+93d69c1ff6fc3ec58a9401445592c13d80a5e8fc")]
[assembly: System.Reflection.AssemblyProductAttribute("Hotfix")]
[assembly: System.Reflection.AssemblyTitleAttribute("Hotfix")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]

View File

@ -1 +1 @@
2e090cacf21634ed778c4b58a890448889cdadc59f62e57779400d185d6066b3
2b7041311f6a19a8b5d2fe00eaac9f6a3f66d84a1851b263ef47c61f4c5c28b9

View File

@ -1 +1 @@
17445925598071222
17446243488709721

View File

@ -13,7 +13,7 @@ using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("Main")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+c3ad3113cf20a8ab062c6e6255582c0100b715d4")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+93d69c1ff6fc3ec58a9401445592c13d80a5e8fc")]
[assembly: System.Reflection.AssemblyProductAttribute("Main")]
[assembly: System.Reflection.AssemblyTitleAttribute("Main")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]

View File

@ -1 +1 @@
394efb132679b18da73e9a918dca67fa1b1184f157208760d57a95961da52a2e
bdec6df185994b1af86f341a674c5f39711943f372014406b428ef851b556cbf

View File

@ -1 +1 @@
17445925598181296
17446243488709721