From 94af0e5ddbf30b63f206dca2040c806bb14a717d Mon Sep 17 00:00:00 2001 From: "Bob.Song" <605277374@qq.com> Date: Wed, 27 Aug 2025 18:05:55 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E8=BF=9B=E5=85=A5=E5=9C=B0?= =?UTF-8?q?=E5=9B=BE=E5=92=8C=E5=88=9B=E5=BB=BA=E6=88=BF=E9=97=B4=E7=9B=B8?= =?UTF-8?q?=E5=85=B3=E9=80=BB=E8=BE=91=E5=92=8C=E5=8D=8F=E8=AE=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Config/Binary/SceneConfigData.bytes | 3 +- Config/Excel/Server/SceneConfig.xlsx | Bin 16874 -> 16971 bytes Config/Excel/Version.txt | 2 +- Config/Json/Server/SceneConfigData.Json | 3 +- .../NetworkProtocol/Inner/InnerMessage.proto | 21 +++++ Config/NetworkProtocol/Outer/MapMessage.proto | 13 ++- .../NetworkProtocol/Outer/OuterMessage.proto | 8 ++ Entity/Gate/GateUnit.cs | 2 +- .../Generate/NetworkProtocol/InnerMessage.cs | 71 +++++++++++++++ .../Generate/NetworkProtocol/InnerOpcode.cs | 3 + Entity/Generate/NetworkProtocol/MapMessage.cs | 50 ++++++++++- .../Generate/NetworkProtocol/OuterMessage.cs | 24 +++++ .../Generate/NetworkProtocol/OuterOpcode.cs | 11 ++- Entity/Map/Entity/Map.cs | 9 ++ Entity/Map/Entity/MapUnit.cs | 5 -- Entity/Model/Def/ErrorCode.cs | 15 ++++ .../Outer/C2G_EnterRoomRequestHandler.cs | 49 ++++++++++- .../Outer/C2G_ExitRoomRequestHandler.cs | 82 ++++++++++++++++++ Hotfix/Gate/Helper/GateLoginHelper.cs | 4 - Hotfix/Gate/System/GateUnitSystem.cs | 36 ++++---- .../Handler/C2Map_CreateRoomRequestHandler.cs | 3 + .../Handler/C2Map_EnterMapRequestHandler.cs | 14 +-- .../Inner/G2Map_EnterRequestHandler.cs | 39 ++++++++- Hotfix/Map/Helper/MapFactory.cs | 20 +++++ Hotfix/Map/System/MapManageComponentSystem.cs | 61 +++++++++++++ Hotfix/Map/System/MapRoomSystem.cs | 9 +- Hotfix/Map/System/MapSystem.cs | 16 ++++ Hotfix/Map/System/MapUnitSystem.cs | 38 ++++++++ .../Map/System/RoomManageComponentSystem.cs | 17 ++-- Main/Properties/launchSettings.json | 1 + Server.sln.DotSettings.user | 1 + 31 files changed, 562 insertions(+), 68 deletions(-) create mode 100644 Hotfix/Gate/Handler/Outer/C2G_ExitRoomRequestHandler.cs create mode 100644 Hotfix/Map/Helper/MapFactory.cs create mode 100644 Hotfix/Map/System/MapManageComponentSystem.cs create mode 100644 Hotfix/Map/System/MapSystem.cs create mode 100644 Hotfix/Map/System/MapUnitSystem.cs diff --git a/Config/Binary/SceneConfigData.bytes b/Config/Binary/SceneConfigData.bytes index aecb47b..f3973aa 100644 --- a/Config/Binary/SceneConfigData.bytes +++ b/Config/Binary/SceneConfigData.bytes @@ -4,4 +4,5 @@ (" MultiThread*Gate2KCP8@VH " MultiThread*Game@VH " MultiThread*Chat@VH -" MultiThread*Map@VH \ No newline at end of file +" MultiThread*Map@VH +" MultiThread*Map@VH \ No newline at end of file diff --git a/Config/Excel/Server/SceneConfig.xlsx b/Config/Excel/Server/SceneConfig.xlsx index 56dbff95928d5aa22b29d3e2cb83ad7bdd04f0c2..c1a40f69e11b7ea5dd193e79d0339bb6148cfd83 100644 GIT binary patch delta 7132 zcmZ8mWmMGNx1OQ989IiPPU#p@KthC}1?g@95%DM8IW!W|F?4q$2olmrgOnnjB3%5x zcins6dp_)Q*4fW~_W5wu+O;199tj3l=Yz42C^N6rz#xz*0tu!Dw4e6zlZC9J-zyCJ zW!C@L#&QnR!3;#5jNC9*`PFEFNMTt#Sj}uSK6v(aRC?##<5} zB47~;@O;GX!pV~kcxiPEJlldD_HF{D#_n^(&WD%cDm_T1#PW_`DN2EB zc`vWyhC0E|o}!|Wfj}TEP?+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$|*t$ga zRj#}Q#W+9oqdmjrUPtJ$G?hzm?{HU>-2I1QW_X4HfK3f&{UJ6-Fv4gdhV`m*hvVg@s8nQvM?Zo~bpW004M@ zkbk#;-Vl-T1pZD2PP#&2Fn)0`%97XKQkBr;Kjel|Ao52rlf$B U|M`FV?|2oALK=vADDoHdKUPi?KL7v# diff --git a/Config/Excel/Version.txt b/Config/Excel/Version.txt index c7407f0..a31803f 100644 --- a/Config/Excel/Version.txt +++ b/Config/Excel/Version.txt @@ -1 +1 @@ -{"WorksheetNames":[-8419147776733210060,-3495952183970875596,1720330851179383898,5812538452563588342],"Tables":{"-3495952183970875596":1756213540397,"-1088042625810372120":1753532052628,"1720330851179383898":1753711757684,"3730651590607244245":1753532052629,"5812538452563588342":1753532052630}} \ No newline at end of file +{"WorksheetNames":[-8419147776733210060,-3495952183970875596,1720330851179383898,3730651590607244245],"Tables":{"-3495952183970875596":1756269765285,"-1088042625810372120":1748918712210,"1720330851179383898":1753770985781,"3730651590607244245":1748918712210,"5812538452563588342":1751250727840}} \ No newline at end of file diff --git a/Config/Json/Server/SceneConfigData.Json b/Config/Json/Server/SceneConfigData.Json index 60bce78..95751da 100644 --- a/Config/Json/Server/SceneConfigData.Json +++ b/Config/Json/Server/SceneConfigData.Json @@ -4,5 +4,6 @@ {"Id":1003,"ProcessConfigId":1,"WorldConfigId":1,"SceneRuntimeMode":"MultiThread","SceneTypeString":"Gate","NetworkProtocol":"KCP","OuterPort":20000,"InnerPort":11021,"SceneType":3}, {"Id":1004,"ProcessConfigId":1,"WorldConfigId":1,"SceneRuntimeMode":"MultiThread","SceneTypeString":"Game","NetworkProtocol":null,"OuterPort":0,"InnerPort":11031,"SceneType":4}, {"Id":1006,"ProcessConfigId":1,"WorldConfigId":1,"SceneRuntimeMode":"MultiThread","SceneTypeString":"Chat","NetworkProtocol":null,"OuterPort":0,"InnerPort":11051,"SceneType":8}, -{"Id":1007,"ProcessConfigId":1,"WorldConfigId":1,"SceneRuntimeMode":"MultiThread","SceneTypeString":"Map","NetworkProtocol":null,"OuterPort":0,"InnerPort":11061,"SceneType":5} +{"Id":1007,"ProcessConfigId":1,"WorldConfigId":1,"SceneRuntimeMode":"MultiThread","SceneTypeString":"Map","NetworkProtocol":null,"OuterPort":0,"InnerPort":11061,"SceneType":5}, +{"Id":1008,"ProcessConfigId":1,"WorldConfigId":1,"SceneRuntimeMode":"MultiThread","SceneTypeString":"Map","NetworkProtocol":null,"OuterPort":0,"InnerPort":11062,"SceneType":5} ]} diff --git a/Config/NetworkProtocol/Inner/InnerMessage.proto b/Config/NetworkProtocol/Inner/InnerMessage.proto index 0709ff3..9b414cc 100644 --- a/Config/NetworkProtocol/Inner/InnerMessage.proto +++ b/Config/NetworkProtocol/Inner/InnerMessage.proto @@ -66,4 +66,25 @@ message Map2G_EnterRoomResponse // IRouteResponse { string RoomCode = 1; //房间代码 repeated MapUnitInfo Units = 2; //房间玩家列表 +} + + +/// 请求离开房间 +message G2Map_ExitRoomRequest // IRouteRequest,Map2G_ExiRoomResponse +{ + string RoomCode = 1; //房间代码 + int64 AccountId = 2; //账号id +} + +/// 请求离开房间响应 +message Map2G_ExiRoomResponse // IRouteResponse +{ +} + + +/// 通知网关切换地图 +message Map2G_ChangeMapMessage // IRouteMessage +{ + int32 MapId = 1; + int32 Node = 2; //站位节点 } \ No newline at end of file diff --git a/Config/NetworkProtocol/Outer/MapMessage.proto b/Config/NetworkProtocol/Outer/MapMessage.proto index 1180e62..53f04f4 100644 --- a/Config/NetworkProtocol/Outer/MapMessage.proto +++ b/Config/NetworkProtocol/Outer/MapMessage.proto @@ -27,6 +27,17 @@ message G2C_EnterRoomResponse // IResponse } +/// 请求网关离开房间 +message C2G_ExitRoomRequest // IRequest,G2C_ExitRoomResponse +{ + string RoomCode = 1; //房间代码 +} +/// 请求网关进入离开响应 +message G2C_ExitRoomResponse // IResponse +{ + string RoomCode = 1; //房间代码 +} + message C2Map_EnterMapRequest // ICustomRouteRequest,Map2C_EnterMapResponse,MapRoute { @@ -36,5 +47,5 @@ message C2Map_EnterMapRequest // ICustomRouteRequest,Map2C_EnterMapResponse,MapR message Map2C_EnterMapResponse // ICustomRouteResponse { - int32 MapId = 1; //地图id + } \ No newline at end of file diff --git a/Config/NetworkProtocol/Outer/OuterMessage.proto b/Config/NetworkProtocol/Outer/OuterMessage.proto index efc4d42..8684598 100644 --- a/Config/NetworkProtocol/Outer/OuterMessage.proto +++ b/Config/NetworkProtocol/Outer/OuterMessage.proto @@ -40,6 +40,14 @@ message G2C_RepeatLogin // IMessage } +/// 通知客户端切换地图 +message G2C_ChangeMap // IMessage +{ + int32 MapId = 1; //地图id + int32 Node = 2; //站位节点 +} + + message C2Game_GetRoleInfoRequest // ICustomRouteRequest,Game2C_GetRoleInfoResponse,GameRoute { diff --git a/Entity/Gate/GateUnit.cs b/Entity/Gate/GateUnit.cs index a37b9c6..de814d0 100644 --- a/Entity/Gate/GateUnit.cs +++ b/Entity/Gate/GateUnit.cs @@ -5,9 +5,9 @@ namespace NB.Gate; public class GateUnit : Entity { - public bool Kick; public long AccountID; public int Region; + public string RoomCode = string.Empty; public Dictionary SceneRoutes = new Dictionary(); public EntityReference Session; } \ No newline at end of file diff --git a/Entity/Generate/NetworkProtocol/InnerMessage.cs b/Entity/Generate/NetworkProtocol/InnerMessage.cs index 2519fb0..a799e68 100644 --- a/Entity/Generate/NetworkProtocol/InnerMessage.cs +++ b/Entity/Generate/NetworkProtocol/InnerMessage.cs @@ -253,4 +253,75 @@ namespace Fantasy [ProtoMember(3)] public uint ErrorCode { get; set; } } + /// + /// 请求离开房间 + /// + [ProtoContract] + public partial class G2Map_ExitRoomRequest : AMessage, IRouteRequest, IProto + { + public static G2Map_ExitRoomRequest Create(Scene scene) + { + return scene.MessagePoolComponent.Rent(); + } + public override void Dispose() + { + RoomCode = default; + AccountId = default; +#if FANTASY_NET || FANTASY_UNITY + GetScene().MessagePoolComponent.Return(this); +#endif + } + [ProtoIgnore] + public Map2G_ExiRoomResponse ResponseType { get; set; } + public uint OpCode() { return InnerOpcode.G2Map_ExitRoomRequest; } + [ProtoMember(1)] + public string RoomCode { get; set; } + [ProtoMember(2)] + public long AccountId { get; set; } + } + /// + /// 请求离开房间响应 + /// + [ProtoContract] + public partial class Map2G_ExiRoomResponse : AMessage, IRouteResponse, IProto + { + public static Map2G_ExiRoomResponse Create(Scene scene) + { + return scene.MessagePoolComponent.Rent(); + } + public override void Dispose() + { + ErrorCode = default; +#if FANTASY_NET || FANTASY_UNITY + GetScene().MessagePoolComponent.Return(this); +#endif + } + public uint OpCode() { return InnerOpcode.Map2G_ExiRoomResponse; } + [ProtoMember(1)] + public uint ErrorCode { get; set; } + } + /// + /// 通知网关切换地图 + /// + [ProtoContract] + public partial class Map2G_ChangeMapMessage : AMessage, IRouteMessage, IProto + { + public static Map2G_ChangeMapMessage Create(Scene scene) + { + return scene.MessagePoolComponent.Rent(); + } + public override void Dispose() + { + MapId = default; + Node = default; +#if FANTASY_NET || FANTASY_UNITY + GetScene().MessagePoolComponent.Return(this); +#endif + } + public uint OpCode() { return InnerOpcode.Map2G_ChangeMapMessage; } + [ProtoMember(1)] + public int MapId { get; set; } + [ProtoMember(2)] + public int Node { get; set; } + } } diff --git a/Entity/Generate/NetworkProtocol/InnerOpcode.cs b/Entity/Generate/NetworkProtocol/InnerOpcode.cs index 81c5c0b..d8c5cdf 100644 --- a/Entity/Generate/NetworkProtocol/InnerOpcode.cs +++ b/Entity/Generate/NetworkProtocol/InnerOpcode.cs @@ -12,5 +12,8 @@ namespace Fantasy public const uint Club2Chat_CreateChannel = 939534098; public const uint G2Map_EnterRoomRequest = 1073751828; public const uint Map2G_EnterRoomResponse = 1207969556; + public const uint G2Map_ExitRoomRequest = 1073751829; + public const uint Map2G_ExiRoomResponse = 1207969557; + public const uint Map2G_ChangeMapMessage = 939534099; } } diff --git a/Entity/Generate/NetworkProtocol/MapMessage.cs b/Entity/Generate/NetworkProtocol/MapMessage.cs index 9029d73..c440d81 100644 --- a/Entity/Generate/NetworkProtocol/MapMessage.cs +++ b/Entity/Generate/NetworkProtocol/MapMessage.cs @@ -119,6 +119,53 @@ namespace Fantasy [ProtoMember(3)] public uint ErrorCode { get; set; } } + /// + /// 请求网关离开房间 + /// + [ProtoContract] + public partial class C2G_ExitRoomRequest : AMessage, IRequest, IProto + { + public static C2G_ExitRoomRequest Create(Scene scene) + { + return scene.MessagePoolComponent.Rent(); + } + public override void Dispose() + { + RoomCode = default; +#if FANTASY_NET || FANTASY_UNITY + GetScene().MessagePoolComponent.Return(this); +#endif + } + [ProtoIgnore] + public G2C_ExitRoomResponse ResponseType { get; set; } + public uint OpCode() { return OuterOpcode.C2G_ExitRoomRequest; } + [ProtoMember(1)] + public string RoomCode { get; set; } + } + /// + /// 请求网关进入离开响应 + /// + [ProtoContract] + public partial class G2C_ExitRoomResponse : AMessage, IResponse, IProto + { + public static G2C_ExitRoomResponse Create(Scene scene) + { + return scene.MessagePoolComponent.Rent(); + } + public override void Dispose() + { + ErrorCode = default; + RoomCode = default; +#if FANTASY_NET || FANTASY_UNITY + GetScene().MessagePoolComponent.Return(this); +#endif + } + public uint OpCode() { return OuterOpcode.G2C_ExitRoomResponse; } + [ProtoMember(1)] + public string RoomCode { get; set; } + [ProtoMember(2)] + public uint ErrorCode { get; set; } + } [ProtoContract] public partial class C2Map_EnterMapRequest : AMessage, ICustomRouteRequest, IProto { @@ -154,15 +201,12 @@ namespace Fantasy public override void Dispose() { ErrorCode = default; - MapId = default; #if FANTASY_NET || FANTASY_UNITY GetScene().MessagePoolComponent.Return(this); #endif } public uint OpCode() { return OuterOpcode.Map2C_EnterMapResponse; } [ProtoMember(1)] - public int MapId { get; set; } - [ProtoMember(2)] public uint ErrorCode { get; set; } } } diff --git a/Entity/Generate/NetworkProtocol/OuterMessage.cs b/Entity/Generate/NetworkProtocol/OuterMessage.cs index cb9c2d8..d020beb 100644 --- a/Entity/Generate/NetworkProtocol/OuterMessage.cs +++ b/Entity/Generate/NetworkProtocol/OuterMessage.cs @@ -129,6 +129,30 @@ namespace Fantasy } public uint OpCode() { return OuterOpcode.G2C_RepeatLogin; } } + /// + /// 通知客户端切换地图 + /// + [ProtoContract] + public partial class G2C_ChangeMap : AMessage, IMessage, IProto + { + public static G2C_ChangeMap Create(Scene scene) + { + return scene.MessagePoolComponent.Rent(); + } + public override void Dispose() + { + MapId = default; + Node = default; +#if FANTASY_NET || FANTASY_UNITY + GetScene().MessagePoolComponent.Return(this); +#endif + } + public uint OpCode() { return OuterOpcode.G2C_ChangeMap; } + [ProtoMember(1)] + public int MapId { get; set; } + [ProtoMember(2)] + public int Node { get; set; } + } [ProtoContract] public partial class C2Game_GetRoleInfoRequest : AMessage, ICustomRouteRequest, IProto { diff --git a/Entity/Generate/NetworkProtocol/OuterOpcode.cs b/Entity/Generate/NetworkProtocol/OuterOpcode.cs index e380a2c..0936072 100644 --- a/Entity/Generate/NetworkProtocol/OuterOpcode.cs +++ b/Entity/Generate/NetworkProtocol/OuterOpcode.cs @@ -6,13 +6,16 @@ namespace Fantasy public const uint Map2C_CreateRoomResponse = 2415929105; public const uint C2G_EnterRoomRequest = 268445457; public const uint G2C_EnterRoomResponse = 402663185; + public const uint C2G_ExitRoomRequest = 268445458; + public const uint G2C_ExitRoomResponse = 402663186; public const uint C2Map_EnterMapRequest = 2281711378; public const uint Map2C_EnterMapResponse = 2415929106; - public const uint C2A_LoginRequest = 268445458; - public const uint A2C_LoginResponse = 402663186; - public const uint C2G_LoginRequest = 268445459; - public const uint G2C_LoginResponse = 402663187; + public const uint C2A_LoginRequest = 268445459; + public const uint A2C_LoginResponse = 402663187; + public const uint C2G_LoginRequest = 268445460; + public const uint G2C_LoginResponse = 402663188; public const uint G2C_RepeatLogin = 134227729; + public const uint G2C_ChangeMap = 134227730; public const uint C2Game_GetRoleInfoRequest = 2281711379; public const uint Game2C_GetRoleInfoResponse = 2415929107; public const uint C2Map_EnterRoomRequest = 2281711380; diff --git a/Entity/Map/Entity/Map.cs b/Entity/Map/Entity/Map.cs index 0a2046e..3bbc832 100644 --- a/Entity/Map/Entity/Map.cs +++ b/Entity/Map/Entity/Map.cs @@ -4,4 +4,13 @@ namespace NB.Map; public class Map : Entity { + /// + /// 地图配置id + /// + public int MapId; + + /// + /// 地图玩家 + /// + public Dictionary Units = new Dictionary(); } \ No newline at end of file diff --git a/Entity/Map/Entity/MapUnit.cs b/Entity/Map/Entity/MapUnit.cs index edf10b7..bab9391 100644 --- a/Entity/Map/Entity/MapUnit.cs +++ b/Entity/Map/Entity/MapUnit.cs @@ -23,10 +23,5 @@ public class MapUnit : Entity /// public int MapId; - /// - /// 当前所在房间id - /// - public int RoomId; - public long GateRouteId; } \ No newline at end of file diff --git a/Entity/Model/Def/ErrorCode.cs b/Entity/Model/Def/ErrorCode.cs index d57c45b..1c8b31f 100644 --- a/Entity/Model/Def/ErrorCode.cs +++ b/Entity/Model/Def/ErrorCode.cs @@ -69,4 +69,19 @@ public class ErrorCode /// 已在房间,不能加入另一个 /// public const uint MapRoomHave = 13004; + + /// + /// 加入服务失败 + /// + public const uint MapRoomEnterError = 13005; + + /// + /// 重复加入失败 + /// + public const uint MapRoomEnterRepeated = 13006; + + /// + /// 地图id错误 + /// + public const uint MapIdError = 13007; } \ No newline at end of file diff --git a/Hotfix/Gate/Handler/Outer/C2G_EnterRoomRequestHandler.cs b/Hotfix/Gate/Handler/Outer/C2G_EnterRoomRequestHandler.cs index bd56c76..aefa70c 100644 --- a/Hotfix/Gate/Handler/Outer/C2G_EnterRoomRequestHandler.cs +++ b/Hotfix/Gate/Handler/Outer/C2G_EnterRoomRequestHandler.cs @@ -3,10 +3,9 @@ using Fantasy.Async; using Fantasy.Network; using Fantasy.Network.Interface; using Fantasy.Platform.Net; -using NB.Common; using NB.Map; -namespace NB.Gate.Handler; +namespace NB.Gate; public class C2G_EnterRoomRequestHandler : MessageRPC { @@ -41,6 +40,13 @@ public class C2G_EnterRoomRequestHandler : MessageRPC +{ + protected override async FTask Run(Session session, C2G_ExitRoomRequest request, G2C_ExitRoomResponse response, + Action reply) + { + if (string.IsNullOrEmpty(request.RoomCode)) + { + response.ErrorCode = ErrorCode.MapRoomIdError; + return; + } + + var gateUnitSessionComponent = session.GetComponent(); + if (gateUnitSessionComponent == null) + { + response.ErrorCode = ErrorCode.ErrServer; + return; + } + + // 在缓存中检查该账号是否存在 + var gateUnitManageComponent = session.Scene.GetComponent(); + if (gateUnitManageComponent == null) + { + response.ErrorCode = ErrorCode.ErrServer; + return; + } + + var gateUnit = gateUnitManageComponent.Get(gateUnitSessionComponent.AccountID); + if (gateUnit == null) + { + response.ErrorCode = ErrorCode.ErrServer; + return; + } + + if (gateUnit.RoomCode != request.RoomCode) + { + response.ErrorCode = ErrorCode.MapRoomIdError; + return; + } + + + RoomHelper.ParseCode(request.RoomCode, out var serviceId, out var roomId); + if (serviceId < 1 || roomId < 1) + { + response.ErrorCode = ErrorCode.MapRoomIdError; + return; + } + + var sceneConfig = SceneConfigData.Instance.Get(serviceId); + if (sceneConfig == null) + { + response.ErrorCode = ErrorCode.MapRoomIdError; + return; + } + + //执行退出房间操作 + var roomResponse = (Map2G_ExiRoomResponse)await session.Scene.NetworkMessagingComponent.CallInnerRoute( + sceneConfig.RouteId, new G2Map_ExitRoomRequest() + { + AccountId = gateUnit.Id, + RoomCode = request.RoomCode, + }); + if (roomResponse.ErrorCode != 0) + { + response.ErrorCode = ErrorCode.MapRoomIdError; + return; + } + + gateUnit.RoomCode = string.Empty; + + response.RoomCode = request.RoomCode; + response.ErrorCode = ErrorCode.Successful; + } +} \ No newline at end of file diff --git a/Hotfix/Gate/Helper/GateLoginHelper.cs b/Hotfix/Gate/Helper/GateLoginHelper.cs index 05b0f03..79c30ef 100644 --- a/Hotfix/Gate/Helper/GateLoginHelper.cs +++ b/Hotfix/Gate/Helper/GateLoginHelper.cs @@ -62,10 +62,6 @@ public static class GateLoginHelper //通知服务器下线 Log.Info($"断线的session id={sessionId}"); var ret = await gateUnit.Offline(sessionId, RouteType.GameRoute, RouteType.SocialRoute, RouteType.MapRoute); - - // await GameSceneHelper.Offline(gateUnit.Scene, gateUnit.AccountID, sessionId); - // await SocialSceneHelper.Offline(gateUnit.Scene, gateUnit.AccountID, sessionId, - // gateUnit.ChatSceneRouteId); return ret; } diff --git a/Hotfix/Gate/System/GateUnitSystem.cs b/Hotfix/Gate/System/GateUnitSystem.cs index 6bbcc1e..2186177 100644 --- a/Hotfix/Gate/System/GateUnitSystem.cs +++ b/Hotfix/Gate/System/GateUnitSystem.cs @@ -2,6 +2,7 @@ using Fantasy.Async; using Fantasy.Entitas.Interface; using Fantasy.Network; +using Fantasy.Platform.Net; using NB.Common; // ReSharper disable ConditionIsAlwaysTrueOrFalseAccordingToNullableAPIContract @@ -13,7 +14,9 @@ public class GateUnitDestroySystem : DestroySystem protected override void Destroy(GateUnit self) { self.AccountID = 0; - self.Kick = false; + self.Region = 0; + self.SceneRoutes.Clear(); + self.RoomCode = string.Empty; } } @@ -21,15 +24,9 @@ public static class GateUnitSystem { #region Address - public static void RemoveAddress(this GateUnit self, int routType, long routeId) + public static void RemoveAddress(this GateUnit self, int routType) { - if (self.SceneRoutes.TryGetValue(routType, out var route)) - { - if (route == routeId) - { - self.SceneRoutes.Remove(routType); - } - } + self.SceneRoutes.Remove(routType); } public static void AddAddress(this GateUnit self, int routType, long routeId) @@ -61,7 +58,7 @@ public static class GateUnitSystem return ErrorCode.Successful; } - public static async FTask Online(this GateUnit self, int routeType) + public static async FTask Online(this GateUnit self, int routeType, SceneConfig? sceneConfig = null) { Session session = self.Session; var routeComponent = session.GetComponent(); @@ -69,9 +66,13 @@ public static class GateUnitSystem { routeComponent = session.AddComponent(); } - - var gameSceneConfig = SceneConfigHelper.GetConfigByRouteType(routeType); - var gameRouteId = gameSceneConfig.RouteId; + + if (sceneConfig == null) + { + sceneConfig = SceneConfigHelper.GetConfigByRouteType(routeType); + } + + var gameRouteId = sceneConfig.RouteId; var gameResponse = (G2Common_EnterResponse)await self.Scene.NetworkMessagingComponent.CallInnerRoute( gameRouteId, new G2Common_EnterRequest() @@ -85,8 +86,10 @@ public static class GateUnitSystem return gameResponse.ErrorCode; } + routeComponent.RemoveAddress(routeType); routeComponent.AddAddress(routeType, gameResponse.UnitRouteId); self.AddAddress(routeType, gameResponse.UnitRouteId); + self.AddAddress(sceneConfig.SceneType, gameRouteId); return ErrorCode.Successful; } @@ -111,7 +114,8 @@ public static class GateUnitSystem public static async FTask Offline(this GateUnit self, long sessionId, int routeType) { - var sceneRouteId = self.GetAddress(routeType); + var sceneConfig = SceneConfigHelper.GetConfigByRouteType(routeType); + var sceneRouteId = sceneConfig.RouteId; if (sceneRouteId < 1) return ErrorCode.Successful; for (int i = 0; i < 10; i++) { @@ -123,7 +127,9 @@ public static class GateUnitSystem }); if (gameResponse.ErrorCode == 0) { - self.RemoveAddress(routeType, sceneRouteId); + //TODO:这里需要清理掉记录的数据 + self.RemoveAddress(routeType); + self.RemoveAddress(sceneConfig.SceneType); return ErrorCode.Successful; } } diff --git a/Hotfix/Map/Handler/C2Map_CreateRoomRequestHandler.cs b/Hotfix/Map/Handler/C2Map_CreateRoomRequestHandler.cs index 3d60f11..325ae54 100644 --- a/Hotfix/Map/Handler/C2Map_CreateRoomRequestHandler.cs +++ b/Hotfix/Map/Handler/C2Map_CreateRoomRequestHandler.cs @@ -39,6 +39,9 @@ public class C2Map_CreateRoomRequestHandler : RouteRPC 0) - // { - // response.ErrorCode = ErrorCode.MapRoomHave; - // return; - // } - // - // roomManageComponent.Enter(entity, request.RoomId); - Log.Info($"进入地图=== map:{request.MapId}"); - entity.MapId = request.MapId; - response.MapId = request.MapId; - - await FTask.CompletedTask; + response.ErrorCode = await entity.EnterMap(request.MapId); } } \ No newline at end of file diff --git a/Hotfix/Map/Handler/Inner/G2Map_EnterRequestHandler.cs b/Hotfix/Map/Handler/Inner/G2Map_EnterRequestHandler.cs index eeb03a6..8bc59cd 100644 --- a/Hotfix/Map/Handler/Inner/G2Map_EnterRequestHandler.cs +++ b/Hotfix/Map/Handler/Inner/G2Map_EnterRequestHandler.cs @@ -15,13 +15,48 @@ public class G2Map_EnterRequestHandler : RouteRPC(); + if (mapUnitManage == null) + { + response.ErrorCode = ErrorCode.ErrServer; + return; + } + + var mapUnit = mapUnitManage.Get(request.AccountId); + if (mapUnit == null) + { + response.ErrorCode = ErrorCode.ErrServer; + return; + } + + RoomHelper.ParseCode(request.RoomCode, out var serviceId, out var roomId); if (serviceId < 1 || roomId < 1) { response.ErrorCode = ErrorCode.MapRoomIdError; return; } - // roomManageComponent.Enter(); + + var room = roomManageComponent.Get(roomId); + if (room == null) + { + response.ErrorCode = ErrorCode.MapRoomIdError; + return; + } + + if (mapUnit.MapId != room.Map) + { + //切换地图 + response.ErrorCode = await mapUnit.EnterMap(mapUnit.MapId); + if (response.ErrorCode != 0) + { + return; + } + } + + + response.ErrorCode = await room.Enter(request.AccountId); + response.RoomCode = room.Code; } } \ No newline at end of file diff --git a/Hotfix/Map/Helper/MapFactory.cs b/Hotfix/Map/Helper/MapFactory.cs new file mode 100644 index 0000000..dad3195 --- /dev/null +++ b/Hotfix/Map/Helper/MapFactory.cs @@ -0,0 +1,20 @@ +using Fantasy; +using Fantasy.Entitas; + +namespace NB.Map; + +public class MapFactory +{ + /// + /// 创建一个地图 + /// + /// + /// + /// + public static Map? Create(Scene scene, int mapId) + { + var map = Entity.Create(scene, true, true); + map.MapId = mapId; + return map; + } +} \ No newline at end of file diff --git a/Hotfix/Map/System/MapManageComponentSystem.cs b/Hotfix/Map/System/MapManageComponentSystem.cs new file mode 100644 index 0000000..900bc2c --- /dev/null +++ b/Hotfix/Map/System/MapManageComponentSystem.cs @@ -0,0 +1,61 @@ +using Fantasy.Entitas; +using Fantasy.Entitas.Interface; + +namespace NB.Map; + +public class MapManageComponentDestroySystem : DestroySystem +{ + protected override void Destroy(MapManageComponent self) + { + foreach (var (_, map) in self.Maps) + { + map.Dispose(); + } + + self.Maps.Clear(); + } +} + +public class MapManageComponentAwakeSystem : AwakeSystem +{ + protected override void Awake(MapManageComponent self) + { + //初始化所有地图 + for (int i = 1; i < 100; i++) + { + //初始化100个地图 + var map = MapFactory.Create(self.Scene, i); + if (map != null) + { + self.Add(map); + } + } + } +} + +public static class MapManageComponentSystem +{ + #region 增删 + + public static void Add(this MapManageComponent self, Map map) + { + self.Maps[map.MapId] = map; + } + + public static bool Remove(this MapManageComponent self, int mapId) + { + if (self.Maps.TryGetValue(mapId, out var map)) + { + map.Dispose(); + } + + return true; + } + + public static Map? Get(this MapManageComponent self, int mapId) + { + return self.Maps.GetValueOrDefault(mapId); + } + + #endregion +} \ No newline at end of file diff --git a/Hotfix/Map/System/MapRoomSystem.cs b/Hotfix/Map/System/MapRoomSystem.cs index 2b4cdfb..149260e 100644 --- a/Hotfix/Map/System/MapRoomSystem.cs +++ b/Hotfix/Map/System/MapRoomSystem.cs @@ -1,4 +1,6 @@ -using Fantasy.Entitas.Interface; +using Fantasy; +using Fantasy.Async; +using Fantasy.Entitas.Interface; namespace NB.Map; @@ -16,4 +18,9 @@ public class MapRoomDestroySystem : DestroySystem public static class MapRoomSystem { + public static async FTask Enter(this MapRoom self, long unitId) + { + await FTask.CompletedTask; + return ErrorCode.Successful; + } } \ No newline at end of file diff --git a/Hotfix/Map/System/MapSystem.cs b/Hotfix/Map/System/MapSystem.cs new file mode 100644 index 0000000..a27e3d5 --- /dev/null +++ b/Hotfix/Map/System/MapSystem.cs @@ -0,0 +1,16 @@ +using Fantasy.Entitas.Interface; + +namespace NB.Map; + +public class MapDestroySystem : DestroySystem +{ + protected override void Destroy(Map self) + { + self.MapId = 0; + self.Units.Clear(); + } +} + +public static class MapSystem +{ +} \ No newline at end of file diff --git a/Hotfix/Map/System/MapUnitSystem.cs b/Hotfix/Map/System/MapUnitSystem.cs new file mode 100644 index 0000000..529d1cd --- /dev/null +++ b/Hotfix/Map/System/MapUnitSystem.cs @@ -0,0 +1,38 @@ +using Fantasy; +using Fantasy.Async; +using Fantasy.Entitas.Interface; +using Unity.Mathematics; + +namespace NB.Map; + +public class MapUnitSystemDestroySystem : DestroySystem +{ + protected override void Destroy(MapUnit self) + { + self.MapId = 0; + self.Position = float3.zero; + self.Rotation = float4.zero; + self.GateRouteId = 0L; + } +} + +public static class MapUnitSystem +{ + public static async FTask EnterMap(this MapUnit self, int mapId) + { + var mapManageComponent = self.Scene.GetComponent(); + + var map = mapManageComponent.Get(mapId); + if (map == null) + { + return ErrorCode.MapIdError; + } + + // map.en + + await FTask.CompletedTask; + + + return ErrorCode.Successful; + } +} \ No newline at end of file diff --git a/Hotfix/Map/System/RoomManageComponentSystem.cs b/Hotfix/Map/System/RoomManageComponentSystem.cs index d759524..2f4d5e2 100644 --- a/Hotfix/Map/System/RoomManageComponentSystem.cs +++ b/Hotfix/Map/System/RoomManageComponentSystem.cs @@ -46,7 +46,10 @@ public static class RoomManageComponentSystem return true; } - + public static MapRoom? Get(this RoomManageComponent self, int roomId) + { + return self.Rooms.GetValueOrDefault(roomId); + } #endregion #region 房间Id @@ -79,15 +82,5 @@ public static class RoomManageComponentSystem #endregion - #region 进入退出 - - public static void Enter(this RoomManageComponent self, MapUnit unit, long roomId) - { - } - - public static void Exit(this RoomManageComponent self, MapUnit unit) - { - } - - #endregion + } \ No newline at end of file diff --git a/Main/Properties/launchSettings.json b/Main/Properties/launchSettings.json index b30e999..90a0233 100644 --- a/Main/Properties/launchSettings.json +++ b/Main/Properties/launchSettings.json @@ -3,6 +3,7 @@ "profiles": { "Main": { "commandName": "Project", + "workingDirectory": "$(OutputPath)", "environmentVariables": {}, "commandLineArgs": "--m Develop" } diff --git a/Server.sln.DotSettings.user b/Server.sln.DotSettings.user index 3d97d67..5c51dc1 100644 --- a/Server.sln.DotSettings.user +++ b/Server.sln.DotSettings.user @@ -21,6 +21,7 @@ ForceIncluded ForceIncluded ForceIncluded + ForceIncluded ForceIncluded ForceIncluded ForceIncluded