提交示例代码

This commit is contained in:
Bob.Song
2026-03-05 11:39:06 +08:00
commit 25958f58c3
2534 changed files with 209593 additions and 0 deletions

View File

@@ -0,0 +1,318 @@
using ProtoBuf;
using System.Collections.Generic;
using Fantasy;
using Fantasy.Network.Interface;
using Fantasy.Serialize;
#pragma warning disable CS8618
namespace Fantasy
{
/// <summary>
/// 登录游戏
/// </summary>
[ProtoContract]
public partial class C2G_LoginRequest : AMessage, IRequest, IProto
{
public static C2G_LoginRequest Create(Scene scene)
{
return scene.MessagePoolComponent.Rent<C2G_LoginRequest>();
}
public override void Dispose()
{
UserName = default;
#if FANTASY_NET || FANTASY_UNITY
GetScene().MessagePoolComponent.Return<C2G_LoginRequest>(this);
#endif
}
[ProtoIgnore]
public G2C_LoginResponse ResponseType { get; set; }
public uint OpCode() { return OuterOpcode.C2G_LoginRequest; }
[ProtoMember(1)]
public string UserName { get; set; }
}
[ProtoContract]
public partial class G2C_LoginResponse : AMessage, IResponse, IProto
{
public static G2C_LoginResponse Create(Scene scene)
{
return scene.MessagePoolComponent.Rent<G2C_LoginResponse>();
}
public override void Dispose()
{
ErrorCode = default;
#if FANTASY_NET || FANTASY_UNITY
GetScene().MessagePoolComponent.Return<G2C_LoginResponse>(this);
#endif
}
public uint OpCode() { return OuterOpcode.G2C_LoginResponse; }
[ProtoMember(1)]
public uint ErrorCode { get; set; }
}
/// <summary>
/// 退出游戏
/// </summary>
[ProtoContract]
public partial class C2G_ExitRequest : AMessage, IRequest, IProto
{
public static C2G_ExitRequest Create(Scene scene)
{
return scene.MessagePoolComponent.Rent<C2G_ExitRequest>();
}
public override void Dispose()
{
#if FANTASY_NET || FANTASY_UNITY
GetScene().MessagePoolComponent.Return<C2G_ExitRequest>(this);
#endif
}
[ProtoIgnore]
public G2C_ExitResponse ResponseType { get; set; }
public uint OpCode() { return OuterOpcode.C2G_ExitRequest; }
}
[ProtoContract]
public partial class G2C_ExitResponse : AMessage, IResponse, IProto
{
public static G2C_ExitResponse Create(Scene scene)
{
return scene.MessagePoolComponent.Rent<G2C_ExitResponse>();
}
public override void Dispose()
{
ErrorCode = default;
#if FANTASY_NET || FANTASY_UNITY
GetScene().MessagePoolComponent.Return<G2C_ExitResponse>(this);
#endif
}
public uint OpCode() { return OuterOpcode.G2C_ExitResponse; }
[ProtoMember(1)]
public uint ErrorCode { get; set; }
}
/// <summary>
/// 发送一个聊天消息给Chat服务器中间是经过Gate中转的
/// </summary>
[ProtoContract]
public partial class C2Chat_SendMessageRequest : AMessage, ICustomRouteRequest, IProto
{
public static C2Chat_SendMessageRequest Create(Scene scene)
{
return scene.MessagePoolComponent.Rent<C2Chat_SendMessageRequest>();
}
public override void Dispose()
{
ChatInfoTree = default;
#if FANTASY_NET || FANTASY_UNITY
GetScene().MessagePoolComponent.Return<C2Chat_SendMessageRequest>(this);
#endif
}
[ProtoIgnore]
public Chat2C_SendMessageResponse ResponseType { get; set; }
public uint OpCode() { return OuterOpcode.C2Chat_SendMessageRequest; }
[ProtoIgnore]
public int RouteType => Fantasy.RouteType.ChatRoute;
[ProtoMember(1)]
public ChatInfoTree ChatInfoTree { get; set; }
}
[ProtoContract]
public partial class Chat2C_SendMessageResponse : AMessage, ICustomRouteResponse, IProto
{
public static Chat2C_SendMessageResponse Create(Scene scene)
{
return scene.MessagePoolComponent.Rent<Chat2C_SendMessageResponse>();
}
public override void Dispose()
{
ErrorCode = default;
#if FANTASY_NET || FANTASY_UNITY
GetScene().MessagePoolComponent.Return<Chat2C_SendMessageResponse>(this);
#endif
}
public uint OpCode() { return OuterOpcode.Chat2C_SendMessageResponse; }
[ProtoMember(1)]
public uint ErrorCode { get; set; }
}
[ProtoContract]
public partial class Chat2C_Message : AMessage, ICustomRouteMessage, IProto
{
public static Chat2C_Message Create(Scene scene)
{
return scene.MessagePoolComponent.Rent<Chat2C_Message>();
}
public override void Dispose()
{
ChatInfoTree = default;
#if FANTASY_NET || FANTASY_UNITY
GetScene().MessagePoolComponent.Return<Chat2C_Message>(this);
#endif
}
public uint OpCode() { return OuterOpcode.Chat2C_Message; }
[ProtoIgnore]
public int RouteType => Fantasy.RouteType.ChatRoute;
[ProtoMember(1)]
public ChatInfoTree ChatInfoTree { get; set; }
}
/// <summary>
/// 聊天消息树
/// </summary>
[ProtoContract]
public partial class ChatInfoTree : AMessage, IProto
{
public static ChatInfoTree Create(Scene scene)
{
return scene.MessagePoolComponent.Rent<ChatInfoTree>();
}
public override void Dispose()
{
ChatChannelType = default;
ChatChannelId = default;
UnitId = default;
UserName = default;
Target.Clear();
Node.Clear();
#if FANTASY_NET || FANTASY_UNITY
GetScene().MessagePoolComponent.Return<ChatInfoTree>(this);
#endif
}
[ProtoMember(1)]
public int ChatChannelType { get; set; }
[ProtoMember(2)]
public long ChatChannelId { get; set; }
[ProtoMember(3)]
public long UnitId { get; set; }
[ProtoMember(4)]
public string UserName { get; set; }
[ProtoMember(5)]
public List<long> Target = new List<long>();
[ProtoMember(6)]
public List<ChatInfoNode> Node = new List<ChatInfoNode>();
}
/// <summary>
/// 聊天信息节点
/// </summary>
[ProtoContract]
public partial class ChatInfoNode : AMessage, IProto
{
public static ChatInfoNode Create(Scene scene)
{
return scene.MessagePoolComponent.Rent<ChatInfoNode>();
}
public override void Dispose()
{
ChatNodeType = default;
ChatNodeEvent = default;
Content = default;
Color = default;
Data = default;
#if FANTASY_NET || FANTASY_UNITY
GetScene().MessagePoolComponent.Return<ChatInfoNode>(this);
#endif
}
[ProtoMember(1)]
public int ChatNodeType { get; set; }
[ProtoMember(2)]
public int ChatNodeEvent { get; set; }
[ProtoMember(3)]
public string Content { get; set; }
[ProtoMember(4)]
public string Color { get; set; }
[ProtoMember(5)]
public byte[] Data { get; set; }
}
/// <summary>
/// 聊天位置信息节点
/// </summary>
[ProtoContract]
public partial class ChatPositionNode : AMessage, IProto
{
public static ChatPositionNode Create(Scene scene)
{
return scene.MessagePoolComponent.Rent<ChatPositionNode>();
}
public override void Dispose()
{
MapName = default;
PosX = default;
PosY = default;
PosZ = default;
#if FANTASY_NET || FANTASY_UNITY
GetScene().MessagePoolComponent.Return<ChatPositionNode>(this);
#endif
}
[ProtoMember(1)]
public string MapName { get; set; }
[ProtoMember(2)]
public float PosX { get; set; }
[ProtoMember(3)]
public float PosY { get; set; }
[ProtoMember(4)]
public float PosZ { get; set; }
}
/// <summary>
/// 聊天位置信息节点
/// </summary>
[ProtoContract]
public partial class ChatOpenUINode : AMessage, IProto
{
public static ChatOpenUINode Create(Scene scene)
{
return scene.MessagePoolComponent.Rent<ChatOpenUINode>();
}
public override void Dispose()
{
UIName = default;
#if FANTASY_NET || FANTASY_UNITY
GetScene().MessagePoolComponent.Return<ChatOpenUINode>(this);
#endif
}
[ProtoMember(1)]
public string UIName { get; set; }
}
/// <summary>
/// 聊天连接信息节点
/// </summary>
[ProtoContract]
public partial class ChatLinkNode : AMessage, IProto
{
public static ChatLinkNode Create(Scene scene)
{
return scene.MessagePoolComponent.Rent<ChatLinkNode>();
}
public override void Dispose()
{
Link = default;
#if FANTASY_NET || FANTASY_UNITY
GetScene().MessagePoolComponent.Return<ChatLinkNode>(this);
#endif
}
[ProtoMember(1)]
public string Link { get; set; }
}
/// <summary>
/// 装备信息实体
/// </summary>
[ProtoContract]
public partial class Item : AMessage, IProto
{
public static Item Create(Scene scene)
{
return scene.MessagePoolComponent.Rent<Item>();
}
public override void Dispose()
{
Level = default;
Name = default;
HP = default;
MP = default;
#if FANTASY_NET || FANTASY_UNITY
GetScene().MessagePoolComponent.Return<Item>(this);
#endif
}
[ProtoMember(1)]
public string Level { get; set; }
[ProtoMember(2)]
public string Name { get; set; }
[ProtoMember(3)]
public string HP { get; set; }
[ProtoMember(4)]
public string MP { get; set; }
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: d8b7e9d1d45c14f28ba2e43726bae843
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,13 @@
namespace Fantasy
{
public static partial class OuterOpcode
{
public const uint C2G_LoginRequest = 268445457;
public const uint G2C_LoginResponse = 402663185;
public const uint C2G_ExitRequest = 268445458;
public const uint G2C_ExitResponse = 402663186;
public const uint C2Chat_SendMessageRequest = 2281711377;
public const uint Chat2C_SendMessageResponse = 2415929105;
public const uint Chat2C_Message = 2147493649;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 99247fb17248243e591419cbf976f158
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,9 @@
namespace Fantasy
{
// Route协议定义(需要定义1000以上、因为1000以内的框架预留)
public static class RouteType
{
public const int GateRoute = 1001; // Gate
public const int ChatRoute = 1002; // Chat
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: c84127d566a0345b19311b3a293ab9cc
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: