From 78b647e1bbda8c49c670a0298c6d98815e4c7e6c Mon Sep 17 00:00:00 2001 From: BobSong <605277374@qq.com> Date: Mon, 28 Jul 2025 23:46:05 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B8=B8=E6=88=8F=E6=9C=8D=E7=9B=B8=E5=85=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Generate/NetworkProtocol/OuterCommon.cs | 67 +++++++++++++++++++ .../NetworkProtocol/OuterCommon.cs.meta | 2 + .../Generate/NetworkProtocol/OuterMessage.cs | 34 +++++----- .../Generate/NetworkProtocol/OuterOpcode.cs | 4 +- .../Generate/NetworkProtocol/RouteType.cs | 1 + Assets/Scripts/Startup/Init.cs | 10 +-- 6 files changed, 96 insertions(+), 22 deletions(-) create mode 100644 Assets/Scripts/Generate/NetworkProtocol/OuterCommon.cs create mode 100644 Assets/Scripts/Generate/NetworkProtocol/OuterCommon.cs.meta diff --git a/Assets/Scripts/Generate/NetworkProtocol/OuterCommon.cs b/Assets/Scripts/Generate/NetworkProtocol/OuterCommon.cs new file mode 100644 index 000000000..d651bc0d2 --- /dev/null +++ b/Assets/Scripts/Generate/NetworkProtocol/OuterCommon.cs @@ -0,0 +1,67 @@ +using ProtoBuf; + +using System.Collections.Generic; +using Fantasy; +using NBC; +using NBC.Network.Interface; +using NBC.Serialize; +#pragma warning disable CS8618 + +namespace NBC +{ + /// + /// GameAccount实体类 + /// + [ProtoContract] + public partial class RoleBaseInfo : AMessage, IProto + { + public static RoleBaseInfo Create(Scene scene) + { + return scene.MessagePoolComponent.Rent(); + } + public override void Dispose() + { + NickName = default; + Head = default; + Country = default; + Level = default; + Exp = default; +#if FANTASY_NET || FANTASY_UNITY + GetScene().MessagePoolComponent.Return(this); +#endif + } + [ProtoMember(1)] + public string NickName { get; set; } + [ProtoMember(2)] + public string Head { get; set; } + [ProtoMember(3)] + public string Country { get; set; } + [ProtoMember(4)] + public int Level { get; set; } + [ProtoMember(5)] + public int Exp { get; set; } + } + /// + /// 角色信息 + /// + [ProtoContract] + public partial class RoleInfo : AMessage, IProto + { + public static RoleInfo Create(Scene scene) + { + return scene.MessagePoolComponent.Rent(); + } + public override void Dispose() + { + BaseInfo = default; + RoleId = default; +#if FANTASY_NET || FANTASY_UNITY + GetScene().MessagePoolComponent.Return(this); +#endif + } + [ProtoMember(1)] + public RoleBaseInfo BaseInfo { get; set; } + [ProtoMember(2)] + public long RoleId { get; set; } + } +} diff --git a/Assets/Scripts/Generate/NetworkProtocol/OuterCommon.cs.meta b/Assets/Scripts/Generate/NetworkProtocol/OuterCommon.cs.meta new file mode 100644 index 000000000..393559e17 --- /dev/null +++ b/Assets/Scripts/Generate/NetworkProtocol/OuterCommon.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 5a7e198038cdd4e4d927a062fefa83d8 \ No newline at end of file diff --git a/Assets/Scripts/Generate/NetworkProtocol/OuterMessage.cs b/Assets/Scripts/Generate/NetworkProtocol/OuterMessage.cs index 0eb9495e4..48070f14b 100644 --- a/Assets/Scripts/Generate/NetworkProtocol/OuterMessage.cs +++ b/Assets/Scripts/Generate/NetworkProtocol/OuterMessage.cs @@ -141,45 +141,47 @@ namespace NBC [ProtoMember(2)] public long LoginTime { get; set; } } - /// - /// 拿到当前账号的信息 - /// [ProtoContract] - public partial class C2G_GetAccountInfoRequest : AMessage, IRequest, IProto + public partial class C2Game_GetRoleInfoRequest : AMessage, ICustomRouteRequest, IProto { - public static C2G_GetAccountInfoRequest Create(Scene scene) + public static C2Game_GetRoleInfoRequest Create(Scene scene) { - return scene.MessagePoolComponent.Rent(); + return scene.MessagePoolComponent.Rent(); } public override void Dispose() { #if FANTASY_NET || FANTASY_UNITY - GetScene().MessagePoolComponent.Return(this); + GetScene().MessagePoolComponent.Return(this); #endif } [ProtoIgnore] - public G2C_GetAccountInfoResponse ResponseType { get; set; } - public uint OpCode() { return OuterOpcode.C2G_GetAccountInfoRequest; } + public Game2C_GetRoleInfoResponse ResponseType { get; set; } + public uint OpCode() { return OuterOpcode.C2Game_GetRoleInfoRequest; } + [ProtoIgnore] + public int RouteType => Fantasy.RouteType.GameRoute; } [ProtoContract] - public partial class G2C_GetAccountInfoResponse : AMessage, IResponse, IProto + public partial class Game2C_GetRoleInfoResponse : AMessage, ICustomRouteResponse, IProto { - public static G2C_GetAccountInfoResponse Create(Scene scene) + public static Game2C_GetRoleInfoResponse Create(Scene scene) { - return scene.MessagePoolComponent.Rent(); + return scene.MessagePoolComponent.Rent(); } public override void Dispose() { ErrorCode = default; - GameAccountInfo = default; + Name = default; + RoleId = default; #if FANTASY_NET || FANTASY_UNITY - GetScene().MessagePoolComponent.Return(this); + GetScene().MessagePoolComponent.Return(this); #endif } - public uint OpCode() { return OuterOpcode.G2C_GetAccountInfoResponse; } + public uint OpCode() { return OuterOpcode.Game2C_GetRoleInfoResponse; } [ProtoMember(1)] - public GameAccountInfo GameAccountInfo { get; set; } + public string Name { get; set; } [ProtoMember(2)] + public string RoleId { get; set; } + [ProtoMember(3)] public uint ErrorCode { get; set; } } } diff --git a/Assets/Scripts/Generate/NetworkProtocol/OuterOpcode.cs b/Assets/Scripts/Generate/NetworkProtocol/OuterOpcode.cs index 4648e953a..5b83c2e14 100644 --- a/Assets/Scripts/Generate/NetworkProtocol/OuterOpcode.cs +++ b/Assets/Scripts/Generate/NetworkProtocol/OuterOpcode.cs @@ -7,7 +7,7 @@ namespace Fantasy public const uint C2G_LoginRequest = 268445458; public const uint G2C_LoginResponse = 402663186; public const uint G2C_RepeatLogin = 134227729; - public const uint C2G_GetAccountInfoRequest = 268445459; - public const uint G2C_GetAccountInfoResponse = 402663187; + public const uint C2Game_GetRoleInfoRequest = 2281711377; + public const uint Game2C_GetRoleInfoResponse = 2415929105; } } diff --git a/Assets/Scripts/Generate/NetworkProtocol/RouteType.cs b/Assets/Scripts/Generate/NetworkProtocol/RouteType.cs index cdd0df002..8bd8a52a2 100644 --- a/Assets/Scripts/Generate/NetworkProtocol/RouteType.cs +++ b/Assets/Scripts/Generate/NetworkProtocol/RouteType.cs @@ -5,5 +5,6 @@ namespace Fantasy { public const int GateRoute = 1001; // Gate public const int ChatRoute = 1002; // Chat + public const int GameRoute = 1003; // Game } } diff --git a/Assets/Scripts/Startup/Init.cs b/Assets/Scripts/Startup/Init.cs index 5c0ed8245..389388b5d 100644 --- a/Assets/Scripts/Startup/Init.cs +++ b/Assets/Scripts/Startup/Init.cs @@ -193,11 +193,13 @@ namespace NBF } Log.Debug( - $"登录到Gate服务器成功!LoginTime:{loginResponse.GameAccountInfo.LoginTime} CreateTime:{loginResponse.GameAccountInfo.CreateTime}"); + $"登录到Gate服务器成功!ErrorCode:{loginResponse.ErrorCode}"); + // Log.Debug( + // $"登录到Gate服务器成功!LoginTime:{loginResponse.GameAccountInfo.LoginTime} CreateTime:{loginResponse.GameAccountInfo.CreateTime}"); - var getResponse = (G2C_GetAccountInfoResponse)await _session.Call(new C2G_GetAccountInfoRequest()); - var gameAcc = getResponse.GameAccountInfo; - Log.Info($"gameAcc LoginTime:{gameAcc.LoginTime} CreateTime:{gameAcc.CreateTime}"); + // var getResponse = (G2C_GetAccountInfoResponse)await _session.Call(new C2G_GetAccountInfoRequest()); + // var gameAcc = getResponse.GameAccountInfo; + // Log.Info($"gameAcc LoginTime:{gameAcc.LoginTime} CreateTime:{gameAcc.CreateTime}"); // getResponse.GameAccountInfo.LoginTime.ToString() }