From 7325e268ce9e83cdc3a74e0d31815407f76d265b Mon Sep 17 00:00:00 2001 From: "Bob.Song" <605277374@qq.com> Date: Tue, 26 Aug 2025 18:03:52 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E7=9B=B8=E5=85=B3=E5=8D=8F?= =?UTF-8?q?=E8=AE=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../NetworkProtocol/Inner/InnerMessage.proto | 53 +- .../NetworkProtocol/Outer/GameMessage.proto | 44 ++ Config/NetworkProtocol/Outer/MapMessage.proto | 151 ------ .../NetworkProtocol/Outer/OuterMessage.proto | 12 + .../NetworkProtocol/Outer/RoomMessage.proto | 141 +++++ .../{Account.proto => CommonProtoData.proto} | 0 Config/NetworkProtocol/RouteType.Config | 3 +- Entity/Entity.csproj | 2 +- Entity/Gate/GateUnit.cs | 3 +- .../{Account.cs => CommonProtoData.cs} | 0 .../Generate/NetworkProtocol/GameMessage.cs | 185 +++++++ .../Generate/NetworkProtocol/InnerMessage.cs | 139 +---- .../Generate/NetworkProtocol/InnerOpcode.cs | 12 +- Entity/Generate/NetworkProtocol/MapMessage.cs | 482 ----------------- .../Generate/NetworkProtocol/OuterMessage.cs | 44 ++ .../Generate/NetworkProtocol/OuterOpcode.cs | 85 +-- .../Generate/NetworkProtocol/RoomMessage.cs | 502 ++++++++++++++++++ Entity/Generate/NetworkProtocol/RouteType.cs | 3 +- .../Handler/G2Common_EnterRequestHandler.cs | 66 +++ .../Handler/G2Common_ExitRequestHandler.cs | 55 ++ Hotfix/Common/Helper/LoginHelper.cs | 9 + Hotfix/Common/Helper/SceneConfigHelper.cs | 14 + Hotfix/Game/Cache/Helper/CacheHandler.cs | 3 +- .../Handler/G2Game_EnterRequestHandler.cs | 58 +- Hotfix/Game/Helper/GameSceneHelper.cs | 48 -- .../Components/PlayerManageComponentSystem.cs | 3 +- Hotfix/Game/Player/Helper/PlayerHelper.cs | 2 +- .../Handler/Outer/C2G_LoginRequestHandler.cs | 27 - Hotfix/Gate/Helper/GateLoginHelper.cs | 48 +- Hotfix/Gate/System/GateUnitSystem.cs | 124 ++++- Hotfix/Hotfix.csproj | 2 + .../Handler/C2Map_CreateRoomRequestHandler.cs | 30 +- .../Handler/Inner/G2S_EnterRequestHandler.cs | 22 - .../Handler/Inner/G2S_ExitRequestHandler.cs | 16 - .../Social/Chat/Helper/SocialSceneHelper.cs | 91 ++-- .../System/ChatUnitManageComponentSystem.cs | 8 +- 36 files changed, 1402 insertions(+), 1085 deletions(-) create mode 100644 Config/NetworkProtocol/Outer/GameMessage.proto create mode 100644 Config/NetworkProtocol/Outer/RoomMessage.proto rename Config/NetworkProtocol/Outer/data/{Account.proto => CommonProtoData.proto} (100%) rename Entity/Generate/NetworkProtocol/{Account.cs => CommonProtoData.cs} (100%) create mode 100644 Entity/Generate/NetworkProtocol/GameMessage.cs create mode 100644 Entity/Generate/NetworkProtocol/RoomMessage.cs create mode 100644 Hotfix/Common/Handler/G2Common_EnterRequestHandler.cs create mode 100644 Hotfix/Common/Handler/G2Common_ExitRequestHandler.cs create mode 100644 Hotfix/Common/Helper/LoginHelper.cs create mode 100644 Hotfix/Common/Helper/SceneConfigHelper.cs delete mode 100644 Hotfix/Game/Helper/GameSceneHelper.cs delete mode 100644 Hotfix/Social/Chat/Handler/Inner/G2S_EnterRequestHandler.cs delete mode 100644 Hotfix/Social/Chat/Handler/Inner/G2S_ExitRequestHandler.cs diff --git a/Config/NetworkProtocol/Inner/InnerMessage.proto b/Config/NetworkProtocol/Inner/InnerMessage.proto index 8f9b6a3..2423d5a 100644 --- a/Config/NetworkProtocol/Inner/InnerMessage.proto +++ b/Config/NetworkProtocol/Inner/InnerMessage.proto @@ -1,25 +1,28 @@ syntax = "proto3"; package Sining.Message; ///通知游戏服角色进入该游戏服 -message G2Game_EnterRequest // IRouteRequest,Game2G_EnterResponse +message G2Common_EnterRequest // IRouteRequest,G2Common_EnterResponse +{ + int64 AccountId = 1; //账号id + int64 GateRouteId = 2; //网关路由地址 + int32 RouteType = 3; //登陆的路由类型 +} + +message G2Common_EnterResponse // IRouteResponse +{ + int64 RoleRouteId = 1; //实体的路由id + int32 RouteType = 2; //登陆的场景类型 +} + +message G2Common_ExitRequest // IRouteRequest,Common2G_ExitResponse { int64 AccountId = 1; //账号id int64 GateRouteId = 2;//网关路由地址 } -message Game2G_EnterResponse // IRouteResponse -{ - int64 RoleRouteId = 1; //角色实体的路由id - RoleSimpleInfo RoleInfo = 2; //角色信息 -} -message G2Game_ExitRequest // IRouteRequest,Game2G_ExitResponse -{ - int64 AccountId = 1; //账号id - int64 GateRouteId = 2;//网关路由地址 -} - -message Game2G_ExitResponse // IRouteResponse +message Common2G_ExitResponse // IRouteResponse { + } @@ -36,30 +39,6 @@ message G2S_GetPlayerBasicInfoResponse // IRouteResponse -///通知游戏服角色进入该聊天服 -message G2S_EnterRequest // IRouteRequest,S2G_EnterResponse -{ - RoleSimpleInfo Role = 1; //角色信息 - int64 GateRouteId = 2;//网关路由地址 -} - -message S2G_EnterResponse // IRouteResponse -{ - int64 RoleRouteId = 1; //角色实体的路由id -} - -message G2S_ExitRequest // IRouteRequest,S2G_ExitResponse -{ - int64 AccountId = 1; //账号id - int64 GateRouteId = 2;//网关路由地址 -} - -message S2G_ExitResponse // IRouteResponse -{ - -} - - message S2G_ChatMessage // IRouteMessage { ChatMessageInfo Message = 1; //聊天内容 diff --git a/Config/NetworkProtocol/Outer/GameMessage.proto b/Config/NetworkProtocol/Outer/GameMessage.proto new file mode 100644 index 0000000..54b0540 --- /dev/null +++ b/Config/NetworkProtocol/Outer/GameMessage.proto @@ -0,0 +1,44 @@ +syntax = "proto3"; +package Fantasy.Network.Message; + +/// 请求创建房间 +message C2Game_CreateRoomRequest // ICustomRouteRequest,Game2C_CreateRoomResponse,MapRoute +{ + int32 MapId = 1;//地图id + string Password = 2;//进入密码 +} + +/// 请求创建房间成功 +message Game2C_CreateRoomResponse // ICustomRouteResponse +{ + int32 MapId = 1;//地图id + int64 RoomId = 2;//房间id +} + +/// 请求进入地图 +message C2Game_EnterMapRequest // ICustomRouteRequest,Game2C_EnterMapResponse,MapRoute +{ + int32 MapId = 1; //房间id + int32 Type = 2; //进入地图方式 +} + +/// 请求进入地图响应 +message Game2C_EnterMapResponse // ICustomRouteResponse +{ + int32 MapId = 1; //地图id + int Pos = 2; //位置 +} + +/// 请求进入房间 +message C2Game_EnterRoomRequest // ICustomRouteRequest,Game2C_EnterRoomResponse,MapRoute +{ + int32 MapId = 1;//房间id + string Password = 2;//进入密码 +} + +/// 请求进入房间响应 +message Game2C_EnterRoomResponse // ICustomRouteResponse +{ + int32 MapId = 1;//地图id + int64 RoomId = 2;//房间id +} \ No newline at end of file diff --git a/Config/NetworkProtocol/Outer/MapMessage.proto b/Config/NetworkProtocol/Outer/MapMessage.proto index bf42a68..e69de29 100644 --- a/Config/NetworkProtocol/Outer/MapMessage.proto +++ b/Config/NetworkProtocol/Outer/MapMessage.proto @@ -1,151 +0,0 @@ -syntax = "proto3"; -package Fantasy.Network.Message; - -message UnitGearItemInfo -{ - int64 Id = 1; //唯一id - int32 ConfigId = 2; //配置id -} - -message UnitGearInfo -{ - UnitGearItemInfo Rod = 1; - UnitGearItemInfo Reel = 2; - UnitGearItemInfo Bobber = 3; - UnitGearItemInfo Hook = 4; - UnitGearItemInfo Bait = 5; - UnitGearItemInfo Lure = 6; - UnitGearItemInfo Weight = 7; - UnitGearItemInfo Line = 8; - UnitGearItemInfo Leader = 9; - UnitGearItemInfo Feeder = 10; -} - -message Vector3Info -{ - float x = 1; - float y = 2; - float z = 3; -} -message QuaternionInfo -{ - float x = 1; - float y = 2; - float z = 3; - float w = 4; -} - -message UnitFishingInfo -{ - float LineLength = 1;//线长度 - float ReelSpeed = 2;//收线速度 - bool OpenLight = 3;//打开手电筒 - int RodSetting = 4; -} - -message UnitStateInfo -{ - int32 State = 1; //状态id - repeated string Args = 2; //状态参数 -} - -message MapUnitInfo -{ - int64 Id = 1; //用户id - RoleSimpleInfo RoleInfo = 2; //基础信息 - MapUnitPositionInfo Location = 3; //位置信息 - UnitStateInfo State = 4; //状态信息 - UnitGearInfo Gears = 5; //钓组数据 - UnitFishingInfo FishingInfo = 6; //钓鱼状态信息 - repeated KeyValueInt32 KV = 7; //属性信息 -} - -message MapUnitPositionInfo -{ - Vector3Info Position = 1; - QuaternionInfo Rotation = 2; -} - -message C2Map_CreateRoomRequest // ICustomRouteRequest,Map2C_CreateRoomResponse,MapRoute -{ - int32 MapId = 1;//房间id - string Password = 2;//进入密码 -} - -message Map2C_CreateRoomResponse // ICustomRouteResponse -{ - int32 MapId = 1;//地图id - int64 RoomId = 2;//房间id -} - -message C2Map_EnterRoomRequest // ICustomRouteRequest,Map2C_EnterRoomResponse,MapRoute -{ - int32 MapId = 1;//房间id - string Password = 2;//进入密码 -} - -message Map2C_EnterRoomResponse // ICustomRouteResponse -{ - int32 MapId = 1;//地图id - int64 RoomId = 2;//房间id -} - -message C2Map_EnterMapRequest // ICustomRouteRequest,Map2C_EnterMapResponse,MapRoute -{ - int32 MapId = 1;//地图id - int64 RoomId = 2;//房间id,如果联机则有 -} - -message Map2C_EnterMapResponse // ICustomRouteResponse -{ - repeated MapUnitInfo Roles = 1; //地图玩家列表 - int64 MapId = 2; //地图id -} - - -message C2Map_Move // ICustomRouteMessage,MapRoute -{ - MapUnitPositionInfo Location = 1; - bool IsStop = 2; -} - - -///用户进入地图 -message Map2C_RoleEnterMapNotify // ICustomRouteMessage,MapRoute -{ - MapUnitInfo Info = 1; -} - -///用户离开地图 -message Map2C_RoleExitMapNotify // ICustomRouteMessage,MapRoute -{ - int64 Id = 1;//离开人员 -} - -///玩家状态变化同步 -message Map2C_RoleStateNotify // ICustomRouteMessage,MapRoute -{ - int64 Id = 1; - UnitStateInfo State = 2; -} - -///玩家钓组状态变化 -message Map2C_RoleGearStateNotify // ICustomRouteMessage,MapRoute -{ - int64 Id = 1; - UnitFishingInfo State = 2; -} - -///玩家钓组变化 -message Map2C_RoleGearChangeNotify // ICustomRouteMessage,MapRoute -{ - int64 Id = 1; - UnitGearInfo Gears = 2; //钓组数据 -} - -///玩家位置变化 -message Map2C_MoveNotify -{ - int64 Id = 1; - MapUnitPositionInfo Location = 2; -} \ No newline at end of file diff --git a/Config/NetworkProtocol/Outer/OuterMessage.proto b/Config/NetworkProtocol/Outer/OuterMessage.proto index 5ca1bfb..133ed58 100644 --- a/Config/NetworkProtocol/Outer/OuterMessage.proto +++ b/Config/NetworkProtocol/Outer/OuterMessage.proto @@ -30,6 +30,18 @@ message G2C_LoginResponse // IResponse { int64 RoleId = 1; } + +/// 客户端登陆聊天服 +message C2G_LoginChatRequest +{ + int32 Type = 1; +} +/// 客户端登陆聊天服响应 +message G2C_LoginChatResponse // IResponse +{ + int64 RouteId = 1; +} + /// 通知客户端重复登录 message G2C_RepeatLogin // IMessage { diff --git a/Config/NetworkProtocol/Outer/RoomMessage.proto b/Config/NetworkProtocol/Outer/RoomMessage.proto new file mode 100644 index 0000000..836f09f --- /dev/null +++ b/Config/NetworkProtocol/Outer/RoomMessage.proto @@ -0,0 +1,141 @@ +syntax = "proto3"; +package Fantasy.Network.Message; + +message UnitGearItemInfo +{ + int64 Id = 1; //唯一id + int32 ConfigId = 2; //配置id +} + +message UnitGearInfo +{ + UnitGearItemInfo Rod = 1; + UnitGearItemInfo Reel = 2; + UnitGearItemInfo Bobber = 3; + UnitGearItemInfo Hook = 4; + UnitGearItemInfo Bait = 5; + UnitGearItemInfo Lure = 6; + UnitGearItemInfo Weight = 7; + UnitGearItemInfo Line = 8; + UnitGearItemInfo Leader = 9; + UnitGearItemInfo Feeder = 10; +} + +message Vector3Info +{ + float x = 1; + float y = 2; + float z = 3; +} +message QuaternionInfo +{ + float x = 1; + float y = 2; + float z = 3; + float w = 4; +} + +message UnitFishingInfo +{ + float LineLength = 1;//线长度 + float ReelSpeed = 2;//收线速度 + bool OpenLight = 3;//打开手电筒 + int RodSetting = 4; +} + +message UnitStateInfo +{ + int32 State = 1; //状态id + repeated string Args = 2; //状态参数 +} + +message MapUnitInfo +{ + int64 Id = 1; //用户id + RoleSimpleInfo RoleInfo = 2; //基础信息 + MapUnitPositionInfo Location = 3; //位置信息 + UnitStateInfo State = 4; //状态信息 + UnitGearInfo Gears = 5; //钓组数据 + UnitFishingInfo FishingInfo = 6; //钓鱼状态信息 + repeated KeyValueInt32 KV = 7; //属性信息 +} + +message MapUnitPositionInfo +{ + Vector3Info Position = 1; + QuaternionInfo Rotation = 2; +} + + + +message C2Map_EnterRoomRequest // ICustomRouteRequest,Map2C_EnterRoomResponse,MapRoute +{ + int32 MapId = 1;//房间id + string Password = 2;//进入密码 +} + +message Map2C_EnterRoomResponse // ICustomRouteResponse +{ + int32 MapId = 1;//地图id + int64 RoomId = 2;//房间id +} + +message C2Map_EnterMapRequest // ICustomRouteRequest,Map2C_EnterMapResponse,MapRoute +{ + int32 MapId = 1;//地图id + int64 RoomId = 2;//房间id,如果联机则有 +} + +message Map2C_EnterMapResponse // ICustomRouteResponse +{ + repeated MapUnitInfo Roles = 1; //地图玩家列表 + int64 MapId = 2; //地图id +} + + +message C2Map_Move // ICustomRouteMessage,MapRoute +{ + MapUnitPositionInfo Location = 1; + bool IsStop = 2; +} + + +///用户进入地图 +message Map2C_RoleEnterMapNotify // ICustomRouteMessage,MapRoute +{ + MapUnitInfo Info = 1; +} + +///用户离开地图 +message Map2C_RoleExitMapNotify // ICustomRouteMessage,MapRoute +{ + int64 Id = 1;//离开人员 +} + +///玩家状态变化同步 +message Map2C_RoleStateNotify // ICustomRouteMessage,MapRoute +{ + int64 Id = 1; + UnitStateInfo State = 2; +} + +///玩家钓组状态变化 +message Map2C_RoleGearStateNotify // ICustomRouteMessage,MapRoute +{ + int64 Id = 1; + UnitFishingInfo State = 2; +} + +///玩家钓组变化 +message Map2C_RoleGearChangeNotify // ICustomRouteMessage,MapRoute +{ + int64 Id = 1; + UnitGearInfo Gears = 2; //钓组数据 +} + +///玩家位置变化 +message Map2C_MoveNotify +{ + int64 Id = 1; + MapUnitPositionInfo Location = 2; +} \ No newline at end of file diff --git a/Config/NetworkProtocol/Outer/data/Account.proto b/Config/NetworkProtocol/Outer/data/CommonProtoData.proto similarity index 100% rename from Config/NetworkProtocol/Outer/data/Account.proto rename to Config/NetworkProtocol/Outer/data/CommonProtoData.proto diff --git a/Config/NetworkProtocol/RouteType.Config b/Config/NetworkProtocol/RouteType.Config index 0f04d57..78df07a 100644 --- a/Config/NetworkProtocol/RouteType.Config +++ b/Config/NetworkProtocol/RouteType.Config @@ -2,5 +2,4 @@ GateRoute = 1001 // Gate SocialRoute = 1002 // Social GameRoute = 1003 // Game -MapRoute = 1004 // Map -RoomRoute = 1005 // Room \ No newline at end of file +MapRoute = 1004 // 地图 \ No newline at end of file diff --git a/Entity/Entity.csproj b/Entity/Entity.csproj index 6f1d222..f0bf372 100644 --- a/Entity/Entity.csproj +++ b/Entity/Entity.csproj @@ -29,9 +29,9 @@ + - diff --git a/Entity/Gate/GateUnit.cs b/Entity/Gate/GateUnit.cs index 03529de..a37b9c6 100644 --- a/Entity/Gate/GateUnit.cs +++ b/Entity/Gate/GateUnit.cs @@ -8,7 +8,6 @@ public class GateUnit : Entity public bool Kick; public long AccountID; public int Region; - public long GameSceneRouteId; - public long ChatSceneRouteId; + public Dictionary SceneRoutes = new Dictionary(); public EntityReference Session; } \ No newline at end of file diff --git a/Entity/Generate/NetworkProtocol/Account.cs b/Entity/Generate/NetworkProtocol/CommonProtoData.cs similarity index 100% rename from Entity/Generate/NetworkProtocol/Account.cs rename to Entity/Generate/NetworkProtocol/CommonProtoData.cs diff --git a/Entity/Generate/NetworkProtocol/GameMessage.cs b/Entity/Generate/NetworkProtocol/GameMessage.cs new file mode 100644 index 0000000..9c9cb9b --- /dev/null +++ b/Entity/Generate/NetworkProtocol/GameMessage.cs @@ -0,0 +1,185 @@ +using ProtoBuf; + +using System.Collections.Generic; +using MongoDB.Bson.Serialization.Attributes; +using Fantasy; +using Fantasy.Network.Interface; +using Fantasy.Serialize; +// ReSharper disable InconsistentNaming +// ReSharper disable RedundantUsingDirective +// ReSharper disable RedundantOverriddenMember +// ReSharper disable PartialTypeWithSinglePart +// ReSharper disable UnusedAutoPropertyAccessor.Global +// ReSharper disable MemberCanBePrivate.Global +// ReSharper disable CheckNamespace +#pragma warning disable CS8625 // Cannot convert null literal to non-nullable reference type. +#pragma warning disable CS8618 + +namespace Fantasy +{ + /// + /// 请求创建房间 + /// + [ProtoContract] + public partial class C2Game_CreateRoomRequest : AMessage, ICustomRouteRequest, IProto + { + public static C2Game_CreateRoomRequest Create(Scene scene) + { + return scene.MessagePoolComponent.Rent(); + } + public override void Dispose() + { + MapId = default; + Password = default; +#if FANTASY_NET || FANTASY_UNITY + GetScene().MessagePoolComponent.Return(this); +#endif + } + [ProtoIgnore] + public Game2C_CreateRoomResponse ResponseType { get; set; } + public uint OpCode() { return OuterOpcode.C2Game_CreateRoomRequest; } + [ProtoIgnore] + public int RouteType => Fantasy.RouteType.MapRoute; + [ProtoMember(1)] + public int MapId { get; set; } + [ProtoMember(2)] + public string Password { get; set; } + } + /// + /// 请求创建房间成功 + /// + [ProtoContract] + public partial class Game2C_CreateRoomResponse : AMessage, ICustomRouteResponse, IProto + { + public static Game2C_CreateRoomResponse Create(Scene scene) + { + return scene.MessagePoolComponent.Rent(); + } + public override void Dispose() + { + ErrorCode = default; + MapId = default; + RoomId = default; +#if FANTASY_NET || FANTASY_UNITY + GetScene().MessagePoolComponent.Return(this); +#endif + } + public uint OpCode() { return OuterOpcode.Game2C_CreateRoomResponse; } + [ProtoMember(1)] + public int MapId { get; set; } + [ProtoMember(2)] + public long RoomId { get; set; } + [ProtoMember(3)] + public uint ErrorCode { get; set; } + } + /// + /// 请求进入地图 + /// + [ProtoContract] + public partial class C2Game_EnterMapRequest : AMessage, ICustomRouteRequest, IProto + { + public static C2Game_EnterMapRequest Create(Scene scene) + { + return scene.MessagePoolComponent.Rent(); + } + public override void Dispose() + { + MapId = default; + Type = default; +#if FANTASY_NET || FANTASY_UNITY + GetScene().MessagePoolComponent.Return(this); +#endif + } + [ProtoIgnore] + public Game2C_EnterMapResponse ResponseType { get; set; } + public uint OpCode() { return OuterOpcode.C2Game_EnterMapRequest; } + [ProtoIgnore] + public int RouteType => Fantasy.RouteType.MapRoute; + [ProtoMember(1)] + public int MapId { get; set; } + [ProtoMember(2)] + public int Type { get; set; } + } + /// + /// 请求进入地图响应 + /// + [ProtoContract] + public partial class Game2C_EnterMapResponse : AMessage, ICustomRouteResponse, IProto + { + public static Game2C_EnterMapResponse Create(Scene scene) + { + return scene.MessagePoolComponent.Rent(); + } + public override void Dispose() + { + ErrorCode = default; + MapId = default; + Pos = default; +#if FANTASY_NET || FANTASY_UNITY + GetScene().MessagePoolComponent.Return(this); +#endif + } + public uint OpCode() { return OuterOpcode.Game2C_EnterMapResponse; } + [ProtoMember(1)] + public int MapId { get; set; } + [ProtoMember(2)] + public int Pos { get; set; } + [ProtoMember(3)] + public uint ErrorCode { get; set; } + } + /// + /// 请求进入房间 + /// + [ProtoContract] + public partial class C2Game_EnterRoomRequest : AMessage, ICustomRouteRequest, IProto + { + public static C2Game_EnterRoomRequest Create(Scene scene) + { + return scene.MessagePoolComponent.Rent(); + } + public override void Dispose() + { + MapId = default; + Password = default; +#if FANTASY_NET || FANTASY_UNITY + GetScene().MessagePoolComponent.Return(this); +#endif + } + [ProtoIgnore] + public Game2C_EnterRoomResponse ResponseType { get; set; } + public uint OpCode() { return OuterOpcode.C2Game_EnterRoomRequest; } + [ProtoIgnore] + public int RouteType => Fantasy.RouteType.MapRoute; + [ProtoMember(1)] + public int MapId { get; set; } + [ProtoMember(2)] + public string Password { get; set; } + } + /// + /// 请求进入房间响应 + /// + [ProtoContract] + public partial class Game2C_EnterRoomResponse : AMessage, ICustomRouteResponse, IProto + { + public static Game2C_EnterRoomResponse Create(Scene scene) + { + return scene.MessagePoolComponent.Rent(); + } + public override void Dispose() + { + ErrorCode = default; + MapId = default; + RoomId = default; +#if FANTASY_NET || FANTASY_UNITY + GetScene().MessagePoolComponent.Return(this); +#endif + } + public uint OpCode() { return OuterOpcode.Game2C_EnterRoomResponse; } + [ProtoMember(1)] + public int MapId { get; set; } + [ProtoMember(2)] + public long RoomId { get; set; } + [ProtoMember(3)] + public uint ErrorCode { get; set; } + } +} diff --git a/Entity/Generate/NetworkProtocol/InnerMessage.cs b/Entity/Generate/NetworkProtocol/InnerMessage.cs index 07bdcae..e5f64b7 100644 --- a/Entity/Generate/NetworkProtocol/InnerMessage.cs +++ b/Entity/Generate/NetworkProtocol/InnerMessage.cs @@ -21,90 +21,93 @@ namespace Fantasy /// 通知游戏服角色进入该游戏服 /// [ProtoContract] - public partial class G2Game_EnterRequest : AMessage, IRouteRequest, IProto + public partial class G2Common_EnterRequest : AMessage, IRouteRequest, IProto { - public static G2Game_EnterRequest Create(Scene scene) + public static G2Common_EnterRequest Create(Scene scene) { - return scene.MessagePoolComponent.Rent(); + return scene.MessagePoolComponent.Rent(); } public override void Dispose() { AccountId = default; GateRouteId = default; + RouteType = default; #if FANTASY_NET || FANTASY_UNITY - GetScene().MessagePoolComponent.Return(this); + GetScene().MessagePoolComponent.Return(this); #endif } [ProtoIgnore] - public Game2G_EnterResponse ResponseType { get; set; } - public uint OpCode() { return InnerOpcode.G2Game_EnterRequest; } + public G2Common_EnterResponse ResponseType { get; set; } + public uint OpCode() { return InnerOpcode.G2Common_EnterRequest; } [ProtoMember(1)] public long AccountId { get; set; } [ProtoMember(2)] public long GateRouteId { get; set; } + [ProtoMember(3)] + public int RouteType { get; set; } } [ProtoContract] - public partial class Game2G_EnterResponse : AMessage, IRouteResponse, IProto + public partial class G2Common_EnterResponse : AMessage, IRouteResponse, IProto { - public static Game2G_EnterResponse Create(Scene scene) + public static G2Common_EnterResponse Create(Scene scene) { - return scene.MessagePoolComponent.Rent(); + return scene.MessagePoolComponent.Rent(); } public override void Dispose() { ErrorCode = default; RoleRouteId = default; - RoleInfo = default; + RouteType = default; #if FANTASY_NET || FANTASY_UNITY - GetScene().MessagePoolComponent.Return(this); + GetScene().MessagePoolComponent.Return(this); #endif } - public uint OpCode() { return InnerOpcode.Game2G_EnterResponse; } + public uint OpCode() { return InnerOpcode.G2Common_EnterResponse; } [ProtoMember(1)] public long RoleRouteId { get; set; } [ProtoMember(2)] - public RoleSimpleInfo RoleInfo { get; set; } + public int RouteType { get; set; } [ProtoMember(3)] public uint ErrorCode { get; set; } } [ProtoContract] - public partial class G2Game_ExitRequest : AMessage, IRouteRequest, IProto + public partial class G2Common_ExitRequest : AMessage, IRouteRequest, IProto { - public static G2Game_ExitRequest Create(Scene scene) + public static G2Common_ExitRequest Create(Scene scene) { - return scene.MessagePoolComponent.Rent(); + return scene.MessagePoolComponent.Rent(); } public override void Dispose() { AccountId = default; GateRouteId = default; #if FANTASY_NET || FANTASY_UNITY - GetScene().MessagePoolComponent.Return(this); + GetScene().MessagePoolComponent.Return(this); #endif } [ProtoIgnore] - public Game2G_ExitResponse ResponseType { get; set; } - public uint OpCode() { return InnerOpcode.G2Game_ExitRequest; } + public Common2G_ExitResponse ResponseType { get; set; } + public uint OpCode() { return InnerOpcode.G2Common_ExitRequest; } [ProtoMember(1)] public long AccountId { get; set; } [ProtoMember(2)] public long GateRouteId { get; set; } } [ProtoContract] - public partial class Game2G_ExitResponse : AMessage, IRouteResponse, IProto + public partial class Common2G_ExitResponse : AMessage, IRouteResponse, IProto { - public static Game2G_ExitResponse Create(Scene scene) + public static Common2G_ExitResponse Create(Scene scene) { - return scene.MessagePoolComponent.Rent(); + return scene.MessagePoolComponent.Rent(); } public override void Dispose() { ErrorCode = default; #if FANTASY_NET || FANTASY_UNITY - GetScene().MessagePoolComponent.Return(this); + GetScene().MessagePoolComponent.Return(this); #endif } - public uint OpCode() { return InnerOpcode.Game2G_ExitResponse; } + public uint OpCode() { return InnerOpcode.Common2G_ExitResponse; } [ProtoMember(1)] public uint ErrorCode { get; set; } } @@ -155,94 +158,6 @@ namespace Fantasy [ProtoMember(2)] public uint ErrorCode { get; set; } } - /// - /// 通知游戏服角色进入该聊天服 - /// - [ProtoContract] - public partial class G2S_EnterRequest : AMessage, IRouteRequest, IProto - { - public static G2S_EnterRequest Create(Scene scene) - { - return scene.MessagePoolComponent.Rent(); - } - public override void Dispose() - { - Role = default; - GateRouteId = default; -#if FANTASY_NET || FANTASY_UNITY - GetScene().MessagePoolComponent.Return(this); -#endif - } - [ProtoIgnore] - public S2G_EnterResponse ResponseType { get; set; } - public uint OpCode() { return InnerOpcode.G2S_EnterRequest; } - [ProtoMember(1)] - public RoleSimpleInfo Role { get; set; } - [ProtoMember(2)] - public long GateRouteId { get; set; } - } - [ProtoContract] - public partial class S2G_EnterResponse : AMessage, IRouteResponse, IProto - { - public static S2G_EnterResponse Create(Scene scene) - { - return scene.MessagePoolComponent.Rent(); - } - public override void Dispose() - { - ErrorCode = default; - RoleRouteId = default; -#if FANTASY_NET || FANTASY_UNITY - GetScene().MessagePoolComponent.Return(this); -#endif - } - public uint OpCode() { return InnerOpcode.S2G_EnterResponse; } - [ProtoMember(1)] - public long RoleRouteId { get; set; } - [ProtoMember(2)] - public uint ErrorCode { get; set; } - } - [ProtoContract] - public partial class G2S_ExitRequest : AMessage, IRouteRequest, IProto - { - public static G2S_ExitRequest Create(Scene scene) - { - return scene.MessagePoolComponent.Rent(); - } - public override void Dispose() - { - AccountId = default; - GateRouteId = default; -#if FANTASY_NET || FANTASY_UNITY - GetScene().MessagePoolComponent.Return(this); -#endif - } - [ProtoIgnore] - public S2G_ExitResponse ResponseType { get; set; } - public uint OpCode() { return InnerOpcode.G2S_ExitRequest; } - [ProtoMember(1)] - public long AccountId { get; set; } - [ProtoMember(2)] - public long GateRouteId { get; set; } - } - [ProtoContract] - public partial class S2G_ExitResponse : AMessage, IRouteResponse, IProto - { - public static S2G_ExitResponse 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.S2G_ExitResponse; } - [ProtoMember(1)] - public uint ErrorCode { get; set; } - } [ProtoContract] public partial class S2G_ChatMessage : AMessage, IRouteMessage, IProto { diff --git a/Entity/Generate/NetworkProtocol/InnerOpcode.cs b/Entity/Generate/NetworkProtocol/InnerOpcode.cs index 96c73a4..095a392 100644 --- a/Entity/Generate/NetworkProtocol/InnerOpcode.cs +++ b/Entity/Generate/NetworkProtocol/InnerOpcode.cs @@ -2,16 +2,12 @@ namespace Fantasy { public static partial class InnerOpcode { - public const uint G2Game_EnterRequest = 1073751825; - public const uint Game2G_EnterResponse = 1207969553; - public const uint G2Game_ExitRequest = 1073751826; - public const uint Game2G_ExitResponse = 1207969554; + public const uint G2Common_EnterRequest = 1073751825; + public const uint G2Common_EnterResponse = 1207969553; + public const uint G2Common_ExitRequest = 1073751826; + public const uint Common2G_ExitResponse = 1207969554; public const uint S2G_GetPlayerBasicInfoRequest = 1073751827; public const uint G2S_GetPlayerBasicInfoResponse = 1207969555; - public const uint G2S_EnterRequest = 1073751828; - public const uint S2G_EnterResponse = 1207969556; - public const uint G2S_ExitRequest = 1073751829; - public const uint S2G_ExitResponse = 1207969557; public const uint S2G_ChatMessage = 939534097; public const uint Club2Chat_CreateChannel = 939534098; } diff --git a/Entity/Generate/NetworkProtocol/MapMessage.cs b/Entity/Generate/NetworkProtocol/MapMessage.cs index c33e04d..c4f45da 100644 --- a/Entity/Generate/NetworkProtocol/MapMessage.cs +++ b/Entity/Generate/NetworkProtocol/MapMessage.cs @@ -17,486 +17,4 @@ using Fantasy.Serialize; namespace Fantasy { - [ProtoContract] - public partial class UnitGearItemInfo : AMessage, IProto - { - public static UnitGearItemInfo Create(Scene scene) - { - return scene.MessagePoolComponent.Rent(); - } - public override void Dispose() - { - Id = default; - ConfigId = default; -#if FANTASY_NET || FANTASY_UNITY - GetScene().MessagePoolComponent.Return(this); -#endif - } - [ProtoMember(1)] - public long Id { get; set; } - [ProtoMember(2)] - public int ConfigId { get; set; } - } - [ProtoContract] - public partial class UnitGearInfo : AMessage, IProto - { - public static UnitGearInfo Create(Scene scene) - { - return scene.MessagePoolComponent.Rent(); - } - public override void Dispose() - { - Rod = default; - Reel = default; - Bobber = default; - Hook = default; - Bait = default; - Lure = default; - Weight = default; - Line = default; - Leader = default; - Feeder = default; -#if FANTASY_NET || FANTASY_UNITY - GetScene().MessagePoolComponent.Return(this); -#endif - } - [ProtoMember(1)] - public UnitGearItemInfo Rod { get; set; } - [ProtoMember(2)] - public UnitGearItemInfo Reel { get; set; } - [ProtoMember(3)] - public UnitGearItemInfo Bobber { get; set; } - [ProtoMember(4)] - public UnitGearItemInfo Hook { get; set; } - [ProtoMember(5)] - public UnitGearItemInfo Bait { get; set; } - [ProtoMember(6)] - public UnitGearItemInfo Lure { get; set; } - [ProtoMember(7)] - public UnitGearItemInfo Weight { get; set; } - [ProtoMember(8)] - public UnitGearItemInfo Line { get; set; } - [ProtoMember(9)] - public UnitGearItemInfo Leader { get; set; } - [ProtoMember(10)] - public UnitGearItemInfo Feeder { get; set; } - } - [ProtoContract] - public partial class Vector3Info : AMessage, IProto - { - public static Vector3Info Create(Scene scene) - { - return scene.MessagePoolComponent.Rent(); - } - public override void Dispose() - { - x = default; - y = default; - z = default; -#if FANTASY_NET || FANTASY_UNITY - GetScene().MessagePoolComponent.Return(this); -#endif - } - [ProtoMember(1)] - public float x { get; set; } - [ProtoMember(2)] - public float y { get; set; } - [ProtoMember(3)] - public float z { get; set; } - } - [ProtoContract] - public partial class QuaternionInfo : AMessage, IProto - { - public static QuaternionInfo Create(Scene scene) - { - return scene.MessagePoolComponent.Rent(); - } - public override void Dispose() - { - x = default; - y = default; - z = default; - w = default; -#if FANTASY_NET || FANTASY_UNITY - GetScene().MessagePoolComponent.Return(this); -#endif - } - [ProtoMember(1)] - public float x { get; set; } - [ProtoMember(2)] - public float y { get; set; } - [ProtoMember(3)] - public float z { get; set; } - [ProtoMember(4)] - public float w { get; set; } - } - [ProtoContract] - public partial class UnitFishingInfo : AMessage, IProto - { - public static UnitFishingInfo Create(Scene scene) - { - return scene.MessagePoolComponent.Rent(); - } - public override void Dispose() - { - LineLength = default; - ReelSpeed = default; - OpenLight = default; - RodSetting = default; -#if FANTASY_NET || FANTASY_UNITY - GetScene().MessagePoolComponent.Return(this); -#endif - } - [ProtoMember(1)] - public float LineLength { get; set; } - [ProtoMember(2)] - public float ReelSpeed { get; set; } - [ProtoMember(3)] - public bool OpenLight { get; set; } - [ProtoMember(4)] - public int RodSetting { get; set; } - } - [ProtoContract] - public partial class UnitStateInfo : AMessage, IProto - { - public static UnitStateInfo Create(Scene scene) - { - return scene.MessagePoolComponent.Rent(); - } - public override void Dispose() - { - State = default; - Args.Clear(); -#if FANTASY_NET || FANTASY_UNITY - GetScene().MessagePoolComponent.Return(this); -#endif - } - [ProtoMember(1)] - public int State { get; set; } - [ProtoMember(2)] - public List Args = new List(); - } - [ProtoContract] - public partial class MapUnitInfo : AMessage, IProto - { - public static MapUnitInfo Create(Scene scene) - { - return scene.MessagePoolComponent.Rent(); - } - public override void Dispose() - { - Id = default; - RoleInfo = default; - Location = default; - State = default; - Gears = default; - FishingInfo = default; - KV.Clear(); -#if FANTASY_NET || FANTASY_UNITY - GetScene().MessagePoolComponent.Return(this); -#endif - } - [ProtoMember(1)] - public long Id { get; set; } - [ProtoMember(2)] - public RoleSimpleInfo RoleInfo { get; set; } - [ProtoMember(3)] - public MapUnitPositionInfo Location { get; set; } - [ProtoMember(4)] - public UnitStateInfo State { get; set; } - [ProtoMember(5)] - public UnitGearInfo Gears { get; set; } - [ProtoMember(6)] - public UnitFishingInfo FishingInfo { get; set; } - [ProtoMember(7)] - public List KV = new List(); - } - [ProtoContract] - public partial class MapUnitPositionInfo : AMessage, IProto - { - public static MapUnitPositionInfo Create(Scene scene) - { - return scene.MessagePoolComponent.Rent(); - } - public override void Dispose() - { - Position = default; - Rotation = default; -#if FANTASY_NET || FANTASY_UNITY - GetScene().MessagePoolComponent.Return(this); -#endif - } - [ProtoMember(1)] - public Vector3Info Position { get; set; } - [ProtoMember(2)] - public QuaternionInfo Rotation { get; set; } - } - [ProtoContract] - public partial class C2Map_CreateRoomRequest : AMessage, ICustomRouteRequest, IProto - { - public static C2Map_CreateRoomRequest Create(Scene scene) - { - return scene.MessagePoolComponent.Rent(); - } - public override void Dispose() - { - MapId = default; - Password = default; -#if FANTASY_NET || FANTASY_UNITY - GetScene().MessagePoolComponent.Return(this); -#endif - } - [ProtoIgnore] - public Map2C_CreateRoomResponse ResponseType { get; set; } - public uint OpCode() { return OuterOpcode.C2Map_CreateRoomRequest; } - [ProtoIgnore] - public int RouteType => Fantasy.RouteType.MapRoute; - [ProtoMember(1)] - public int MapId { get; set; } - [ProtoMember(2)] - public string Password { get; set; } - } - [ProtoContract] - public partial class Map2C_CreateRoomResponse : AMessage, ICustomRouteResponse, IProto - { - public static Map2C_CreateRoomResponse Create(Scene scene) - { - return scene.MessagePoolComponent.Rent(); - } - public override void Dispose() - { - ErrorCode = default; - MapId = default; - RoomId = default; -#if FANTASY_NET || FANTASY_UNITY - GetScene().MessagePoolComponent.Return(this); -#endif - } - public uint OpCode() { return OuterOpcode.Map2C_CreateRoomResponse; } - [ProtoMember(1)] - public int MapId { get; set; } - [ProtoMember(2)] - public long RoomId { get; set; } - [ProtoMember(3)] - public uint ErrorCode { get; set; } - } - [ProtoContract] - public partial class C2Map_EnterMapRequest : AMessage, ICustomRouteRequest, IProto - { - public static C2Map_EnterMapRequest Create(Scene scene) - { - return scene.MessagePoolComponent.Rent(); - } - public override void Dispose() - { - MapId = default; - RoomId = default; -#if FANTASY_NET || FANTASY_UNITY - GetScene().MessagePoolComponent.Return(this); -#endif - } - [ProtoIgnore] - public Map2C_EnterMapResponse ResponseType { get; set; } - public uint OpCode() { return OuterOpcode.C2Map_EnterMapRequest; } - [ProtoIgnore] - public int RouteType => Fantasy.RouteType.MapRoute; - [ProtoMember(1)] - public int MapId { get; set; } - [ProtoMember(2)] - public long RoomId { get; set; } - } - [ProtoContract] - public partial class Map2C_EnterMapResponse : AMessage, ICustomRouteResponse, IProto - { - public static Map2C_EnterMapResponse Create(Scene scene) - { - return scene.MessagePoolComponent.Rent(); - } - public override void Dispose() - { - ErrorCode = default; - Roles.Clear(); - MapId = default; -#if FANTASY_NET || FANTASY_UNITY - GetScene().MessagePoolComponent.Return(this); -#endif - } - public uint OpCode() { return OuterOpcode.Map2C_EnterMapResponse; } - [ProtoMember(1)] - public List Roles = new List(); - [ProtoMember(2)] - public long MapId { get; set; } - [ProtoMember(3)] - public uint ErrorCode { get; set; } - } - [ProtoContract] - public partial class C2Map_Move : AMessage, ICustomRouteMessage, IProto - { - public static C2Map_Move Create(Scene scene) - { - return scene.MessagePoolComponent.Rent(); - } - public override void Dispose() - { - Location = default; - IsStop = default; -#if FANTASY_NET || FANTASY_UNITY - GetScene().MessagePoolComponent.Return(this); -#endif - } - public uint OpCode() { return OuterOpcode.C2Map_Move; } - [ProtoIgnore] - public int RouteType => Fantasy.RouteType.MapRoute; - [ProtoMember(1)] - public MapUnitPositionInfo Location { get; set; } - [ProtoMember(2)] - public bool IsStop { get; set; } - } - /// - /// 用户进入地图 - /// - [ProtoContract] - public partial class Map2C_RoleEnterMapNotify : AMessage, ICustomRouteMessage, IProto - { - public static Map2C_RoleEnterMapNotify Create(Scene scene) - { - return scene.MessagePoolComponent.Rent(); - } - public override void Dispose() - { - Info = default; -#if FANTASY_NET || FANTASY_UNITY - GetScene().MessagePoolComponent.Return(this); -#endif - } - public uint OpCode() { return OuterOpcode.Map2C_RoleEnterMapNotify; } - [ProtoIgnore] - public int RouteType => Fantasy.RouteType.MapRoute; - [ProtoMember(1)] - public MapUnitInfo Info { get; set; } - } - /// - /// 用户离开地图 - /// - [ProtoContract] - public partial class Map2C_RoleExitMapNotify : AMessage, ICustomRouteMessage, IProto - { - public static Map2C_RoleExitMapNotify Create(Scene scene) - { - return scene.MessagePoolComponent.Rent(); - } - public override void Dispose() - { - Id = default; -#if FANTASY_NET || FANTASY_UNITY - GetScene().MessagePoolComponent.Return(this); -#endif - } - public uint OpCode() { return OuterOpcode.Map2C_RoleExitMapNotify; } - [ProtoIgnore] - public int RouteType => Fantasy.RouteType.MapRoute; - [ProtoMember(1)] - public long Id { get; set; } - } - /// - /// 玩家状态变化同步 - /// - [ProtoContract] - public partial class Map2C_RoleStateNotify : AMessage, ICustomRouteMessage, IProto - { - public static Map2C_RoleStateNotify Create(Scene scene) - { - return scene.MessagePoolComponent.Rent(); - } - public override void Dispose() - { - Id = default; - State = default; -#if FANTASY_NET || FANTASY_UNITY - GetScene().MessagePoolComponent.Return(this); -#endif - } - public uint OpCode() { return OuterOpcode.Map2C_RoleStateNotify; } - [ProtoIgnore] - public int RouteType => Fantasy.RouteType.MapRoute; - [ProtoMember(1)] - public long Id { get; set; } - [ProtoMember(2)] - public UnitStateInfo State { get; set; } - } - /// - /// 玩家钓组状态变化 - /// - [ProtoContract] - public partial class Map2C_RoleGearStateNotify : AMessage, ICustomRouteMessage, IProto - { - public static Map2C_RoleGearStateNotify Create(Scene scene) - { - return scene.MessagePoolComponent.Rent(); - } - public override void Dispose() - { - Id = default; - State = default; -#if FANTASY_NET || FANTASY_UNITY - GetScene().MessagePoolComponent.Return(this); -#endif - } - public uint OpCode() { return OuterOpcode.Map2C_RoleGearStateNotify; } - [ProtoIgnore] - public int RouteType => Fantasy.RouteType.MapRoute; - [ProtoMember(1)] - public long Id { get; set; } - [ProtoMember(2)] - public UnitFishingInfo State { get; set; } - } - /// - /// 玩家钓组变化 - /// - [ProtoContract] - public partial class Map2C_RoleGearChangeNotify : AMessage, ICustomRouteMessage, IProto - { - public static Map2C_RoleGearChangeNotify Create(Scene scene) - { - return scene.MessagePoolComponent.Rent(); - } - public override void Dispose() - { - Id = default; - Gears = default; -#if FANTASY_NET || FANTASY_UNITY - GetScene().MessagePoolComponent.Return(this); -#endif - } - public uint OpCode() { return OuterOpcode.Map2C_RoleGearChangeNotify; } - [ProtoIgnore] - public int RouteType => Fantasy.RouteType.MapRoute; - [ProtoMember(1)] - public long Id { get; set; } - [ProtoMember(2)] - public UnitGearInfo Gears { get; set; } - } - /// - /// 玩家位置变化 - /// - [ProtoContract] - public partial class Map2C_MoveNotify : AMessage, IProto - { - public static Map2C_MoveNotify Create(Scene scene) - { - return scene.MessagePoolComponent.Rent(); - } - public override void Dispose() - { - Id = default; - Location = default; -#if FANTASY_NET || FANTASY_UNITY - GetScene().MessagePoolComponent.Return(this); -#endif - } - [ProtoMember(1)] - public long Id { get; set; } - [ProtoMember(2)] - public MapUnitPositionInfo Location { get; set; } - } } diff --git a/Entity/Generate/NetworkProtocol/OuterMessage.cs b/Entity/Generate/NetworkProtocol/OuterMessage.cs index cb9c2d8..18d4604 100644 --- a/Entity/Generate/NetworkProtocol/OuterMessage.cs +++ b/Entity/Generate/NetworkProtocol/OuterMessage.cs @@ -112,6 +112,50 @@ namespace Fantasy public uint ErrorCode { get; set; } } /// + /// 客户端登陆聊天服 + /// + [ProtoContract] + public partial class C2G_LoginChatRequest : AMessage, IProto + { + public static C2G_LoginChatRequest Create(Scene scene) + { + return scene.MessagePoolComponent.Rent(); + } + public override void Dispose() + { + Type = default; +#if FANTASY_NET || FANTASY_UNITY + GetScene().MessagePoolComponent.Return(this); +#endif + } + [ProtoMember(1)] + public int Type { get; set; } + } + /// + /// 客户端登陆聊天服响应 + /// + [ProtoContract] + public partial class G2C_LoginChatResponse : AMessage, IResponse, IProto + { + public static G2C_LoginChatResponse Create(Scene scene) + { + return scene.MessagePoolComponent.Rent(); + } + public override void Dispose() + { + ErrorCode = default; + RouteId = default; +#if FANTASY_NET || FANTASY_UNITY + GetScene().MessagePoolComponent.Return(this); +#endif + } + public uint OpCode() { return OuterOpcode.G2C_LoginChatResponse; } + [ProtoMember(1)] + public long RouteId { get; set; } + [ProtoMember(2)] + public uint ErrorCode { get; set; } + } + /// /// 通知客户端重复登录 /// [ProtoContract] diff --git a/Entity/Generate/NetworkProtocol/OuterOpcode.cs b/Entity/Generate/NetworkProtocol/OuterOpcode.cs index 9fc7539..425911b 100644 --- a/Entity/Generate/NetworkProtocol/OuterOpcode.cs +++ b/Entity/Generate/NetworkProtocol/OuterOpcode.cs @@ -2,54 +2,61 @@ namespace Fantasy { public static partial class OuterOpcode { - public const uint C2Map_CreateRoomRequest = 2281711377; - public const uint Map2C_CreateRoomResponse = 2415929105; - public const uint C2Map_EnterMapRequest = 2281711378; - public const uint Map2C_EnterMapResponse = 2415929106; + public const uint C2Game_CreateRoomRequest = 2281711377; + public const uint Game2C_CreateRoomResponse = 2415929105; + public const uint C2Game_EnterMapRequest = 2281711378; + public const uint Game2C_EnterMapResponse = 2415929106; + public const uint C2Game_EnterRoomRequest = 2281711379; + public const uint Game2C_EnterRoomResponse = 2415929107; + public const uint C2A_LoginRequest = 268445457; + public const uint A2C_LoginResponse = 402663185; + public const uint C2G_LoginRequest = 268445458; + public const uint G2C_LoginResponse = 402663186; + public const uint G2C_LoginChatResponse = 402663187; + public const uint G2C_RepeatLogin = 134227729; + public const uint C2Game_GetRoleInfoRequest = 2281711380; + public const uint Game2C_GetRoleInfoResponse = 2415929108; + public const uint C2Map_EnterRoomRequest = 2281711381; + public const uint Map2C_EnterRoomResponse = 2415929109; + public const uint C2Map_EnterMapRequest = 2281711382; + public const uint Map2C_EnterMapResponse = 2415929110; public const uint C2Map_Move = 2147493649; public const uint Map2C_RoleEnterMapNotify = 2147493650; public const uint Map2C_RoleExitMapNotify = 2147493651; public const uint Map2C_RoleStateNotify = 2147493652; public const uint Map2C_RoleGearStateNotify = 2147493653; public const uint Map2C_RoleGearChangeNotify = 2147493654; - public const uint C2A_LoginRequest = 268445457; - public const uint A2C_LoginResponse = 402663185; - public const uint C2G_LoginRequest = 268445458; - public const uint G2C_LoginResponse = 402663186; - public const uint G2C_RepeatLogin = 134227729; - public const uint C2Game_GetRoleInfoRequest = 2281711379; - public const uint Game2C_GetRoleInfoResponse = 2415929107; - public const uint C2S_GetConversationsRequest = 2281711380; - public const uint S2C_GetConversationsResponse = 2415929108; - public const uint C2S_SendMailRequest = 2281711381; - public const uint S2C_SendMailResponse = 2415929109; - public const uint C2S_DeleteMailRequest = 2281711382; - public const uint S2C_DeleteMailResponse = 2415929110; + public const uint C2S_GetConversationsRequest = 2281711383; + public const uint S2C_GetConversationsResponse = 2415929111; + public const uint C2S_SendMailRequest = 2281711384; + public const uint S2C_SendMailResponse = 2415929112; + public const uint C2S_DeleteMailRequest = 2281711385; + public const uint S2C_DeleteMailResponse = 2415929113; public const uint S2C_HaveMail = 2147493655; public const uint S2C_MailState = 2147493656; - public const uint C2S_CreateChannelRequest = 2281711383; - public const uint S2C_CreateChannelResponse = 2415929111; - public const uint C2S_JoinChannelRequest = 2281711384; - public const uint S2C_JoinChannelResponse = 2415929112; - public const uint C2S_SendMessageRequest = 2281711385; - public const uint S2C_SendMessageResponse = 2415929113; + public const uint C2S_CreateChannelRequest = 2281711386; + public const uint S2C_CreateChannelResponse = 2415929114; + public const uint C2S_JoinChannelRequest = 2281711387; + public const uint S2C_JoinChannelResponse = 2415929115; + public const uint C2S_SendMessageRequest = 2281711388; + public const uint S2C_SendMessageResponse = 2415929116; public const uint S2C_Message = 2147493657; - public const uint C2S_CreateClubRequest = 2281711386; - public const uint S2C_CreateClubResponse = 2415929114; - public const uint C2S_GetClubInfoRequest = 2281711387; - public const uint S2C_GetClubInfoResponse = 2415929115; - public const uint C2S_GetMemberListRequest = 2281711388; - public const uint S2C_GetMemberListResponse = 2415929116; - public const uint C2S_GetClubListRequest = 2281711389; - public const uint S2C_GetClubListResponse = 2415929117; - public const uint C2S_JoinClubRequest = 2281711390; - public const uint S2C_JoinClubResponse = 2415929118; - public const uint C2S_LeaveClubRequest = 2281711391; - public const uint S2C_LeaveClubResponse = 2415929119; - public const uint C2S_DissolveClubRequest = 2281711392; - public const uint S2C_DissolveClubResponse = 2415929120; - public const uint C2S_DisposeJoinRequest = 2281711393; - public const uint S2C_DisposeJoinResponse = 2415929121; + public const uint C2S_CreateClubRequest = 2281711389; + public const uint S2C_CreateClubResponse = 2415929117; + public const uint C2S_GetClubInfoRequest = 2281711390; + public const uint S2C_GetClubInfoResponse = 2415929118; + public const uint C2S_GetMemberListRequest = 2281711391; + public const uint S2C_GetMemberListResponse = 2415929119; + public const uint C2S_GetClubListRequest = 2281711392; + public const uint S2C_GetClubListResponse = 2415929120; + public const uint C2S_JoinClubRequest = 2281711393; + public const uint S2C_JoinClubResponse = 2415929121; + public const uint C2S_LeaveClubRequest = 2281711394; + public const uint S2C_LeaveClubResponse = 2415929122; + public const uint C2S_DissolveClubRequest = 2281711395; + public const uint S2C_DissolveClubResponse = 2415929123; + public const uint C2S_DisposeJoinRequest = 2281711396; + public const uint S2C_DisposeJoinResponse = 2415929124; public const uint S2C_ClubChange = 2147493658; } } diff --git a/Entity/Generate/NetworkProtocol/RoomMessage.cs b/Entity/Generate/NetworkProtocol/RoomMessage.cs new file mode 100644 index 0000000..c3d09da --- /dev/null +++ b/Entity/Generate/NetworkProtocol/RoomMessage.cs @@ -0,0 +1,502 @@ +using ProtoBuf; + +using System.Collections.Generic; +using MongoDB.Bson.Serialization.Attributes; +using Fantasy; +using Fantasy.Network.Interface; +using Fantasy.Serialize; +// ReSharper disable InconsistentNaming +// ReSharper disable RedundantUsingDirective +// ReSharper disable RedundantOverriddenMember +// ReSharper disable PartialTypeWithSinglePart +// ReSharper disable UnusedAutoPropertyAccessor.Global +// ReSharper disable MemberCanBePrivate.Global +// ReSharper disable CheckNamespace +#pragma warning disable CS8625 // Cannot convert null literal to non-nullable reference type. +#pragma warning disable CS8618 + +namespace Fantasy +{ + [ProtoContract] + public partial class UnitGearItemInfo : AMessage, IProto + { + public static UnitGearItemInfo Create(Scene scene) + { + return scene.MessagePoolComponent.Rent(); + } + public override void Dispose() + { + Id = default; + ConfigId = default; +#if FANTASY_NET || FANTASY_UNITY + GetScene().MessagePoolComponent.Return(this); +#endif + } + [ProtoMember(1)] + public long Id { get; set; } + [ProtoMember(2)] + public int ConfigId { get; set; } + } + [ProtoContract] + public partial class UnitGearInfo : AMessage, IProto + { + public static UnitGearInfo Create(Scene scene) + { + return scene.MessagePoolComponent.Rent(); + } + public override void Dispose() + { + Rod = default; + Reel = default; + Bobber = default; + Hook = default; + Bait = default; + Lure = default; + Weight = default; + Line = default; + Leader = default; + Feeder = default; +#if FANTASY_NET || FANTASY_UNITY + GetScene().MessagePoolComponent.Return(this); +#endif + } + [ProtoMember(1)] + public UnitGearItemInfo Rod { get; set; } + [ProtoMember(2)] + public UnitGearItemInfo Reel { get; set; } + [ProtoMember(3)] + public UnitGearItemInfo Bobber { get; set; } + [ProtoMember(4)] + public UnitGearItemInfo Hook { get; set; } + [ProtoMember(5)] + public UnitGearItemInfo Bait { get; set; } + [ProtoMember(6)] + public UnitGearItemInfo Lure { get; set; } + [ProtoMember(7)] + public UnitGearItemInfo Weight { get; set; } + [ProtoMember(8)] + public UnitGearItemInfo Line { get; set; } + [ProtoMember(9)] + public UnitGearItemInfo Leader { get; set; } + [ProtoMember(10)] + public UnitGearItemInfo Feeder { get; set; } + } + [ProtoContract] + public partial class Vector3Info : AMessage, IProto + { + public static Vector3Info Create(Scene scene) + { + return scene.MessagePoolComponent.Rent(); + } + public override void Dispose() + { + x = default; + y = default; + z = default; +#if FANTASY_NET || FANTASY_UNITY + GetScene().MessagePoolComponent.Return(this); +#endif + } + [ProtoMember(1)] + public float x { get; set; } + [ProtoMember(2)] + public float y { get; set; } + [ProtoMember(3)] + public float z { get; set; } + } + [ProtoContract] + public partial class QuaternionInfo : AMessage, IProto + { + public static QuaternionInfo Create(Scene scene) + { + return scene.MessagePoolComponent.Rent(); + } + public override void Dispose() + { + x = default; + y = default; + z = default; + w = default; +#if FANTASY_NET || FANTASY_UNITY + GetScene().MessagePoolComponent.Return(this); +#endif + } + [ProtoMember(1)] + public float x { get; set; } + [ProtoMember(2)] + public float y { get; set; } + [ProtoMember(3)] + public float z { get; set; } + [ProtoMember(4)] + public float w { get; set; } + } + [ProtoContract] + public partial class UnitFishingInfo : AMessage, IProto + { + public static UnitFishingInfo Create(Scene scene) + { + return scene.MessagePoolComponent.Rent(); + } + public override void Dispose() + { + LineLength = default; + ReelSpeed = default; + OpenLight = default; + RodSetting = default; +#if FANTASY_NET || FANTASY_UNITY + GetScene().MessagePoolComponent.Return(this); +#endif + } + [ProtoMember(1)] + public float LineLength { get; set; } + [ProtoMember(2)] + public float ReelSpeed { get; set; } + [ProtoMember(3)] + public bool OpenLight { get; set; } + [ProtoMember(4)] + public int RodSetting { get; set; } + } + [ProtoContract] + public partial class UnitStateInfo : AMessage, IProto + { + public static UnitStateInfo Create(Scene scene) + { + return scene.MessagePoolComponent.Rent(); + } + public override void Dispose() + { + State = default; + Args.Clear(); +#if FANTASY_NET || FANTASY_UNITY + GetScene().MessagePoolComponent.Return(this); +#endif + } + [ProtoMember(1)] + public int State { get; set; } + [ProtoMember(2)] + public List Args = new List(); + } + [ProtoContract] + public partial class MapUnitInfo : AMessage, IProto + { + public static MapUnitInfo Create(Scene scene) + { + return scene.MessagePoolComponent.Rent(); + } + public override void Dispose() + { + Id = default; + RoleInfo = default; + Location = default; + State = default; + Gears = default; + FishingInfo = default; + KV.Clear(); +#if FANTASY_NET || FANTASY_UNITY + GetScene().MessagePoolComponent.Return(this); +#endif + } + [ProtoMember(1)] + public long Id { get; set; } + [ProtoMember(2)] + public RoleSimpleInfo RoleInfo { get; set; } + [ProtoMember(3)] + public MapUnitPositionInfo Location { get; set; } + [ProtoMember(4)] + public UnitStateInfo State { get; set; } + [ProtoMember(5)] + public UnitGearInfo Gears { get; set; } + [ProtoMember(6)] + public UnitFishingInfo FishingInfo { get; set; } + [ProtoMember(7)] + public List KV = new List(); + } + [ProtoContract] + public partial class MapUnitPositionInfo : AMessage, IProto + { + public static MapUnitPositionInfo Create(Scene scene) + { + return scene.MessagePoolComponent.Rent(); + } + public override void Dispose() + { + Position = default; + Rotation = default; +#if FANTASY_NET || FANTASY_UNITY + GetScene().MessagePoolComponent.Return(this); +#endif + } + [ProtoMember(1)] + public Vector3Info Position { get; set; } + [ProtoMember(2)] + public QuaternionInfo Rotation { get; set; } + } + [ProtoContract] + public partial class C2Map_EnterRoomRequest : AMessage, ICustomRouteRequest, IProto + { + public static C2Map_EnterRoomRequest Create(Scene scene) + { + return scene.MessagePoolComponent.Rent(); + } + public override void Dispose() + { + MapId = default; + Password = default; +#if FANTASY_NET || FANTASY_UNITY + GetScene().MessagePoolComponent.Return(this); +#endif + } + [ProtoIgnore] + public Map2C_EnterRoomResponse ResponseType { get; set; } + public uint OpCode() { return OuterOpcode.C2Map_EnterRoomRequest; } + [ProtoIgnore] + public int RouteType => Fantasy.RouteType.MapRoute; + [ProtoMember(1)] + public int MapId { get; set; } + [ProtoMember(2)] + public string Password { get; set; } + } + [ProtoContract] + public partial class Map2C_EnterRoomResponse : AMessage, ICustomRouteResponse, IProto + { + public static Map2C_EnterRoomResponse Create(Scene scene) + { + return scene.MessagePoolComponent.Rent(); + } + public override void Dispose() + { + ErrorCode = default; + MapId = default; + RoomId = default; +#if FANTASY_NET || FANTASY_UNITY + GetScene().MessagePoolComponent.Return(this); +#endif + } + public uint OpCode() { return OuterOpcode.Map2C_EnterRoomResponse; } + [ProtoMember(1)] + public int MapId { get; set; } + [ProtoMember(2)] + public long RoomId { get; set; } + [ProtoMember(3)] + public uint ErrorCode { get; set; } + } + [ProtoContract] + public partial class C2Map_EnterMapRequest : AMessage, ICustomRouteRequest, IProto + { + public static C2Map_EnterMapRequest Create(Scene scene) + { + return scene.MessagePoolComponent.Rent(); + } + public override void Dispose() + { + MapId = default; + RoomId = default; +#if FANTASY_NET || FANTASY_UNITY + GetScene().MessagePoolComponent.Return(this); +#endif + } + [ProtoIgnore] + public Map2C_EnterMapResponse ResponseType { get; set; } + public uint OpCode() { return OuterOpcode.C2Map_EnterMapRequest; } + [ProtoIgnore] + public int RouteType => Fantasy.RouteType.MapRoute; + [ProtoMember(1)] + public int MapId { get; set; } + [ProtoMember(2)] + public long RoomId { get; set; } + } + [ProtoContract] + public partial class Map2C_EnterMapResponse : AMessage, ICustomRouteResponse, IProto + { + public static Map2C_EnterMapResponse Create(Scene scene) + { + return scene.MessagePoolComponent.Rent(); + } + public override void Dispose() + { + ErrorCode = default; + Roles.Clear(); + MapId = default; +#if FANTASY_NET || FANTASY_UNITY + GetScene().MessagePoolComponent.Return(this); +#endif + } + public uint OpCode() { return OuterOpcode.Map2C_EnterMapResponse; } + [ProtoMember(1)] + public List Roles = new List(); + [ProtoMember(2)] + public long MapId { get; set; } + [ProtoMember(3)] + public uint ErrorCode { get; set; } + } + [ProtoContract] + public partial class C2Map_Move : AMessage, ICustomRouteMessage, IProto + { + public static C2Map_Move Create(Scene scene) + { + return scene.MessagePoolComponent.Rent(); + } + public override void Dispose() + { + Location = default; + IsStop = default; +#if FANTASY_NET || FANTASY_UNITY + GetScene().MessagePoolComponent.Return(this); +#endif + } + public uint OpCode() { return OuterOpcode.C2Map_Move; } + [ProtoIgnore] + public int RouteType => Fantasy.RouteType.MapRoute; + [ProtoMember(1)] + public MapUnitPositionInfo Location { get; set; } + [ProtoMember(2)] + public bool IsStop { get; set; } + } + /// + /// 用户进入地图 + /// + [ProtoContract] + public partial class Map2C_RoleEnterMapNotify : AMessage, ICustomRouteMessage, IProto + { + public static Map2C_RoleEnterMapNotify Create(Scene scene) + { + return scene.MessagePoolComponent.Rent(); + } + public override void Dispose() + { + Info = default; +#if FANTASY_NET || FANTASY_UNITY + GetScene().MessagePoolComponent.Return(this); +#endif + } + public uint OpCode() { return OuterOpcode.Map2C_RoleEnterMapNotify; } + [ProtoIgnore] + public int RouteType => Fantasy.RouteType.MapRoute; + [ProtoMember(1)] + public MapUnitInfo Info { get; set; } + } + /// + /// 用户离开地图 + /// + [ProtoContract] + public partial class Map2C_RoleExitMapNotify : AMessage, ICustomRouteMessage, IProto + { + public static Map2C_RoleExitMapNotify Create(Scene scene) + { + return scene.MessagePoolComponent.Rent(); + } + public override void Dispose() + { + Id = default; +#if FANTASY_NET || FANTASY_UNITY + GetScene().MessagePoolComponent.Return(this); +#endif + } + public uint OpCode() { return OuterOpcode.Map2C_RoleExitMapNotify; } + [ProtoIgnore] + public int RouteType => Fantasy.RouteType.MapRoute; + [ProtoMember(1)] + public long Id { get; set; } + } + /// + /// 玩家状态变化同步 + /// + [ProtoContract] + public partial class Map2C_RoleStateNotify : AMessage, ICustomRouteMessage, IProto + { + public static Map2C_RoleStateNotify Create(Scene scene) + { + return scene.MessagePoolComponent.Rent(); + } + public override void Dispose() + { + Id = default; + State = default; +#if FANTASY_NET || FANTASY_UNITY + GetScene().MessagePoolComponent.Return(this); +#endif + } + public uint OpCode() { return OuterOpcode.Map2C_RoleStateNotify; } + [ProtoIgnore] + public int RouteType => Fantasy.RouteType.MapRoute; + [ProtoMember(1)] + public long Id { get; set; } + [ProtoMember(2)] + public UnitStateInfo State { get; set; } + } + /// + /// 玩家钓组状态变化 + /// + [ProtoContract] + public partial class Map2C_RoleGearStateNotify : AMessage, ICustomRouteMessage, IProto + { + public static Map2C_RoleGearStateNotify Create(Scene scene) + { + return scene.MessagePoolComponent.Rent(); + } + public override void Dispose() + { + Id = default; + State = default; +#if FANTASY_NET || FANTASY_UNITY + GetScene().MessagePoolComponent.Return(this); +#endif + } + public uint OpCode() { return OuterOpcode.Map2C_RoleGearStateNotify; } + [ProtoIgnore] + public int RouteType => Fantasy.RouteType.MapRoute; + [ProtoMember(1)] + public long Id { get; set; } + [ProtoMember(2)] + public UnitFishingInfo State { get; set; } + } + /// + /// 玩家钓组变化 + /// + [ProtoContract] + public partial class Map2C_RoleGearChangeNotify : AMessage, ICustomRouteMessage, IProto + { + public static Map2C_RoleGearChangeNotify Create(Scene scene) + { + return scene.MessagePoolComponent.Rent(); + } + public override void Dispose() + { + Id = default; + Gears = default; +#if FANTASY_NET || FANTASY_UNITY + GetScene().MessagePoolComponent.Return(this); +#endif + } + public uint OpCode() { return OuterOpcode.Map2C_RoleGearChangeNotify; } + [ProtoIgnore] + public int RouteType => Fantasy.RouteType.MapRoute; + [ProtoMember(1)] + public long Id { get; set; } + [ProtoMember(2)] + public UnitGearInfo Gears { get; set; } + } + /// + /// 玩家位置变化 + /// + [ProtoContract] + public partial class Map2C_MoveNotify : AMessage, IProto + { + public static Map2C_MoveNotify Create(Scene scene) + { + return scene.MessagePoolComponent.Rent(); + } + public override void Dispose() + { + Id = default; + Location = default; +#if FANTASY_NET || FANTASY_UNITY + GetScene().MessagePoolComponent.Return(this); +#endif + } + [ProtoMember(1)] + public long Id { get; set; } + [ProtoMember(2)] + public MapUnitPositionInfo Location { get; set; } + } +} diff --git a/Entity/Generate/NetworkProtocol/RouteType.cs b/Entity/Generate/NetworkProtocol/RouteType.cs index ac5c333..01cebe1 100644 --- a/Entity/Generate/NetworkProtocol/RouteType.cs +++ b/Entity/Generate/NetworkProtocol/RouteType.cs @@ -6,7 +6,6 @@ namespace Fantasy public const int GateRoute = 1001; // Gate public const int SocialRoute = 1002; // Social public const int GameRoute = 1003; // Game - public const int MapRoute = 1004; // Map - public const int RoomRoute = 1005; // Room + public const int MapRoute = 1004; // 地图 } } diff --git a/Hotfix/Common/Handler/G2Common_EnterRequestHandler.cs b/Hotfix/Common/Handler/G2Common_EnterRequestHandler.cs new file mode 100644 index 0000000..42c5e96 --- /dev/null +++ b/Hotfix/Common/Handler/G2Common_EnterRequestHandler.cs @@ -0,0 +1,66 @@ +using Fantasy; +using Fantasy.Async; +using Fantasy.Network.Interface; +using NB.Chat; +using NB.Game; + +namespace NB.Common; + +public class G2Common_EnterRequestHandler : RouteRPC +{ + protected override async FTask Run(Scene scene, G2Common_EnterRequest request, G2Common_EnterResponse response, + Action reply) + { + response.RouteType = request.RouteType; + + switch (scene.SceneType) + { + case SceneType.Game: + { + await RunGame(scene, request, response); + + break; + } + case SceneType.Social: + { + await RunSocial(scene, request, response); + break; + } + case SceneType.Map: + { + break; + } + } + + await FTask.CompletedTask; + } + + private async FTask RunGame(Scene scene, G2Common_EnterRequest request, G2Common_EnterResponse response) + { + // 在缓存中检查该账号是否存在 + var gameAccountManageComponent = scene.GetComponent(); + var account = await gameAccountManageComponent.Online(scene, request.AccountId, request.GateRouteId); + if (account == null) + { + response.ErrorCode = ErrorCode.ErrServer; + return; + } + + response.RoleRouteId = account.RuntimeId; + } + + private async FTask RunSocial(Scene scene, G2Common_EnterRequest request, G2Common_EnterResponse response) + { + // 在缓存中检查该账号是否存在 + var chatUnitManageComponent = scene.GetComponent(); + var account = await chatUnitManageComponent.Online(scene, request.AccountId, request.GateRouteId); + + if (account == null) + { + response.ErrorCode = ErrorCode.ErrServer; + return; + } + + response.RoleRouteId = account.RuntimeId; + } +} \ No newline at end of file diff --git a/Hotfix/Common/Handler/G2Common_ExitRequestHandler.cs b/Hotfix/Common/Handler/G2Common_ExitRequestHandler.cs new file mode 100644 index 0000000..15b8568 --- /dev/null +++ b/Hotfix/Common/Handler/G2Common_ExitRequestHandler.cs @@ -0,0 +1,55 @@ +using Fantasy; +using Fantasy.Async; +using Fantasy.Network.Interface; +using NB.Chat; + +namespace NB.Common; + +public class G2Common_ExitRequestHandler : RouteRPC +{ + protected override async FTask Run(Scene scene, G2Common_ExitRequest request, Common2G_ExitResponse response, + Action reply) + { + switch (scene.SceneType) + { + case SceneType.Game: + { + await RunGame(scene, request, response); + + break; + } + case SceneType.Social: + { + await RunSocial(scene, request, response); + break; + } + case SceneType.Map: + { + break; + } + } + + await FTask.CompletedTask; + } + + private async FTask RunGame(Scene scene, G2Common_ExitRequest request, Common2G_ExitResponse response) + { + // // 在缓存中检查该账号是否存在 + // var gameAccountManageComponent = scene.GetComponent(); + // var account = await gameAccountManageComponent.Online(scene, request.AccountId, request.GateRouteId); + // if (account == null) + // { + // response.ErrorCode = ErrorCode.ErrServer; + // return; + // } + // + // response.RoleRouteId = account.RuntimeId; + } + + private async FTask RunSocial(Scene scene, G2Common_ExitRequest request, Common2G_ExitResponse response) + { + // 在缓存中检查该账号是否存在 + var chatUnitManageComponent = scene.GetComponent(); + await chatUnitManageComponent.Offline(scene, request.AccountId, request.GateRouteId); + } +} \ No newline at end of file diff --git a/Hotfix/Common/Helper/LoginHelper.cs b/Hotfix/Common/Helper/LoginHelper.cs new file mode 100644 index 0000000..243dc7f --- /dev/null +++ b/Hotfix/Common/Helper/LoginHelper.cs @@ -0,0 +1,9 @@ +using Fantasy; +using Fantasy.Async; + +namespace NB.Common; + +public static class LoginHelper +{ + +} \ No newline at end of file diff --git a/Hotfix/Common/Helper/SceneConfigHelper.cs b/Hotfix/Common/Helper/SceneConfigHelper.cs new file mode 100644 index 0000000..e12cb8d --- /dev/null +++ b/Hotfix/Common/Helper/SceneConfigHelper.cs @@ -0,0 +1,14 @@ +using Fantasy; +using Fantasy.Platform.Net; + +namespace NB.Common; + +public class SceneConfigHelper +{ + public static SceneConfig GetConfig(int sceneType) + { + var gameSceneConfigs = SceneConfigData.Instance.GetSceneBySceneType(sceneType); + + return gameSceneConfigs.First(); + } +} \ No newline at end of file diff --git a/Hotfix/Game/Cache/Helper/CacheHandler.cs b/Hotfix/Game/Cache/Helper/CacheHandler.cs index bf36af5..119dc34 100644 --- a/Hotfix/Game/Cache/Helper/CacheHandler.cs +++ b/Hotfix/Game/Cache/Helper/CacheHandler.cs @@ -1,5 +1,6 @@ using Fantasy; using Fantasy.Async; +using NB.Common; namespace NB.Game; @@ -13,7 +14,7 @@ public static class CacheHandler /// public static async FTask> GetPlayerBasicCacheInfos(Scene scene, List id) { - var gameSceneConfig = GameSceneHelper.GetSceneConfig(); + var gameSceneConfig = SceneConfigHelper.GetConfig(SceneType.Game); var gameRouteId = gameSceneConfig.RouteId; //连接到游戏中心服 var gameResponse = (G2S_GetPlayerBasicInfoResponse)await scene.NetworkMessagingComponent.CallInnerRoute( diff --git a/Hotfix/Game/Handler/G2Game_EnterRequestHandler.cs b/Hotfix/Game/Handler/G2Game_EnterRequestHandler.cs index 0b0134b..d1033f8 100644 --- a/Hotfix/Game/Handler/G2Game_EnterRequestHandler.cs +++ b/Hotfix/Game/Handler/G2Game_EnterRequestHandler.cs @@ -1,29 +1,29 @@ -using Fantasy; -using Fantasy.Async; -using Fantasy.Entitas; -using Fantasy.Helper; -using Fantasy.Network; -using Fantasy.Network.Interface; -using NB; -using NB.Gate; - -namespace NB.Game; - -public class G2Game_EnterRequestHandler : RouteRPC -{ - protected override async FTask Run(Scene scene, G2Game_EnterRequest request, Game2G_EnterResponse response, - Action reply) - { - Log.Debug("收到 G2Game_EnterRequestHandler"); - - - // 在缓存中检查该账号是否存在 - var gameAccountManageComponent = scene.GetComponent(); - - var account = await gameAccountManageComponent.Online(scene, request.AccountId, request.GateRouteId); - - response.RoleRouteId = account.RuntimeId; - response.RoleInfo = account.GetRoleSimpleInfo(); - await FTask.CompletedTask; - } -} \ No newline at end of file +// using Fantasy; +// using Fantasy.Async; +// using Fantasy.Entitas; +// using Fantasy.Helper; +// using Fantasy.Network; +// using Fantasy.Network.Interface; +// using NB; +// using NB.Gate; +// +// namespace NB.Game; +// +// public class G2Game_EnterRequestHandler : RouteRPC +// { +// protected override async FTask Run(Scene scene, G2Game_EnterRequest request, Game2G_EnterResponse response, +// Action reply) +// { +// Log.Debug("收到 G2Game_EnterRequestHandler"); +// +// +// // 在缓存中检查该账号是否存在 +// var gameAccountManageComponent = scene.GetComponent(); +// +// var account = await gameAccountManageComponent.Online(scene, request.AccountId, request.GateRouteId); +// +// response.RoleRouteId = account.RuntimeId; +// response.RoleInfo = account.GetRoleSimpleInfo(); +// await FTask.CompletedTask; +// } +// } \ No newline at end of file diff --git a/Hotfix/Game/Helper/GameSceneHelper.cs b/Hotfix/Game/Helper/GameSceneHelper.cs deleted file mode 100644 index d93db66..0000000 --- a/Hotfix/Game/Helper/GameSceneHelper.cs +++ /dev/null @@ -1,48 +0,0 @@ -using System.Net; -using Fantasy; -using Fantasy.Async; -using Fantasy.Network; -using Fantasy.Platform.Net; - -namespace NB.Game; - -public static class GameSceneHelper -{ - #region 上线 下线 - - public static SceneConfig GetSceneConfig() - { - var gameSceneConfigs = SceneConfigData.Instance.GetSceneBySceneType(SceneType.Game); - - return gameSceneConfigs.First(); - } - - - public static async FTask<(long, RoleSimpleInfo?)> Online(Scene scene, long accountID, long gateRuntimeId) - { - var gameSceneConfig = GetSceneConfig(); - var gameRouteId = gameSceneConfig.RouteId; - //连接到游戏中心服 - var gameResponse = (Game2G_EnterResponse)await scene.NetworkMessagingComponent.CallInnerRoute( - gameRouteId, new G2Game_EnterRequest() - { - AccountId = accountID, - GateRouteId = gateRuntimeId - }); - - if (gameResponse.ErrorCode != 0) - { - return (0, null); - } - - return (gameResponse.RoleRouteId, gameResponse.RoleInfo); - } - - public static async FTask Offline(Scene scene, long accountId, long gateRuntimeId) - { - } - - #endregion - - -} \ No newline at end of file diff --git a/Hotfix/Game/Player/Components/PlayerManageComponentSystem.cs b/Hotfix/Game/Player/Components/PlayerManageComponentSystem.cs index 22f8ab6..d94b893 100644 --- a/Hotfix/Game/Player/Components/PlayerManageComponentSystem.cs +++ b/Hotfix/Game/Player/Components/PlayerManageComponentSystem.cs @@ -42,7 +42,8 @@ public static class PlayerManageComponentSystem /// /// /// - public static async FTask Online(this PlayerManageComponent self, Scene scene, long accountId, + /// + public static async FTask Online(this PlayerManageComponent self, Scene scene, long accountId, long gateRouteId) { Log.Debug("检查账号是否在缓存中"); diff --git a/Hotfix/Game/Player/Helper/PlayerHelper.cs b/Hotfix/Game/Player/Helper/PlayerHelper.cs index 150248a..77cea70 100644 --- a/Hotfix/Game/Player/Helper/PlayerHelper.cs +++ b/Hotfix/Game/Player/Helper/PlayerHelper.cs @@ -61,7 +61,7 @@ public static class PlayerHelper /// /// 账号Id /// - public static async FTask LoadDataBase(Scene scene, long accountId) + public static async FTask LoadDataBase(Scene scene, long accountId) { var account = await scene.World.DataBase.First(d => d.Id == accountId); if (account == null) diff --git a/Hotfix/Gate/Handler/Outer/C2G_LoginRequestHandler.cs b/Hotfix/Gate/Handler/Outer/C2G_LoginRequestHandler.cs index 38673e9..d18b09f 100644 --- a/Hotfix/Gate/Handler/Outer/C2G_LoginRequestHandler.cs +++ b/Hotfix/Gate/Handler/Outer/C2G_LoginRequestHandler.cs @@ -42,32 +42,5 @@ public sealed class C2G_LoginRequestHandler : MessageRPC(); - // routeComponent.AddAddress(RouteType.GameRoute, gameResponse.RoleRouteId); - // - // // 给当前Session添加一个组件,当Session销毁的时候会销毁这个组件。 - // var accountFlagComponent = session.AddComponent(); - // accountFlagComponent.AccountID = accountId; } } \ No newline at end of file diff --git a/Hotfix/Gate/Helper/GateLoginHelper.cs b/Hotfix/Gate/Helper/GateLoginHelper.cs index 2cb04b7..05b0f03 100644 --- a/Hotfix/Gate/Helper/GateLoginHelper.cs +++ b/Hotfix/Gate/Helper/GateLoginHelper.cs @@ -5,6 +5,8 @@ using Fantasy.Platform.Net; using NB.Chat; using NB.Game; +// ReSharper disable ConditionIsAlwaysTrueOrFalseAccordingToNullableAPIContract + namespace NB.Gate; public static class GateLoginHelper @@ -37,43 +39,13 @@ public static class GateLoginHelper var routeComponent = session.GetComponent(); if (routeComponent == null) { - routeComponent = session.AddComponent(); + session.AddComponent(); } gateUnitSessionComponent.AccountID = gateUnit.AccountID; gateUnitSessionComponent.SessionId = session.RuntimeId; - - //安排游戏服务器,并通知进入 - var (gameRouteId, roleSimpleInfo) = - await GameSceneHelper.Online(session.Scene, gateUnit.AccountID, session.RuntimeId); - if (gameRouteId <= 0 || roleSimpleInfo == null) - { - return ErrorCode.OnlineSceneFailed; - } - - Log.Info($"连接游戏服成功,gameRouteId:{gameRouteId}"); - routeComponent.AddAddress(RouteType.GameRoute, gameRouteId); - gateUnit.GameSceneRouteId = gameRouteId; - - - //安排进入的聊天服 - var (chatRouteId, sceneRouteId) = - await SocialSceneHelper.Online(session.Scene, roleSimpleInfo, session.RuntimeId); - if (chatRouteId <= 0) - { - return ErrorCode.OnlineSceneFailed; - } - - routeComponent.AddAddress(RouteType.SocialRoute, chatRouteId); - gateUnit.ChatSceneRouteId = sceneRouteId; - Log.Info($"连接聊天服成功,gameRouteId:{gameRouteId}"); - - var gameSceneConfigs = SceneConfigData.Instance.GetSceneBySceneType(SceneType.Map); - - var mapSceneConfig = gameSceneConfigs.First(); - routeComponent.AddAddress(RouteType.MapRoute, mapSceneConfig.RouteId); - return ErrorCode.Successful; + return await gateUnit.Online(RouteType.GameRoute, RouteType.SocialRoute, RouteType.MapRoute); } #endregion @@ -88,11 +60,13 @@ public static class GateLoginHelper public static async FTask Offline(GateUnit gateUnit, long sessionId) { //通知服务器下线 - Log.Info($"断线的session id={sessionId} ChatSceneRouteId={gateUnit.ChatSceneRouteId}"); - await GameSceneHelper.Offline(gateUnit.Scene, gateUnit.AccountID, sessionId); - await SocialSceneHelper.Offline(gateUnit.Scene, gateUnit.AccountID, sessionId, - gateUnit.ChatSceneRouteId); - return ErrorCode.Successful; + 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; } #endregion diff --git a/Hotfix/Gate/System/GateUnitSystem.cs b/Hotfix/Gate/System/GateUnitSystem.cs index 5ad76f9..b9d6757 100644 --- a/Hotfix/Gate/System/GateUnitSystem.cs +++ b/Hotfix/Gate/System/GateUnitSystem.cs @@ -1,4 +1,10 @@ -using Fantasy.Entitas.Interface; +using Fantasy; +using Fantasy.Async; +using Fantasy.Entitas.Interface; +using Fantasy.Network; +using NB.Common; + +// ReSharper disable ConditionIsAlwaysTrueOrFalseAccordingToNullableAPIContract namespace NB.Gate; @@ -11,6 +17,120 @@ public class GateUnitDestroySystem : DestroySystem } } -public class GateUnitSystem +public static class GateUnitSystem { + #region Address + + private static void RemoveAddress(this GateUnit self, int routType, long routeId) + { + if (self.SceneRoutes.TryGetValue(routType, out var route)) + { + if (route == routeId) + { + self.SceneRoutes.Remove(routType); + } + } + } + + private static void AddAddress(this GateUnit self, int routType, long routeId) + { + self.SceneRoutes[routType] = routeId; + } + + private static long GetAddress(this GateUnit self, int routType) + { + return self.SceneRoutes.GetValueOrDefault(routType, 0); + } + + #endregion + + + #region 上线 + + public static async FTask Online(this GateUnit self, params int[] routeType) + { + if (routeType != null && routeType.Length > 0) + { + foreach (var route in routeType) + { + var ret = await self.Online(route); + if (ret != ErrorCode.Successful) return ret; + } + } + + return ErrorCode.Successful; + } + + public static async FTask Online(this GateUnit self, int routeType) + { + Session session = self.Session; + var routeComponent = session.GetComponent(); + if (routeComponent == null) + { + routeComponent = session.AddComponent(); + } + + var gameSceneConfig = SceneConfigHelper.GetConfig(routeType); + var gameRouteId = gameSceneConfig.RouteId; + //连接到游戏中心服 + var gameResponse = (G2Common_EnterResponse)await self.Scene.NetworkMessagingComponent.CallInnerRoute( + gameRouteId, new G2Common_EnterRequest() + { + AccountId = self.AccountID, + GateRouteId = session.RuntimeId + }); + + if (gameResponse.ErrorCode != 0) + { + return gameResponse.ErrorCode; + } + + routeComponent.AddAddress(routeType, gameRouteId); + self.AddAddress(routeType, gameRouteId); + + return ErrorCode.Successful; + } + + #endregion + + #region 下线 + + public static async FTask Offline(this GateUnit self, long sessionId, params int[] routeType) + { + if (routeType != null && routeType.Length > 0) + { + foreach (var route in routeType) + { + var ret = await self.Offline(sessionId, route); + if (ret != ErrorCode.Successful) return ret; + } + } + + return ErrorCode.Successful; + } + + public static async FTask Offline(this GateUnit self, long sessionId, int routeType) + { + var sceneRouteId = self.GetAddress(routeType); + if (sceneRouteId < 1) return ErrorCode.Successful; + for (int i = 0; i < 10; i++) + { + var gameResponse = (Common2G_ExitResponse)await self.Scene.NetworkMessagingComponent.CallInnerRoute( + sceneRouteId, new G2Common_ExitRequest() + { + AccountId = self.AccountID, + GateRouteId = sessionId + }); + if (gameResponse.ErrorCode == 0) + { + self.RemoveAddress(routeType, sceneRouteId); + return ErrorCode.Successful; + } + } + + Log.Error($"重试多次还是退出失败,需检查,sessionId={sessionId} route={routeType}"); + return ErrorCode.ErrServer; + } + + #endregion } \ No newline at end of file diff --git a/Hotfix/Hotfix.csproj b/Hotfix/Hotfix.csproj index 7275b1e..34e133c 100644 --- a/Hotfix/Hotfix.csproj +++ b/Hotfix/Hotfix.csproj @@ -13,8 +13,10 @@ + + diff --git a/Hotfix/Map/Handler/C2Map_CreateRoomRequestHandler.cs b/Hotfix/Map/Handler/C2Map_CreateRoomRequestHandler.cs index fc00dd1..6295c17 100644 --- a/Hotfix/Map/Handler/C2Map_CreateRoomRequestHandler.cs +++ b/Hotfix/Map/Handler/C2Map_CreateRoomRequestHandler.cs @@ -1,15 +1,15 @@ -using Fantasy; -using Fantasy.Async; -using Fantasy.Network.Interface; - -namespace NB.Map; - -public class C2Map_CreateRoomRequestHandler : RouteRPC -{ - protected override async FTask Run(Scene entity, C2Map_CreateRoomRequest request, Map2C_CreateRoomResponse response, - Action reply) - { - Log.Info($"创建房间=== map:{request.MapId} pass:{request.Password}"); - await FTask.CompletedTask; - } -} \ No newline at end of file +// using Fantasy; +// using Fantasy.Async; +// using Fantasy.Network.Interface; +// +// namespace NB.Map; +// +// public class C2Map_CreateRoomRequestHandler : RouteRPC +// { +// protected override async FTask Run(Scene entity, C2Map_CreateRoomRequest request, Map2C_CreateRoomResponse response, +// Action reply) +// { +// Log.Info($"创建房间=== map:{request.MapId} pass:{request.Password}"); +// await FTask.CompletedTask; +// } +// } \ No newline at end of file diff --git a/Hotfix/Social/Chat/Handler/Inner/G2S_EnterRequestHandler.cs b/Hotfix/Social/Chat/Handler/Inner/G2S_EnterRequestHandler.cs deleted file mode 100644 index 60c2b87..0000000 --- a/Hotfix/Social/Chat/Handler/Inner/G2S_EnterRequestHandler.cs +++ /dev/null @@ -1,22 +0,0 @@ -using Fantasy; -using Fantasy.Async; -using Fantasy.Network.Interface; -using NB.Game; - -namespace NB.Chat; - -public class G2S_EnterRequestHandler : RouteRPC -{ - protected override async FTask Run(Scene scene, G2S_EnterRequest request, S2G_EnterResponse response, - Action reply) - { - var roleId = request.Role.RoleId; - Log.Debug($"收到 G2S_EnterRequestHandler {roleId}"); - - // 在缓存中检查该账号是否存在 - var chatUnitManageComponent = scene.GetComponent(); - var account = await chatUnitManageComponent.Online(scene, request.Role, request.GateRouteId); - - response.RoleRouteId = account.RuntimeId; - } -} \ No newline at end of file diff --git a/Hotfix/Social/Chat/Handler/Inner/G2S_ExitRequestHandler.cs b/Hotfix/Social/Chat/Handler/Inner/G2S_ExitRequestHandler.cs deleted file mode 100644 index c2e4bbc..0000000 --- a/Hotfix/Social/Chat/Handler/Inner/G2S_ExitRequestHandler.cs +++ /dev/null @@ -1,16 +0,0 @@ -using Fantasy; -using Fantasy.Async; -using Fantasy.Network.Interface; - -namespace NB.Chat; - -public class G2S_ExitRequestHandler : RouteRPC -{ - protected override async FTask Run(Scene scene, G2S_ExitRequest request, S2G_ExitResponse response, - Action reply) - { - // 在缓存中检查该账号是否存在 - var chatUnitManageComponent = scene.GetComponent(); - await chatUnitManageComponent.Offline(scene, request.AccountId, request.GateRouteId); - } -} \ No newline at end of file diff --git a/Hotfix/Social/Chat/Helper/SocialSceneHelper.cs b/Hotfix/Social/Chat/Helper/SocialSceneHelper.cs index c5955e9..648bb66 100644 --- a/Hotfix/Social/Chat/Helper/SocialSceneHelper.cs +++ b/Hotfix/Social/Chat/Helper/SocialSceneHelper.cs @@ -122,52 +122,51 @@ public static class SocialSceneHelper #region 上线下线 - public static async FTask<(long, long)> Online(Scene scene, RoleSimpleInfo roleSimple, long gateRuntimeId) - { - var gameSceneConfig = GetSceneConfig(); - var gameRouteId = gameSceneConfig.RouteId; - //连接到游戏中心服 - var gameResponse = (S2G_EnterResponse)await scene.NetworkMessagingComponent.CallInnerRoute( - gameRouteId, new G2S_EnterRequest() - { - Role = roleSimple, - GateRouteId = gateRuntimeId - }); - - if (gameResponse.ErrorCode != 0) - { - return (0, 0); - } - - return (gameResponse.RoleRouteId, gameRouteId); - // return gameRouteId; - } - - public static async FTask Offline(Scene scene, long accountId, long gateRuntimeId, long sceneRouteId) - { - for (int i = 0; i < 10; i++) - { - var gameResponse = (S2G_ExitResponse)await scene.NetworkMessagingComponent.CallInnerRoute( - sceneRouteId, new G2S_ExitRequest() - { - AccountId = accountId, - GateRouteId = gateRuntimeId - }); - if (gameResponse.ErrorCode == 0) - { - return; - } - } - - Log.Error("重试多次还是退出失败,需检查"); - } - - private static SceneConfig GetSceneConfig() - { - var gameSceneConfigs = SceneConfigData.Instance.GetSceneBySceneType(SceneType.Social); - - return gameSceneConfigs.First(); - } + // public static async FTask<(long, long)> Online(Scene scene, RoleSimpleInfo roleSimple, long gateRuntimeId) + // { + // var gameSceneConfig = GetSceneConfig(); + // var gameRouteId = gameSceneConfig.RouteId; + // //连接到游戏中心服 + // var gameResponse = (S2G_EnterResponse)await scene.NetworkMessagingComponent.CallInnerRoute( + // gameRouteId, new G2S_EnterRequest() + // { + // Role = roleSimple, + // GateRouteId = gateRuntimeId + // }); + // + // if (gameResponse.ErrorCode != 0) + // { + // return (0, 0); + // } + // + // return (gameResponse.RoleRouteId, gameRouteId); + // } + // + // public static async FTask Offline(Scene scene, long accountId, long gateRuntimeId, long sceneRouteId) + // { + // for (int i = 0; i < 10; i++) + // { + // var gameResponse = (S2G_ExitResponse)await scene.NetworkMessagingComponent.CallInnerRoute( + // sceneRouteId, new G2S_ExitRequest() + // { + // AccountId = accountId, + // GateRouteId = gateRuntimeId + // }); + // if (gameResponse.ErrorCode == 0) + // { + // return; + // } + // } + // + // Log.Error("重试多次还是退出失败,需检查"); + // } + // + // private static SceneConfig GetSceneConfig() + // { + // var gameSceneConfigs = SceneConfigData.Instance.GetSceneBySceneType(SceneType.Social); + // + // return gameSceneConfigs.First(); + // } #endregion } \ No newline at end of file diff --git a/Hotfix/Social/Chat/System/ChatUnitManageComponentSystem.cs b/Hotfix/Social/Chat/System/ChatUnitManageComponentSystem.cs index 7aa95b8..61f7720 100644 --- a/Hotfix/Social/Chat/System/ChatUnitManageComponentSystem.cs +++ b/Hotfix/Social/Chat/System/ChatUnitManageComponentSystem.cs @@ -29,13 +29,13 @@ public static class ChatUnitManageComponentSystem /// /// /// - /// + /// /// public static async FTask Online(this SocialUnitManageComponent self, Scene scene, - RoleSimpleInfo roleSimpleInfo, + long accountId, long gateRouteId) { - var accountId = roleSimpleInfo.RoleId; + // var accountId = roleSimpleInfo.RoleId; if (!self.TryGet(accountId, out var account)) { account = ChatUnitFactory.Create(scene, accountId); @@ -46,7 +46,7 @@ public static class ChatUnitManageComponentSystem { await account.TryComponent(); account.GateRouteId = gateRouteId; - account.Role = roleSimpleInfo; + // account.Role = roleSimpleInfo; } await FTask.CompletedTask;