From 36067705f2ae3878175b6869236cffa2aa2f04e0 Mon Sep 17 00:00:00 2001 From: "Bob.Song" Date: Thu, 5 Mar 2026 15:03:45 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=B8=BAluban?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CODELY.md | 441 +++++ Entity/Entity.csproj | 3 +- Entity/Game/Item/Item.cs | 2 +- Entity/Game/Player/PlayerWalletComponent.cs | 2 +- Entity/Generate/ConfigTable/Bait.cs | 70 + Entity/Generate/ConfigTable/BasicConfig.cs | 73 + Entity/Generate/ConfigTable/Bobber.cs | 64 + .../Generate/ConfigTable/Entity/BaitConfig.cs | 87 - .../ConfigTable/Entity/BasicConfig.cs | 85 - .../ConfigTable/Entity/BobberConfig.cs | 85 - .../ConfigTable/Entity/FeederConfig.cs | 85 - .../Generate/ConfigTable/Entity/FishConfig.cs | 93 - .../ConfigTable/Entity/GoodsConfig.cs | 97 - .../Generate/ConfigTable/Entity/HookConfig.cs | 83 - .../Generate/ConfigTable/Entity/InitConfig.cs | 83 - .../Generate/ConfigTable/Entity/ItemConfig.cs | 97 - .../Generate/ConfigTable/Entity/LineConfig.cs | 85 - .../Generate/ConfigTable/Entity/LureConfig.cs | 87 - .../Generate/ConfigTable/Entity/ReelConfig.cs | 87 - .../Generate/ConfigTable/Entity/RingConfig.cs | 85 - .../Generate/ConfigTable/Entity/RodConfig.cs | 91 - .../ConfigTable/Entity/RodRingConfig.cs | 85 - .../ConfigTable/Entity/WeightConfig.cs | 89 - Entity/Generate/ConfigTable/Feeder.cs | 64 + Entity/Generate/ConfigTable/Fish.cs | 76 + Entity/Generate/ConfigTable/Goods.cs | 94 + Entity/Generate/ConfigTable/Hook.cs | 58 + Entity/Generate/ConfigTable/InitItemConfig.cs | 58 + Entity/Generate/ConfigTable/Item.cs | 106 ++ Entity/Generate/ConfigTable/Line.cs | 64 + Entity/Generate/ConfigTable/Lure.cs | 70 + Entity/Generate/ConfigTable/Reel.cs | 70 + Entity/Generate/ConfigTable/Rod.cs | 82 + Entity/Generate/ConfigTable/Shop.cs | 94 + Entity/Generate/ConfigTable/Tables.cs | 113 ++ Entity/Generate/ConfigTable/TbBait.cs | 58 + Entity/Generate/ConfigTable/TbBasicConfig.cs | 58 + Entity/Generate/ConfigTable/TbBobber.cs | 58 + Entity/Generate/ConfigTable/TbFeeder.cs | 58 + Entity/Generate/ConfigTable/TbFish.cs | 58 + Entity/Generate/ConfigTable/TbGoods.cs | 58 + Entity/Generate/ConfigTable/TbHook.cs | 58 + .../Generate/ConfigTable/TbInitItemConfig.cs | 58 + Entity/Generate/ConfigTable/TbItem.cs | 58 + Entity/Generate/ConfigTable/TbLine.cs | 58 + Entity/Generate/ConfigTable/TbLure.cs | 58 + Entity/Generate/ConfigTable/TbReel.cs | 58 + Entity/Generate/ConfigTable/TbRod.cs | 58 + Entity/Generate/ConfigTable/TbShop.cs | 58 + Entity/Generate/ConfigTable/vector2.cs | 50 + Entity/Generate/ConfigTable/vector3.cs | 53 + Entity/Generate/ConfigTable/vector4.cs | 56 + .../Generate/NetworkProtocol/InnerMessage.cs | 89 + .../Generate/NetworkProtocol/InnerOpcode.cs | 2 + .../Generate/NetworkProtocol/OuterMessage.cs | 407 ++++- .../Generate/NetworkProtocol/OuterOpcode.cs | 51 +- Entity/Modules/ConfigTable/Configs.cs | 20 + .../ConfigTable/Interface/IConfigTable.cs | 2 +- Entity/Social/Chat/ChatChannel.cs | 51 - .../Social/Chat/ChatChannelCenterComponent.cs | 12 - .../Components/ChatChannelCenterComponent.cs | 14 + .../Chat/Components/ChatChannelComponent.cs | 14 + Entity/Social/Chat/Enum/ChatChannelType.cs | 50 + Entity/Social/Chat/Model/ChatInfoTree.cs | 17 + Entity/Social/Chat/Model/ChatUnit.cs | 11 + Entity/Social/SocialUnit.cs | 10 +- .../Handler/G2Common_EnterRequestHandler.cs | 1 + .../Handler/G2Common_ExitRequestHandler.cs | 1 + Hotfix/Game/Item/Helper/ItemFactory.cs | 2 +- Hotfix/Game/Item/Helper/ItemHelper.cs | 2 +- .../PlayerItemContainerComponentSystem.cs | 4 +- .../Components/PlayerManageComponentSystem.cs | 13 +- Hotfix/Game/Player/Entity/PlayerSystem.cs | 2 +- .../Wallet/PlayerWalletComponentSystem.cs | 6 +- Hotfix/Hotfix.csproj | 4 + Hotfix/OnCreateSceneEvent.cs | 4 +- .../C2S_CreateChannelRequestHandler.cs | 28 - .../C2S_GetOfflineMessageRequestHandler.cs | 24 - .../Handler/C2S_JoinChannelRequestHandler.cs | 61 - .../Handler/C2S_SendMessageRequestHandler.cs | 156 -- .../Inner/G2Chat_LoginRequestHandler.cs | 21 + .../Inner/G2Chat_OfflineRequestHandler.cs | 13 + .../Inner/Other2Chat_ChatMessageHandler.cs | 20 + .../Outer/C2Chat_SendMessageRequestHandler.cs | 14 + .../Chat/Helper/ChatChannelCenterHelper.cs | 39 + Hotfix/Social/Chat/Helper/ChatHelper.cs | 30 + Hotfix/Social/Chat/Helper/ChatNodeFactory.cs | 128 ++ Hotfix/Social/Chat/Helper/ChatSceneHelper.cs | 258 +++ Hotfix/Social/Chat/Helper/ChatTreeFactory.cs | 121 ++ Hotfix/Social/Chat/Helper/ChatUnitFactory.cs | 20 - .../Social/Chat/Helper/SocialSceneHelper.cs | 173 -- .../ChatChannelCenterComponentSystem.cs | 62 +- .../Chat/System/ChatChannelComponentSystem.cs | 89 + .../Social/Chat/System/ChatChannelSystem.cs | 28 - .../System/ChatUnitManageComponentSystem.cs | 200 +-- Hotfix/Social/Chat/System/ChatUnitSystem.cs | 11 - .../Handler/C2S_SendMailRequestHandler.cs | 14 +- .../Social/SocialUnitManageComponentSystem.cs | 146 ++ Hotfix/Social/SocialUnitSystem.cs | 22 + Main/Main.csproj | 42 + Main/Program.cs | 4 +- Main/cfg/tbbait.json | 39 + Main/cfg/tbbasicconfig.json | 16 + Main/cfg/tbbobber.json | 30 + Main/cfg/tbfeeder.json | 7 + Main/cfg/tbfish.json | 30 + Main/cfg/tbgoods.json | 1290 +++++++++++++ Main/cfg/tbhook.json | 22 + Main/cfg/tbinititemconfig.json | 386 ++++ Main/cfg/tbitem.json | 1118 ++++++++++++ Main/cfg/tbline.json | 12 + Main/cfg/tblure.json | 34 + Main/cfg/tbreel.json | 66 + Main/cfg/tbrod.json | 90 + Main/cfg/tbshop.json | 1290 +++++++++++++ ThirdParty/Luban/BeanBase.cs | 28 + ThirdParty/Luban/ByteBuf.cs | 1588 +++++++++++++++++ ThirdParty/Luban/StringUtil.cs | 73 + ThirdParty/ThirdParty.csproj | 1 + .../NetworkProtocol/Inner/InnerMessage.proto | 16 + .../NetworkProtocol/Outer/SocialMessage.proto | 73 + .../Outer/data/CommonProtoData.proto | 12 +- 122 files changed, 10497 insertions(+), 2216 deletions(-) create mode 100644 CODELY.md create mode 100644 Entity/Generate/ConfigTable/Bait.cs create mode 100644 Entity/Generate/ConfigTable/BasicConfig.cs create mode 100644 Entity/Generate/ConfigTable/Bobber.cs delete mode 100644 Entity/Generate/ConfigTable/Entity/BaitConfig.cs delete mode 100644 Entity/Generate/ConfigTable/Entity/BasicConfig.cs delete mode 100644 Entity/Generate/ConfigTable/Entity/BobberConfig.cs delete mode 100644 Entity/Generate/ConfigTable/Entity/FeederConfig.cs delete mode 100644 Entity/Generate/ConfigTable/Entity/FishConfig.cs delete mode 100644 Entity/Generate/ConfigTable/Entity/GoodsConfig.cs delete mode 100644 Entity/Generate/ConfigTable/Entity/HookConfig.cs delete mode 100644 Entity/Generate/ConfigTable/Entity/InitConfig.cs delete mode 100644 Entity/Generate/ConfigTable/Entity/ItemConfig.cs delete mode 100644 Entity/Generate/ConfigTable/Entity/LineConfig.cs delete mode 100644 Entity/Generate/ConfigTable/Entity/LureConfig.cs delete mode 100644 Entity/Generate/ConfigTable/Entity/ReelConfig.cs delete mode 100644 Entity/Generate/ConfigTable/Entity/RingConfig.cs delete mode 100644 Entity/Generate/ConfigTable/Entity/RodConfig.cs delete mode 100644 Entity/Generate/ConfigTable/Entity/RodRingConfig.cs delete mode 100644 Entity/Generate/ConfigTable/Entity/WeightConfig.cs create mode 100644 Entity/Generate/ConfigTable/Feeder.cs create mode 100644 Entity/Generate/ConfigTable/Fish.cs create mode 100644 Entity/Generate/ConfigTable/Goods.cs create mode 100644 Entity/Generate/ConfigTable/Hook.cs create mode 100644 Entity/Generate/ConfigTable/InitItemConfig.cs create mode 100644 Entity/Generate/ConfigTable/Item.cs create mode 100644 Entity/Generate/ConfigTable/Line.cs create mode 100644 Entity/Generate/ConfigTable/Lure.cs create mode 100644 Entity/Generate/ConfigTable/Reel.cs create mode 100644 Entity/Generate/ConfigTable/Rod.cs create mode 100644 Entity/Generate/ConfigTable/Shop.cs create mode 100644 Entity/Generate/ConfigTable/Tables.cs create mode 100644 Entity/Generate/ConfigTable/TbBait.cs create mode 100644 Entity/Generate/ConfigTable/TbBasicConfig.cs create mode 100644 Entity/Generate/ConfigTable/TbBobber.cs create mode 100644 Entity/Generate/ConfigTable/TbFeeder.cs create mode 100644 Entity/Generate/ConfigTable/TbFish.cs create mode 100644 Entity/Generate/ConfigTable/TbGoods.cs create mode 100644 Entity/Generate/ConfigTable/TbHook.cs create mode 100644 Entity/Generate/ConfigTable/TbInitItemConfig.cs create mode 100644 Entity/Generate/ConfigTable/TbItem.cs create mode 100644 Entity/Generate/ConfigTable/TbLine.cs create mode 100644 Entity/Generate/ConfigTable/TbLure.cs create mode 100644 Entity/Generate/ConfigTable/TbReel.cs create mode 100644 Entity/Generate/ConfigTable/TbRod.cs create mode 100644 Entity/Generate/ConfigTable/TbShop.cs create mode 100644 Entity/Generate/ConfigTable/vector2.cs create mode 100644 Entity/Generate/ConfigTable/vector3.cs create mode 100644 Entity/Generate/ConfigTable/vector4.cs create mode 100644 Entity/Modules/ConfigTable/Configs.cs delete mode 100644 Entity/Social/Chat/ChatChannel.cs delete mode 100644 Entity/Social/Chat/ChatChannelCenterComponent.cs create mode 100644 Entity/Social/Chat/Components/ChatChannelCenterComponent.cs create mode 100644 Entity/Social/Chat/Components/ChatChannelComponent.cs create mode 100644 Entity/Social/Chat/Enum/ChatChannelType.cs create mode 100644 Entity/Social/Chat/Model/ChatInfoTree.cs create mode 100644 Entity/Social/Chat/Model/ChatUnit.cs delete mode 100644 Hotfix/Social/Chat/Handler/C2S_CreateChannelRequestHandler.cs delete mode 100644 Hotfix/Social/Chat/Handler/C2S_GetOfflineMessageRequestHandler.cs delete mode 100644 Hotfix/Social/Chat/Handler/C2S_JoinChannelRequestHandler.cs delete mode 100644 Hotfix/Social/Chat/Handler/C2S_SendMessageRequestHandler.cs create mode 100644 Hotfix/Social/Chat/Handler/Inner/G2Chat_LoginRequestHandler.cs create mode 100644 Hotfix/Social/Chat/Handler/Inner/G2Chat_OfflineRequestHandler.cs create mode 100644 Hotfix/Social/Chat/Handler/Inner/Other2Chat_ChatMessageHandler.cs create mode 100644 Hotfix/Social/Chat/Handler/Outer/C2Chat_SendMessageRequestHandler.cs create mode 100644 Hotfix/Social/Chat/Helper/ChatChannelCenterHelper.cs create mode 100644 Hotfix/Social/Chat/Helper/ChatHelper.cs create mode 100644 Hotfix/Social/Chat/Helper/ChatNodeFactory.cs create mode 100644 Hotfix/Social/Chat/Helper/ChatSceneHelper.cs create mode 100644 Hotfix/Social/Chat/Helper/ChatTreeFactory.cs delete mode 100644 Hotfix/Social/Chat/Helper/ChatUnitFactory.cs delete mode 100644 Hotfix/Social/Chat/Helper/SocialSceneHelper.cs create mode 100644 Hotfix/Social/Chat/System/ChatChannelComponentSystem.cs delete mode 100644 Hotfix/Social/Chat/System/ChatChannelSystem.cs delete mode 100644 Hotfix/Social/Chat/System/ChatUnitSystem.cs create mode 100644 Hotfix/Social/SocialUnitManageComponentSystem.cs create mode 100644 Hotfix/Social/SocialUnitSystem.cs create mode 100644 Main/cfg/tbbait.json create mode 100644 Main/cfg/tbbasicconfig.json create mode 100644 Main/cfg/tbbobber.json create mode 100644 Main/cfg/tbfeeder.json create mode 100644 Main/cfg/tbfish.json create mode 100644 Main/cfg/tbgoods.json create mode 100644 Main/cfg/tbhook.json create mode 100644 Main/cfg/tbinititemconfig.json create mode 100644 Main/cfg/tbitem.json create mode 100644 Main/cfg/tbline.json create mode 100644 Main/cfg/tblure.json create mode 100644 Main/cfg/tbreel.json create mode 100644 Main/cfg/tbrod.json create mode 100644 Main/cfg/tbshop.json create mode 100644 ThirdParty/Luban/BeanBase.cs create mode 100644 ThirdParty/Luban/ByteBuf.cs create mode 100644 ThirdParty/Luban/StringUtil.cs diff --git a/CODELY.md b/CODELY.md new file mode 100644 index 0000000..539a001 --- /dev/null +++ b/CODELY.md @@ -0,0 +1,441 @@ +# Fishing2Server 项目文档 + +## 项目概述 + +Fishing2Server 是一个基于 **Fantasy.Net** 框架开发的分布式钓鱼游戏服务器。采用 .NET 9.0 构建,使用 MongoDB 作为数据库存储,支持热更新机制。 + +### 技术栈 + +- **.NET 版本**: .NET 9.0 +- **框架**: Fantasy.Net (v2025.2.1423) - 分布式游戏服务器框架 +- **数据库**: MongoDB +- **日志系统**: NLog +- **网络协议**: TCP (内部通信), KCP (外部通信) +- **身份认证**: JWT (System.IdentityModel.Tokens.Jwt v8.14.0) +- **序列化**: LightProto, MemoryPack +- **第三方库**: Unity.Mathematics + +### 项目架构 + +项目采用分层架构,包含四个主要项目: + +| 项目 | 命名空间 | 说明 | +|------|---------|------| +| Main | NBF | 应用程序入口,负责初始化和启动框架 | +| Entity | NB | 实体层,定义所有数据结构和实体 | +| Hotfix | NB | 热更新层,包含所有业务逻辑、Handler 和 System | +| ThirdParty | - | 第三方依赖库(Unity.Mathematics) | + +## 项目结构 + +``` +Fishing2Server/ +├── Main/ # 主程序入口 +│ ├── Program.cs # 应用程序入口点 +│ ├── NLog.config # 日志配置 +│ ├── configs.json # 游戏配置(物品、鱼竿等) +│ └── Fantasy.config # Fantasy 框架配置 +├── Entity/ # 实体层(数据定义) +│ ├── Authentication/ # 认证相关实体 +│ ├── Game/ # 游戏实体 +│ │ ├── Player/ # 玩家实体 +│ │ ├── Item/ # 物品系统 +│ │ ├── Map/ # 地图和房间系统 +│ │ ├── Fish/ # 钓鱼系统 +│ │ ├── Skill/ # 技能系统 +│ │ ├── Mission/ # 任务系统 +│ │ ├── Achievement/ # 成就系统 +│ │ ├── Cache/ # 玩家缓存 +│ │ ├── Statistics/ # 统计数据 +│ │ └── Activity/ # 活动系统 +│ ├── Gate/ # 网关实体 +│ ├── Social/ # 社交实体 +│ │ ├── Chat/ # 聊天系统 +│ │ ├── Club/ # 俱乐部系统 +│ │ └── Mail/ # 邮件系统 +│ ├── Def/ # 配置定义 +│ ├── Generate/ # 自动生成的代码 +│ │ ├── NetworkProtocol/ # 网络协议定义 +│ │ └── ConfigTable/ # 配置表代码 +│ └── Modules/ # 配置表模块 +├── Hotfix/ # 热更新层(业务逻辑) +│ ├── Authentication/ # 认证逻辑 +│ │ ├── Handler/ # 认证消息处理器 +│ │ └── System/ # 认证系统 +│ ├── Game/ # 游戏业务逻辑 +│ │ ├── Handler/ # 游戏消息处理器 +│ │ ├── Item/ # 物品逻辑 +│ │ ├── Map/ # 地图逻辑 +│ │ ├── Player/ # 玩家逻辑 +│ │ ├── Wallet/ # 钱包逻辑 +│ │ └── Cache/ # 缓存逻辑 +│ ├── Gate/ # 网关业务逻辑 +│ │ ├── Handler/ # 网关消息处理器 +│ │ │ ├── Inner/ # 内部消息 +│ │ │ └── Outer/ # 外部消息 +│ │ └── System/ # 网关系统 +│ ├── Social/ # 社交业务逻辑 +│ │ ├── Chat/ # 聊天逻辑 +│ │ ├── Mail/ # 邮件逻辑 +│ │ └── Club/ # 俱乐部逻辑 +│ ├── Common/ # 通用逻辑 +│ └── HTTPHandler/ # HTTP 接口 +├── ThirdParty/ # 第三方库 +└── Tools/ # 工具集 + ├── NetworkProtocol/ # 协议配置 + └── ProtocolExportTool/ # 协议导出工具 +``` + +## 服务器架构 + +### 场景类型(Scene Types) + +服务器采用分布式场景架构,包含以下场景类型: + +| Scene ID | 场景类型 | 外网端口 | 内网端口 | 说明 | +|----------|---------|---------|---------|------| +| 1001 | Authentication | 20001 | 11001 | 登录认证服务器(KCP) | +| 1002 | Addressable | - | 11011 | 地址服务器 | +| 1003 | Gate | 20000 | 11021 | 网关服务器(KCP) | +| 1004 | Game | - | 11031 | 游戏逻辑服务器 | +| 1006 | Social | - | 11051 | 社交服务器 | +| 1007 | Map | - | 11061 | 地图服务器(已注释) | + +### 登录流程 + +1. 客户端连接到 **Authentication** 服务器(端口 20001) +2. 用户名密码验证,支持自动注册 +3. 验证成功后颁发 JWT Token +4. 客户端使用 Token 连接到 **Gate** 服务器(端口 20000) +5. Gate 验证 Token 并建立会话 +6. 客户端通过 Gate 与其他服务器通信 + +### 通信架构 + +- **内部通信**: 使用 TCP 协议,各服务器之间通过 Scene ID 路由 +- **外部通信**: 使用 KCP 协议,客户端通过 Gate 服务器连接 +- **消息路由**: 支持自定义路由(ICustomRouteRequest 接口) + +## 构建和运行 + +### 前置要求 + +- .NET 9.0 SDK +- MongoDB 服务器 +- Visual Studio 2022 或 Rider + +### 构建项目 + +```bash +# 构建整个解决方案 +dotnet build Server.sln + +# 构建特定项目 +dotnet build Main/Main.csproj +dotnet build Entity/Entity.csproj +dotnet build Hotfix/Hotfix.csproj +``` + +### 运行项目 + +```bash +# 运行主程序 +dotnet run --project Main/Main.csproj + +# 或直接编译运行 +cd Main/bin/Debug/net9.0 +Main.exe +``` + +### 配置说明 + +#### 1. MongoDB 配置 + +在 `Entity/Fantasy.config` 中配置数据库连接: + +```xml + +``` + +#### 2. 服务器配置 + +在 `Entity/Fantasy.config` 中配置服务器地址: + +```xml + + + +``` + +#### 3. 日志配置 + +在 `Main/NLog.config` 中配置日志输出位置和格式。日志文件保存在: + +``` +Main/bin/Debug/Logs/Server/Server{yyyyMMdd}/{logger}.{appId}.{yyyyMMddHH}.{level}.log +``` + +## 开发规范 + +### 命名约定 + +- **命名空间**: + - Entity 层使用 `NB` 前缀(如 `NB.Game`, `NB.Authentication`) + - Hotfix 层使用 `NB` 前缀(如 `NB.Game`, `NB.Gate`) +- **Handler**: 使用 `{RequestType}Handler` 格式(如 `C2A_LoginRequestHandler`) +- **System**: 使用 `{Entity}System` 格式(如 `PlayerSystem`, `MapSystem`) +- **Helper**: 使用 `{Module}Helper` 格式(如 `AuthenticationHelper`, `PlayerHelper`) + +### 消息处理 + +所有消息处理器继承自 `MessageRPC`: + +```csharp +public class C2Game_GetItemsRequestHandler : MessageRPC +{ + protected override async FTask Run(Session session, C2Game_GetItemsRequest request, G2C_GetItemsResponse response, Action reply) + { + // 业务逻辑 + response.ErrorCode = ErrorCode.Successful; + } +} +``` + +### 实体系统 + +所有实体继承自 `Entity` 基类: + +```csharp +public sealed class Player : Entity +{ + [BsonElement("name")] public string NickName = ""; + [BsonElement("lv")] public int Level; + [BsonIgnore] public long SessionRunTimeId; +} +``` + +### System 系统 + +- **DestroySystem**: 处理实体销毁逻辑(如 `PlayerDestroySystem`) +- **静态 System**: 扩展方法,提供实体操作(如 `PlayerSystem.AddItems()`) + +### 配置表 + +配置表使用 JSON 格式定义在 `Main/configs.json`,自动生成代码到 `Entity/Generate/ConfigTable/`。 + +常用配置类型: +- `ItemConfig` - 物品配置 +- `LureConfig` - 诱饵配置 +- `RodRingConfig` - 鱼竿环配置 + +## 核心功能模块 + +### 1. 认证系统(Authentication) + +- 账号登录/注册 +- JWT Token 颁发和验证 +- 账号缓存管理 +- 区域选择支持 + +**关键文件**: +- `Entity/Authentication/Entity/Account.cs` +- `Hotfix/Authentication/Handler/C2A_LoginRequestHandler.cs` +- `Hotfix/Authentication/System/AuthenticationHelper.cs` + +### 2. 网关系统(Gate) + +- 客户端连接管理 +- Session 管理 +- 消息路由转发 +- JWT Token 验证 + +**关键文件**: +- `Entity/Gate/GateUnit.cs` +- `Hotfix/Gate/Handler/Outer/C2G_LoginRequestHandler.cs` +- `Hotfix/Gate/System/GateUnitManageComponentSystem.cs` + +### 3. 玩家系统(Player) + +- 玩家基本数据管理 +- 等级和经验系统 +- VIP 系统 +- 玩家缓存 + +**关键文件**: +- `Entity/Game/Player/Player.cs` +- `Hotfix/Game/Player/Helper/PlayerFactory.cs` +- `Hotfix/Game/Player/Entity/PlayerSystem.cs` + +### 4. 物品系统(Item) + +- 物品容器管理 +- 物品添加/使用 +- 物品类型分类 +- 奖励物品处理 + +**关键文件**: +- `Entity/Game/Item/Item.cs` +- `Entity/Game/Item/PlayerItemContainerComponent.cs` +- `Hotfix/Game/Item/ItemSystem.cs` + +### 5. 地图和房间系统(Map) + +- 地图管理 +- 房间创建和销毁 +- 玩家移动和同步 +- 地图单元管理 + +**关键文件**: +- `Entity/Game/Map/Entity/Map.cs` +- `Entity/Game/Map/Entity/MapRoom.cs` +- `Hotfix/Game/Map/Handler/C2Map_CreateRoomRequestHandler.cs` + +### 6. 社交系统(Social) + +#### 聊天系统(Chat) +- 多频道聊天 +- 聊天消息路由 +- 聊天单元管理 + +**关键文件**: +- `Entity/Social/Chat/Model/ChatUnit.cs` +- `Hotfix/Social/Chat/Handler/Outer/C2Chat_SendMessageRequestHandler.cs` + +#### 邮件系统(Mail) +- 邮件发送 +- 邮件箱管理 +- 会话管理 + +**关键文件**: +- `Entity/Social/Mail/Entity/Mail.cs` +- `Entity/Social/Mail/Entity/MailBox.cs` +- `Hotfix/Social/Mail/Handler/C2S_SendMailRequestHandler.cs` + +### 7. 钓鱼系统(Fish) + +- 鱼类数据管理 +- 钓鱼容器 +- 鱼竿和诱饵配置 + +**关键文件**: +- `Entity/Game/Fish/Fish.cs` +- `Entity/Game/Fish/FishContainer.cs` + +## 网络协议 + +### 协议生成 + +网络协议定义在 `Tools/NetworkProtocol/` 目录,使用 `Tools/ProtocolExportTool/` 工具导出。 + +自动生成的代码位于: +- `Entity/Generate/NetworkProtocol/OuterMessage.cs` - 外部消息(客户端-服务器) +- `Entity/Generate/NetworkProtocol/InnerMessage.cs` - 内部消息(服务器-服务器) + +### 消息命名约定 + +- `C2X_Request` - 客户端到服务器请求 +- `X2C_Response` - 服务器到客户端响应 +- `X2Y_Request` - 服务器间请求 + +例如: +- `C2A_LoginRequest` - 客户端到认证服务器登录请求 +- `A2C_LoginResponse` - 认证服务器到客户端登录响应 +- `G2Map_EnterMapRequest` - 网关到地图服务器进入地图请求 + +## 日志系统 + +### 日志级别 + +- **Trace**: 最详细的调试信息 +- **Debug**: 调试信息 +- **Info**: 一般信息 +- **Warn**: 警告信息 +- **Error**: 错误信息 +- **Fatal**: 致命错误 + +### 日志使用 + +```csharp +using Fantasy; + +Log.Debug("调试信息"); +Log.Info("一般信息"); +Log.Warn("警告信息"); +Log.Error("错误信息"); +``` + +### 日志输出位置 + +- **控制台**: 开发环境彩色输出 +- **文件**: 生产环境按日期和级别分类存储 + +## 热更新机制 + +项目支持热更新,Hotfix 层可以动态加载和卸载。热更新逻辑位于 `Hotfix/` 目录。 + +### Hotfix 层特点 + +- 不包含实体定义(Entity 层) +- 包含所有 Handler、System 和 Helper +- 可以独立编译和部署 + +## 常见问题 + +### 1. 如何添加新的消息处理器? + +1. 在 `Tools/NetworkProtocol/` 定义消息结构 +2. 运行协议导出工具生成代码 +3. 在 `Hotfix/{Module}/Handler/` 创建 Handler 类 +4. 继承 `MessageRPC` + +### 2. 如何添加新的实体? + +1. 在 `Entity/{Module}/Entity/` 创建实体类 +2. 继承 `Entity` 基类 +3. 在 `Hotfix/{Module}/` 创建对应的 System + +### 3. 如何配置数据库? + +修改 `Entity/Fantasy.config` 中的数据库连接字符串: + +```xml + +``` + +### 4. 如何修改服务器端口? + +修改 `Entity/Fantasy.config` 中对应场景的端口配置: + +```xml + +``` + +## 开发工具 + +### 协议导出工具 + +位置: `Tools/ProtocolExportTool/` + +用于从配置文件导出网络协议代码。 + +### 配置表工具 + +配置表定义在 `Main/configs.json`,代码自动生成到 `Entity/Generate/ConfigTable/`。 + +## 贡献指南 + +1. 遵循现有的命名约定和代码风格 +2. 添加必要的注释和文档 +3. 确保代码编译通过 +4. 测试新功能 +5. 更新相关文档 + +## 许可证 + +本项目为内部项目,版权所有。 + +--- + +**文档版本**: 1.0 +**最后更新**: 2026-03-05 +**维护者**: Fishing2Server Team \ No newline at end of file diff --git a/Entity/Entity.csproj b/Entity/Entity.csproj index 4e906b2..27c7775 100644 --- a/Entity/Entity.csproj +++ b/Entity/Entity.csproj @@ -9,7 +9,7 @@ - + @@ -20,6 +20,7 @@ + diff --git a/Entity/Game/Item/Item.cs b/Entity/Game/Item/Item.cs index 9b371cb..86f2e20 100644 --- a/Entity/Game/Item/Item.cs +++ b/Entity/Game/Item/Item.cs @@ -29,7 +29,7 @@ public class Item : Entity /// /// 配置id /// - [BsonElement("cid")] public uint ConfigId; + [BsonElement("cid")] public int ConfigId; /// /// 是否绑定 diff --git a/Entity/Game/Player/PlayerWalletComponent.cs b/Entity/Game/Player/PlayerWalletComponent.cs index 8a24328..f856cf9 100644 --- a/Entity/Game/Player/PlayerWalletComponent.cs +++ b/Entity/Game/Player/PlayerWalletComponent.cs @@ -14,5 +14,5 @@ public class PlayerWalletComponent : Entity /// 所有货币 /// [BsonDictionaryOptions(DictionaryRepresentation.ArrayOfArrays)] - public Dictionary Currency = new(); + public Dictionary Currency = new(); } \ No newline at end of file diff --git a/Entity/Generate/ConfigTable/Bait.cs b/Entity/Generate/ConfigTable/Bait.cs new file mode 100644 index 0000000..9caf575 --- /dev/null +++ b/Entity/Generate/ConfigTable/Bait.cs @@ -0,0 +1,70 @@ + +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +using Luban; +using Newtonsoft.Json.Linq; + + + +namespace cfg +{ + +public sealed partial class Bait : Luban.BeanBase +{ + public Bait(JToken _buf) + { + JObject _obj = _buf as JObject; + Id = (int)_obj.GetValue("id"); + EfficacyBase = (int)_obj.GetValue("efficacy_base"); + { var __json0 = _obj.GetValue("arr"); Arr = new System.Collections.Generic.List((__json0 as JArray).Count); foreach(JToken __e0 in __json0) { int __v0; __v0 = (int)__e0; Arr.Add(__v0); } } + Strength = (int)_obj.GetValue("strength"); + } + + public static Bait DeserializeBait(JToken _buf) + { + return new Bait(_buf); + } + + /// + /// Id + /// + public readonly int Id; + /// + /// 吸引力 + /// + public readonly int EfficacyBase; + /// + /// 导线圈 + /// + public readonly System.Collections.Generic.List Arr; + /// + /// 强度 + /// + public readonly int Strength; + + + public const int __ID__ = 2062794; + public override int GetTypeId() => __ID__; + + public void ResolveRef(Tables tables) + { + } + + public override string ToString() + { + return "{ " + + "id:" + Id + "," + + "efficacyBase:" + EfficacyBase + "," + + "arr:" + Luban.StringUtil.CollectionToString(Arr) + "," + + "strength:" + Strength + "," + + "}"; + } +} +} + diff --git a/Entity/Generate/ConfigTable/BasicConfig.cs b/Entity/Generate/ConfigTable/BasicConfig.cs new file mode 100644 index 0000000..00bfecf --- /dev/null +++ b/Entity/Generate/ConfigTable/BasicConfig.cs @@ -0,0 +1,73 @@ + +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +using Luban; +using Newtonsoft.Json.Linq; + + + +namespace cfg +{ + +public sealed partial class BasicConfig : Luban.BeanBase +{ + public BasicConfig(JToken _buf) + { + JObject _obj = _buf as JObject; + X1 = (int)_obj.GetValue("x1"); + X2 = (int)_obj.GetValue("x2"); + X3 = (int)_obj.GetValue("x3"); + X4 = (int)_obj.GetValue("x4"); + X5 = (int)_obj.GetValue("x5"); + X6 = (int)_obj.GetValue("x6"); + { var __json0 = _obj.GetValue("x7"); X7 = new System.Collections.Generic.List((__json0 as JArray).Count); foreach(JToken __e0 in __json0) { int __v0; __v0 = (int)__e0; X7.Add(__v0); } } + } + + public static BasicConfig DeserializeBasicConfig(JToken _buf) + { + return new BasicConfig(_buf); + } + + /// + /// 参数1 + /// + public readonly int X1; + /// + /// 道具 + /// + public readonly int X2; + public readonly int X3; + public readonly int X4; + public readonly int X5; + public readonly int X6; + public readonly System.Collections.Generic.List X7; + + + public const int __ID__ = 378573040; + public override int GetTypeId() => __ID__; + + public void ResolveRef(Tables tables) + { + } + + public override string ToString() + { + return "{ " + + "x1:" + X1 + "," + + "x2:" + X2 + "," + + "x3:" + X3 + "," + + "x4:" + X4 + "," + + "x5:" + X5 + "," + + "x6:" + X6 + "," + + "x7:" + Luban.StringUtil.CollectionToString(X7) + "," + + "}"; + } +} +} + diff --git a/Entity/Generate/ConfigTable/Bobber.cs b/Entity/Generate/ConfigTable/Bobber.cs new file mode 100644 index 0000000..f330eb8 --- /dev/null +++ b/Entity/Generate/ConfigTable/Bobber.cs @@ -0,0 +1,64 @@ + +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +using Luban; +using Newtonsoft.Json.Linq; + + + +namespace cfg +{ + +public sealed partial class Bobber : Luban.BeanBase +{ + public Bobber(JToken _buf) + { + JObject _obj = _buf as JObject; + Id = (int)_obj.GetValue("id"); + Displacement = (int)_obj.GetValue("displacement"); + { var __json0 = _obj.GetValue("night_light"); NightLight = new System.Collections.Generic.List((__json0 as JArray).Count); foreach(JToken __e0 in __json0) { float __v0; __v0 = (float)__e0; NightLight.Add(__v0); } } + } + + public static Bobber DeserializeBobber(JToken _buf) + { + return new Bobber(_buf); + } + + /// + /// Id + /// + public readonly int Id; + /// + /// 位移 + /// + public readonly int Displacement; + /// + /// 是否夜光 + /// + public readonly System.Collections.Generic.List NightLight; + + + public const int __ID__ = 1995051738; + public override int GetTypeId() => __ID__; + + public void ResolveRef(Tables tables) + { + } + + public override string ToString() + { + return "{ " + + "id:" + Id + "," + + "displacement:" + Displacement + "," + + "nightLight:" + Luban.StringUtil.CollectionToString(NightLight) + "," + + "}"; + } +} +} + diff --git a/Entity/Generate/ConfigTable/Entity/BaitConfig.cs b/Entity/Generate/ConfigTable/Entity/BaitConfig.cs deleted file mode 100644 index e8c4232..0000000 --- a/Entity/Generate/ConfigTable/Entity/BaitConfig.cs +++ /dev/null @@ -1,87 +0,0 @@ -using System; -using LightProto; -using Fantasy; -using System.Linq; -using System.Reflection; -using System.Collections.Generic; -using System.Collections.Concurrent; -using Fantasy.Serialize; -using NBF.ConfigTable; - -namespace NBF -{ - [ProtoContract] - public sealed partial class BaitConfig : ASerialize, IConfigTable - { - - [ProtoMember(1)] - public uint Id { get; set; } // Id - [ProtoMember(2)] - public uint EfficacyBase { get; set; } // 吸引力 - [ProtoMember(3)] - public uint[] Arr { get; set; } = Array.Empty(); // 重量(克) - [ProtoMember(4)] - public string[] ArrStr { get; set; } = Array.Empty(); // 重量(克) - [ProtoIgnore] - public uint Key => Id; - - #region Static - - private static ConfigContext Context => ConfigTableHelper.Table(); - - public static BaitConfig Get(uint key) - { - return Context.Get(key); - } - - public static BaitConfig Get(Predicate match) - { - return Context.Get(match); - } - - public static BaitConfig Fist() - { - return Context.Fist(); - } - - public static BaitConfig Last() - { - return Context.Last(); - } - - public static BaitConfig Fist(Predicate match) - { - return Context.Fist(match); - } - - public static BaitConfig Last(Predicate match) - { - return Context.Last(match); - } - - public static int Count() - { - return Context.Count(); - } - - public static int Count(Func predicate) - { - return Context.Count(predicate); - } - - public static List GetList() - { - return Context.GetList(); - } - - public static List GetList(Predicate match) - { - return Context.GetList(match); - } - public static void ParseJson(Newtonsoft.Json.Linq.JArray arr) - { - ConfigTableHelper.ParseLine(arr); - } - #endregion - } -} \ No newline at end of file diff --git a/Entity/Generate/ConfigTable/Entity/BasicConfig.cs b/Entity/Generate/ConfigTable/Entity/BasicConfig.cs deleted file mode 100644 index da33e55..0000000 --- a/Entity/Generate/ConfigTable/Entity/BasicConfig.cs +++ /dev/null @@ -1,85 +0,0 @@ -using System; -using LightProto; -using Fantasy; -using System.Linq; -using System.Reflection; -using System.Collections.Generic; -using System.Collections.Concurrent; -using Fantasy.Serialize; -using NBF.ConfigTable; - -namespace NBF -{ - [ProtoContract] - public sealed partial class BasicConfig : ASerialize, IConfigTable - { - - [ProtoMember(1)] - public uint Id { get; set; } // Id - [ProtoMember(2)] - public string Name { get; set; } // 参数名 - [ProtoMember(3)] - public string[] Val { get; set; } = Array.Empty(); // 参数值 - [ProtoIgnore] - public uint Key => Id; - - #region Static - - private static ConfigContext Context => ConfigTableHelper.Table(); - - public static BasicConfig Get(uint key) - { - return Context.Get(key); - } - - public static BasicConfig Get(Predicate match) - { - return Context.Get(match); - } - - public static BasicConfig Fist() - { - return Context.Fist(); - } - - public static BasicConfig Last() - { - return Context.Last(); - } - - public static BasicConfig Fist(Predicate match) - { - return Context.Fist(match); - } - - public static BasicConfig Last(Predicate match) - { - return Context.Last(match); - } - - public static int Count() - { - return Context.Count(); - } - - public static int Count(Func predicate) - { - return Context.Count(predicate); - } - - public static List GetList() - { - return Context.GetList(); - } - - public static List GetList(Predicate match) - { - return Context.GetList(match); - } - public static void ParseJson(Newtonsoft.Json.Linq.JArray arr) - { - ConfigTableHelper.ParseLine(arr); - } - #endregion - } -} \ No newline at end of file diff --git a/Entity/Generate/ConfigTable/Entity/BobberConfig.cs b/Entity/Generate/ConfigTable/Entity/BobberConfig.cs deleted file mode 100644 index eb715bf..0000000 --- a/Entity/Generate/ConfigTable/Entity/BobberConfig.cs +++ /dev/null @@ -1,85 +0,0 @@ -using System; -using LightProto; -using Fantasy; -using System.Linq; -using System.Reflection; -using System.Collections.Generic; -using System.Collections.Concurrent; -using Fantasy.Serialize; -using NBF.ConfigTable; - -namespace NBF -{ - [ProtoContract] - public sealed partial class BobberConfig : ASerialize, IConfigTable - { - - [ProtoMember(1)] - public uint Id { get; set; } // Id - [ProtoMember(2)] - public uint Displacement { get; set; } // 位移 - [ProtoMember(3)] - public uint NightLight { get; set; } // 是否夜光 - [ProtoIgnore] - public uint Key => Id; - - #region Static - - private static ConfigContext Context => ConfigTableHelper.Table(); - - public static BobberConfig Get(uint key) - { - return Context.Get(key); - } - - public static BobberConfig Get(Predicate match) - { - return Context.Get(match); - } - - public static BobberConfig Fist() - { - return Context.Fist(); - } - - public static BobberConfig Last() - { - return Context.Last(); - } - - public static BobberConfig Fist(Predicate match) - { - return Context.Fist(match); - } - - public static BobberConfig Last(Predicate match) - { - return Context.Last(match); - } - - public static int Count() - { - return Context.Count(); - } - - public static int Count(Func predicate) - { - return Context.Count(predicate); - } - - public static List GetList() - { - return Context.GetList(); - } - - public static List GetList(Predicate match) - { - return Context.GetList(match); - } - public static void ParseJson(Newtonsoft.Json.Linq.JArray arr) - { - ConfigTableHelper.ParseLine(arr); - } - #endregion - } -} \ No newline at end of file diff --git a/Entity/Generate/ConfigTable/Entity/FeederConfig.cs b/Entity/Generate/ConfigTable/Entity/FeederConfig.cs deleted file mode 100644 index c189fe9..0000000 --- a/Entity/Generate/ConfigTable/Entity/FeederConfig.cs +++ /dev/null @@ -1,85 +0,0 @@ -using System; -using LightProto; -using Fantasy; -using System.Linq; -using System.Reflection; -using System.Collections.Generic; -using System.Collections.Concurrent; -using Fantasy.Serialize; -using NBF.ConfigTable; - -namespace NBF -{ - [ProtoContract] - public sealed partial class FeederConfig : ASerialize, IConfigTable - { - - [ProtoMember(1)] - public uint Id { get; set; } // Id - [ProtoMember(2)] - public uint Capacity { get; set; } // 能力 - [ProtoMember(3)] - public uint Weight { get; set; } // 重量(克) - [ProtoIgnore] - public uint Key => Id; - - #region Static - - private static ConfigContext Context => ConfigTableHelper.Table(); - - public static FeederConfig Get(uint key) - { - return Context.Get(key); - } - - public static FeederConfig Get(Predicate match) - { - return Context.Get(match); - } - - public static FeederConfig Fist() - { - return Context.Fist(); - } - - public static FeederConfig Last() - { - return Context.Last(); - } - - public static FeederConfig Fist(Predicate match) - { - return Context.Fist(match); - } - - public static FeederConfig Last(Predicate match) - { - return Context.Last(match); - } - - public static int Count() - { - return Context.Count(); - } - - public static int Count(Func predicate) - { - return Context.Count(predicate); - } - - public static List GetList() - { - return Context.GetList(); - } - - public static List GetList(Predicate match) - { - return Context.GetList(match); - } - public static void ParseJson(Newtonsoft.Json.Linq.JArray arr) - { - ConfigTableHelper.ParseLine(arr); - } - #endregion - } -} \ No newline at end of file diff --git a/Entity/Generate/ConfigTable/Entity/FishConfig.cs b/Entity/Generate/ConfigTable/Entity/FishConfig.cs deleted file mode 100644 index 489306c..0000000 --- a/Entity/Generate/ConfigTable/Entity/FishConfig.cs +++ /dev/null @@ -1,93 +0,0 @@ -using System; -using LightProto; -using Fantasy; -using System.Linq; -using System.Reflection; -using System.Collections.Generic; -using System.Collections.Concurrent; -using Fantasy.Serialize; -using NBF.ConfigTable; - -namespace NBF -{ - [ProtoContract] - public sealed partial class FishConfig : ASerialize, IConfigTable - { - - [ProtoMember(1)] - public uint Id { get; set; } // Id - [ProtoMember(2)] - public string[] Model { get; set; } = Array.Empty(); // 模型 - [ProtoMember(3)] - public uint Type { get; set; } // 类型 - [ProtoMember(4)] - public uint SpeciesName { get; set; } // 鱼类型Id - [ProtoMember(5)] - public uint MinWeight { get; set; } // 最小重量(克) - [ProtoMember(6)] - public uint MaxWeight { get; set; } // 最大重量(克) - [ProtoMember(7)] - public uint Accept { get; set; } // 接受饵 - [ProtoIgnore] - public uint Key => Id; - - #region Static - - private static ConfigContext Context => ConfigTableHelper.Table(); - - public static FishConfig Get(uint key) - { - return Context.Get(key); - } - - public static FishConfig Get(Predicate match) - { - return Context.Get(match); - } - - public static FishConfig Fist() - { - return Context.Fist(); - } - - public static FishConfig Last() - { - return Context.Last(); - } - - public static FishConfig Fist(Predicate match) - { - return Context.Fist(match); - } - - public static FishConfig Last(Predicate match) - { - return Context.Last(match); - } - - public static int Count() - { - return Context.Count(); - } - - public static int Count(Func predicate) - { - return Context.Count(predicate); - } - - public static List GetList() - { - return Context.GetList(); - } - - public static List GetList(Predicate match) - { - return Context.GetList(match); - } - public static void ParseJson(Newtonsoft.Json.Linq.JArray arr) - { - ConfigTableHelper.ParseLine(arr); - } - #endregion - } -} \ No newline at end of file diff --git a/Entity/Generate/ConfigTable/Entity/GoodsConfig.cs b/Entity/Generate/ConfigTable/Entity/GoodsConfig.cs deleted file mode 100644 index a0d821c..0000000 --- a/Entity/Generate/ConfigTable/Entity/GoodsConfig.cs +++ /dev/null @@ -1,97 +0,0 @@ -using System; -using LightProto; -using Fantasy; -using System.Linq; -using System.Reflection; -using System.Collections.Generic; -using System.Collections.Concurrent; -using Fantasy.Serialize; -using NBF.ConfigTable; - -namespace NBF -{ - [ProtoContract] - public sealed partial class GoodsConfig : ASerialize, IConfigTable - { - - [ProtoMember(1)] - public uint Id { get; set; } // Id - [ProtoMember(2)] - public uint[] Shop { get; set; } = Array.Empty(); // 出现商店 - [ProtoMember(3)] - public uint Group { get; set; } // 组 - [ProtoMember(4)] - public string[] Items { get; set; } = Array.Empty(); // 物品 - [ProtoMember(5)] - public uint Price1 { get; set; } // 银币价格 - [ProtoMember(6)] - public uint Price2 { get; set; } // 金币价格 - [ProtoMember(7)] - public uint[] Label { get; set; } = Array.Empty(); // 标签 - [ProtoMember(8)] - public uint Number { get; set; } // 可购买数量 - [ProtoMember(9)] - public uint Disable { get; set; } // 禁用状态 - [ProtoIgnore] - public uint Key => Id; - - #region Static - - private static ConfigContext Context => ConfigTableHelper.Table(); - - public static GoodsConfig Get(uint key) - { - return Context.Get(key); - } - - public static GoodsConfig Get(Predicate match) - { - return Context.Get(match); - } - - public static GoodsConfig Fist() - { - return Context.Fist(); - } - - public static GoodsConfig Last() - { - return Context.Last(); - } - - public static GoodsConfig Fist(Predicate match) - { - return Context.Fist(match); - } - - public static GoodsConfig Last(Predicate match) - { - return Context.Last(match); - } - - public static int Count() - { - return Context.Count(); - } - - public static int Count(Func predicate) - { - return Context.Count(predicate); - } - - public static List GetList() - { - return Context.GetList(); - } - - public static List GetList(Predicate match) - { - return Context.GetList(match); - } - public static void ParseJson(Newtonsoft.Json.Linq.JArray arr) - { - ConfigTableHelper.ParseLine(arr); - } - #endregion - } -} \ No newline at end of file diff --git a/Entity/Generate/ConfigTable/Entity/HookConfig.cs b/Entity/Generate/ConfigTable/Entity/HookConfig.cs deleted file mode 100644 index a5e2581..0000000 --- a/Entity/Generate/ConfigTable/Entity/HookConfig.cs +++ /dev/null @@ -1,83 +0,0 @@ -using System; -using LightProto; -using Fantasy; -using System.Linq; -using System.Reflection; -using System.Collections.Generic; -using System.Collections.Concurrent; -using Fantasy.Serialize; -using NBF.ConfigTable; - -namespace NBF -{ - [ProtoContract] - public sealed partial class HookConfig : ASerialize, IConfigTable - { - - [ProtoMember(1)] - public uint Id { get; set; } // Id - [ProtoMember(2)] - public uint Zadzior { get; set; } // 长钉 - [ProtoIgnore] - public uint Key => Id; - - #region Static - - private static ConfigContext Context => ConfigTableHelper.Table(); - - public static HookConfig Get(uint key) - { - return Context.Get(key); - } - - public static HookConfig Get(Predicate match) - { - return Context.Get(match); - } - - public static HookConfig Fist() - { - return Context.Fist(); - } - - public static HookConfig Last() - { - return Context.Last(); - } - - public static HookConfig Fist(Predicate match) - { - return Context.Fist(match); - } - - public static HookConfig Last(Predicate match) - { - return Context.Last(match); - } - - public static int Count() - { - return Context.Count(); - } - - public static int Count(Func predicate) - { - return Context.Count(predicate); - } - - public static List GetList() - { - return Context.GetList(); - } - - public static List GetList(Predicate match) - { - return Context.GetList(match); - } - public static void ParseJson(Newtonsoft.Json.Linq.JArray arr) - { - ConfigTableHelper.ParseLine(arr); - } - #endregion - } -} \ No newline at end of file diff --git a/Entity/Generate/ConfigTable/Entity/InitConfig.cs b/Entity/Generate/ConfigTable/Entity/InitConfig.cs deleted file mode 100644 index fa11a8f..0000000 --- a/Entity/Generate/ConfigTable/Entity/InitConfig.cs +++ /dev/null @@ -1,83 +0,0 @@ -using System; -using LightProto; -using Fantasy; -using System.Linq; -using System.Reflection; -using System.Collections.Generic; -using System.Collections.Concurrent; -using Fantasy.Serialize; -using NBF.ConfigTable; - -namespace NBF -{ - [ProtoContract] - public sealed partial class InitConfig : ASerialize, IConfigTable - { - - [ProtoMember(1)] - public uint Id { get; set; } // Id - [ProtoMember(2)] - public int Amount { get; set; } // 数量 - [ProtoIgnore] - public uint Key => Id; - - #region Static - - private static ConfigContext Context => ConfigTableHelper.Table(); - - public static InitConfig Get(uint key) - { - return Context.Get(key); - } - - public static InitConfig Get(Predicate match) - { - return Context.Get(match); - } - - public static InitConfig Fist() - { - return Context.Fist(); - } - - public static InitConfig Last() - { - return Context.Last(); - } - - public static InitConfig Fist(Predicate match) - { - return Context.Fist(match); - } - - public static InitConfig Last(Predicate match) - { - return Context.Last(match); - } - - public static int Count() - { - return Context.Count(); - } - - public static int Count(Func predicate) - { - return Context.Count(predicate); - } - - public static List GetList() - { - return Context.GetList(); - } - - public static List GetList(Predicate match) - { - return Context.GetList(match); - } - public static void ParseJson(Newtonsoft.Json.Linq.JArray arr) - { - ConfigTableHelper.ParseLine(arr); - } - #endregion - } -} \ No newline at end of file diff --git a/Entity/Generate/ConfigTable/Entity/ItemConfig.cs b/Entity/Generate/ConfigTable/Entity/ItemConfig.cs deleted file mode 100644 index 06e75b8..0000000 --- a/Entity/Generate/ConfigTable/Entity/ItemConfig.cs +++ /dev/null @@ -1,97 +0,0 @@ -using System; -using LightProto; -using Fantasy; -using System.Linq; -using System.Reflection; -using System.Collections.Generic; -using System.Collections.Concurrent; -using Fantasy.Serialize; -using NBF.ConfigTable; - -namespace NBF -{ - [ProtoContract] - public sealed partial class ItemConfig : ASerialize, IConfigTable - { - - [ProtoMember(1)] - public uint Id { get; set; } // Id - [ProtoMember(2)] - public string Model { get; set; } // 模型 - [ProtoMember(3)] - public uint Type { get; set; } // 子类型 - [ProtoMember(4)] - public uint Quality { get; set; } // 品质 - [ProtoMember(5)] - public uint Brand { get; set; } // 品牌 - [ProtoMember(6)] - public uint Weight { get; set; } // 重量(克) - [ProtoMember(7)] - public uint Length { get; set; } // 长度(毫米) - [ProtoMember(8)] - public uint Max { get; set; } // 最大堆叠数量 - [ProtoMember(9)] - public uint AutoUse { get; set; } // 获得自动使用 - [ProtoIgnore] - public uint Key => Id; - - #region Static - - private static ConfigContext Context => ConfigTableHelper.Table(); - - public static ItemConfig Get(uint key) - { - return Context.Get(key); - } - - public static ItemConfig Get(Predicate match) - { - return Context.Get(match); - } - - public static ItemConfig Fist() - { - return Context.Fist(); - } - - public static ItemConfig Last() - { - return Context.Last(); - } - - public static ItemConfig Fist(Predicate match) - { - return Context.Fist(match); - } - - public static ItemConfig Last(Predicate match) - { - return Context.Last(match); - } - - public static int Count() - { - return Context.Count(); - } - - public static int Count(Func predicate) - { - return Context.Count(predicate); - } - - public static List GetList() - { - return Context.GetList(); - } - - public static List GetList(Predicate match) - { - return Context.GetList(match); - } - public static void ParseJson(Newtonsoft.Json.Linq.JArray arr) - { - ConfigTableHelper.ParseLine(arr); - } - #endregion - } -} \ No newline at end of file diff --git a/Entity/Generate/ConfigTable/Entity/LineConfig.cs b/Entity/Generate/ConfigTable/Entity/LineConfig.cs deleted file mode 100644 index 54a1502..0000000 --- a/Entity/Generate/ConfigTable/Entity/LineConfig.cs +++ /dev/null @@ -1,85 +0,0 @@ -using System; -using LightProto; -using Fantasy; -using System.Linq; -using System.Reflection; -using System.Collections.Generic; -using System.Collections.Concurrent; -using Fantasy.Serialize; -using NBF.ConfigTable; - -namespace NBF -{ - [ProtoContract] - public sealed partial class LineConfig : ASerialize, IConfigTable - { - - [ProtoMember(1)] - public uint Id { get; set; } // Id - [ProtoMember(2)] - public uint Strength { get; set; } // 强度 - [ProtoMember(3)] - public uint Size { get; set; } // 尺寸 - [ProtoIgnore] - public uint Key => Id; - - #region Static - - private static ConfigContext Context => ConfigTableHelper.Table(); - - public static LineConfig Get(uint key) - { - return Context.Get(key); - } - - public static LineConfig Get(Predicate match) - { - return Context.Get(match); - } - - public static LineConfig Fist() - { - return Context.Fist(); - } - - public static LineConfig Last() - { - return Context.Last(); - } - - public static LineConfig Fist(Predicate match) - { - return Context.Fist(match); - } - - public static LineConfig Last(Predicate match) - { - return Context.Last(match); - } - - public static int Count() - { - return Context.Count(); - } - - public static int Count(Func predicate) - { - return Context.Count(predicate); - } - - public static List GetList() - { - return Context.GetList(); - } - - public static List GetList(Predicate match) - { - return Context.GetList(match); - } - public static void ParseJson(Newtonsoft.Json.Linq.JArray arr) - { - ConfigTableHelper.ParseLine(arr); - } - #endregion - } -} \ No newline at end of file diff --git a/Entity/Generate/ConfigTable/Entity/LureConfig.cs b/Entity/Generate/ConfigTable/Entity/LureConfig.cs deleted file mode 100644 index 29f0037..0000000 --- a/Entity/Generate/ConfigTable/Entity/LureConfig.cs +++ /dev/null @@ -1,87 +0,0 @@ -using System; -using LightProto; -using Fantasy; -using System.Linq; -using System.Reflection; -using System.Collections.Generic; -using System.Collections.Concurrent; -using Fantasy.Serialize; -using NBF.ConfigTable; - -namespace NBF -{ - [ProtoContract] - public sealed partial class LureConfig : ASerialize, IConfigTable - { - - [ProtoMember(1)] - public uint Id { get; set; } // Id - [ProtoMember(2)] - public uint[] Hook { get; set; } = Array.Empty(); // 勾 - [ProtoMember(3)] - public uint HookNum { get; set; } // 装配鱼钩数量 - [ProtoMember(4)] - public uint EfficacyBase { get; set; } // 吸引力 - [ProtoIgnore] - public uint Key => Id; - - #region Static - - private static ConfigContext Context => ConfigTableHelper.Table(); - - public static LureConfig Get(uint key) - { - return Context.Get(key); - } - - public static LureConfig Get(Predicate match) - { - return Context.Get(match); - } - - public static LureConfig Fist() - { - return Context.Fist(); - } - - public static LureConfig Last() - { - return Context.Last(); - } - - public static LureConfig Fist(Predicate match) - { - return Context.Fist(match); - } - - public static LureConfig Last(Predicate match) - { - return Context.Last(match); - } - - public static int Count() - { - return Context.Count(); - } - - public static int Count(Func predicate) - { - return Context.Count(predicate); - } - - public static List GetList() - { - return Context.GetList(); - } - - public static List GetList(Predicate match) - { - return Context.GetList(match); - } - public static void ParseJson(Newtonsoft.Json.Linq.JArray arr) - { - ConfigTableHelper.ParseLine(arr); - } - #endregion - } -} \ No newline at end of file diff --git a/Entity/Generate/ConfigTable/Entity/ReelConfig.cs b/Entity/Generate/ConfigTable/Entity/ReelConfig.cs deleted file mode 100644 index 6555e2f..0000000 --- a/Entity/Generate/ConfigTable/Entity/ReelConfig.cs +++ /dev/null @@ -1,87 +0,0 @@ -using System; -using LightProto; -using Fantasy; -using System.Linq; -using System.Reflection; -using System.Collections.Generic; -using System.Collections.Concurrent; -using Fantasy.Serialize; -using NBF.ConfigTable; - -namespace NBF -{ - [ProtoContract] - public sealed partial class ReelConfig : ASerialize, IConfigTable - { - - [ProtoMember(1)] - public uint Id { get; set; } // Id - [ProtoMember(2)] - public uint ReelType { get; set; } // 鱼轮类型 - [ProtoMember(3)] - public float[] GearRatio { get; set; } = Array.Empty(); // 组件比 - [ProtoMember(4)] - public uint Strength { get; set; } // 强度 - [ProtoIgnore] - public uint Key => Id; - - #region Static - - private static ConfigContext Context => ConfigTableHelper.Table(); - - public static ReelConfig Get(uint key) - { - return Context.Get(key); - } - - public static ReelConfig Get(Predicate match) - { - return Context.Get(match); - } - - public static ReelConfig Fist() - { - return Context.Fist(); - } - - public static ReelConfig Last() - { - return Context.Last(); - } - - public static ReelConfig Fist(Predicate match) - { - return Context.Fist(match); - } - - public static ReelConfig Last(Predicate match) - { - return Context.Last(match); - } - - public static int Count() - { - return Context.Count(); - } - - public static int Count(Func predicate) - { - return Context.Count(predicate); - } - - public static List GetList() - { - return Context.GetList(); - } - - public static List GetList(Predicate match) - { - return Context.GetList(match); - } - public static void ParseJson(Newtonsoft.Json.Linq.JArray arr) - { - ConfigTableHelper.ParseLine(arr); - } - #endregion - } -} \ No newline at end of file diff --git a/Entity/Generate/ConfigTable/Entity/RingConfig.cs b/Entity/Generate/ConfigTable/Entity/RingConfig.cs deleted file mode 100644 index cf21659..0000000 --- a/Entity/Generate/ConfigTable/Entity/RingConfig.cs +++ /dev/null @@ -1,85 +0,0 @@ -using System; -using LightProto; -using Fantasy; -using System.Linq; -using System.Reflection; -using System.Collections.Generic; -using System.Collections.Concurrent; -using Fantasy.Serialize; -using NBF.ConfigTable; - -namespace NBF -{ - [ProtoContract] - public sealed partial class RingConfig : ASerialize, IConfigTable - { - - [ProtoMember(1)] - public uint Id { get; set; } // Id - [ProtoMember(2)] - public string Model { get; set; } // 模型 - [ProtoMember(3)] - public string Icon { get; set; } // 图标 - [ProtoIgnore] - public uint Key => Id; - - #region Static - - private static ConfigContext Context => ConfigTableHelper.Table(); - - public static RingConfig Get(uint key) - { - return Context.Get(key); - } - - public static RingConfig Get(Predicate match) - { - return Context.Get(match); - } - - public static RingConfig Fist() - { - return Context.Fist(); - } - - public static RingConfig Last() - { - return Context.Last(); - } - - public static RingConfig Fist(Predicate match) - { - return Context.Fist(match); - } - - public static RingConfig Last(Predicate match) - { - return Context.Last(match); - } - - public static int Count() - { - return Context.Count(); - } - - public static int Count(Func predicate) - { - return Context.Count(predicate); - } - - public static List GetList() - { - return Context.GetList(); - } - - public static List GetList(Predicate match) - { - return Context.GetList(match); - } - public static void ParseJson(Newtonsoft.Json.Linq.JArray arr) - { - ConfigTableHelper.ParseLine(arr); - } - #endregion - } -} \ No newline at end of file diff --git a/Entity/Generate/ConfigTable/Entity/RodConfig.cs b/Entity/Generate/ConfigTable/Entity/RodConfig.cs deleted file mode 100644 index 646b639..0000000 --- a/Entity/Generate/ConfigTable/Entity/RodConfig.cs +++ /dev/null @@ -1,91 +0,0 @@ -using System; -using LightProto; -using Fantasy; -using System.Linq; -using System.Reflection; -using System.Collections.Generic; -using System.Collections.Concurrent; -using Fantasy.Serialize; -using NBF.ConfigTable; - -namespace NBF -{ - [ProtoContract] - public sealed partial class RodConfig : ASerialize, IConfigTable - { - - [ProtoMember(1)] - public uint Id { get; set; } // Id - [ProtoMember(2)] - public uint RodType { get; set; } // 鱼竿类型 - [ProtoMember(3)] - public uint Ring { get; set; } // 导线圈 - [ProtoMember(4)] - public uint Strength { get; set; } // 强度 - [ProtoMember(5)] - public uint MaxRange { get; set; } // 最大范围 - [ProtoMember(6)] - public uint ConstructionType { get; set; } // 结构类型 - [ProtoIgnore] - public uint Key => Id; - - #region Static - - private static ConfigContext Context => ConfigTableHelper.Table(); - - public static RodConfig Get(uint key) - { - return Context.Get(key); - } - - public static RodConfig Get(Predicate match) - { - return Context.Get(match); - } - - public static RodConfig Fist() - { - return Context.Fist(); - } - - public static RodConfig Last() - { - return Context.Last(); - } - - public static RodConfig Fist(Predicate match) - { - return Context.Fist(match); - } - - public static RodConfig Last(Predicate match) - { - return Context.Last(match); - } - - public static int Count() - { - return Context.Count(); - } - - public static int Count(Func predicate) - { - return Context.Count(predicate); - } - - public static List GetList() - { - return Context.GetList(); - } - - public static List GetList(Predicate match) - { - return Context.GetList(match); - } - public static void ParseJson(Newtonsoft.Json.Linq.JArray arr) - { - ConfigTableHelper.ParseLine(arr); - } - #endregion - } -} \ No newline at end of file diff --git a/Entity/Generate/ConfigTable/Entity/RodRingConfig.cs b/Entity/Generate/ConfigTable/Entity/RodRingConfig.cs deleted file mode 100644 index d1921cc..0000000 --- a/Entity/Generate/ConfigTable/Entity/RodRingConfig.cs +++ /dev/null @@ -1,85 +0,0 @@ -using System; -using LightProto; -using Fantasy; -using System.Linq; -using System.Reflection; -using System.Collections.Generic; -using System.Collections.Concurrent; -using Fantasy.Serialize; -using NBF.ConfigTable; - -namespace NBF -{ - [ProtoContract] - public sealed partial class RodRingConfig : ASerialize, IConfigTable - { - - [ProtoMember(1)] - public uint Id { get; set; } // Id - [ProtoMember(2)] - public string Model { get; set; } // 模型 - [ProtoMember(3)] - public uint Strength { get; set; } // 强度 - [ProtoIgnore] - public uint Key => Id; - - #region Static - - private static ConfigContext Context => ConfigTableHelper.Table(); - - public static RodRingConfig Get(uint key) - { - return Context.Get(key); - } - - public static RodRingConfig Get(Predicate match) - { - return Context.Get(match); - } - - public static RodRingConfig Fist() - { - return Context.Fist(); - } - - public static RodRingConfig Last() - { - return Context.Last(); - } - - public static RodRingConfig Fist(Predicate match) - { - return Context.Fist(match); - } - - public static RodRingConfig Last(Predicate match) - { - return Context.Last(match); - } - - public static int Count() - { - return Context.Count(); - } - - public static int Count(Func predicate) - { - return Context.Count(predicate); - } - - public static List GetList() - { - return Context.GetList(); - } - - public static List GetList(Predicate match) - { - return Context.GetList(match); - } - public static void ParseJson(Newtonsoft.Json.Linq.JArray arr) - { - ConfigTableHelper.ParseLine(arr); - } - #endregion - } -} \ No newline at end of file diff --git a/Entity/Generate/ConfigTable/Entity/WeightConfig.cs b/Entity/Generate/ConfigTable/Entity/WeightConfig.cs deleted file mode 100644 index 2758a31..0000000 --- a/Entity/Generate/ConfigTable/Entity/WeightConfig.cs +++ /dev/null @@ -1,89 +0,0 @@ -using System; -using LightProto; -using Fantasy; -using System.Linq; -using System.Reflection; -using System.Collections.Generic; -using System.Collections.Concurrent; -using Fantasy.Serialize; -using NBF.ConfigTable; - -namespace NBF -{ - [ProtoContract] - public sealed partial class WeightConfig : ASerialize, IConfigTable - { - - [ProtoMember(1)] - public uint Id { get; set; } // Id - [ProtoMember(2)] - public string Model { get; set; } // 模型 - [ProtoMember(3)] - public string Icon { get; set; } // 图标 - [ProtoMember(4)] - public uint Type { get; set; } // 类型 - [ProtoMember(5)] - public uint Weight { get; set; } // 重量(克) - [ProtoIgnore] - public uint Key => Id; - - #region Static - - private static ConfigContext Context => ConfigTableHelper.Table(); - - public static WeightConfig Get(uint key) - { - return Context.Get(key); - } - - public static WeightConfig Get(Predicate match) - { - return Context.Get(match); - } - - public static WeightConfig Fist() - { - return Context.Fist(); - } - - public static WeightConfig Last() - { - return Context.Last(); - } - - public static WeightConfig Fist(Predicate match) - { - return Context.Fist(match); - } - - public static WeightConfig Last(Predicate match) - { - return Context.Last(match); - } - - public static int Count() - { - return Context.Count(); - } - - public static int Count(Func predicate) - { - return Context.Count(predicate); - } - - public static List GetList() - { - return Context.GetList(); - } - - public static List GetList(Predicate match) - { - return Context.GetList(match); - } - public static void ParseJson(Newtonsoft.Json.Linq.JArray arr) - { - ConfigTableHelper.ParseLine(arr); - } - #endregion - } -} \ No newline at end of file diff --git a/Entity/Generate/ConfigTable/Feeder.cs b/Entity/Generate/ConfigTable/Feeder.cs new file mode 100644 index 0000000..aa4ac2d --- /dev/null +++ b/Entity/Generate/ConfigTable/Feeder.cs @@ -0,0 +1,64 @@ + +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +using Luban; +using Newtonsoft.Json.Linq; + + + +namespace cfg +{ + +public sealed partial class Feeder : Luban.BeanBase +{ + public Feeder(JToken _buf) + { + JObject _obj = _buf as JObject; + Id = (int)_obj.GetValue("id"); + Capacity = (int)_obj.GetValue("capacity"); + Weight = (int)_obj.GetValue("weight"); + } + + public static Feeder DeserializeFeeder(JToken _buf) + { + return new Feeder(_buf); + } + + /// + /// Id + /// + public readonly int Id; + /// + /// 能力 + /// + public readonly int Capacity; + /// + /// 重量(克) + /// + public readonly int Weight; + + + public const int __ID__ = 2100424427; + public override int GetTypeId() => __ID__; + + public void ResolveRef(Tables tables) + { + } + + public override string ToString() + { + return "{ " + + "id:" + Id + "," + + "capacity:" + Capacity + "," + + "weight:" + Weight + "," + + "}"; + } +} +} + diff --git a/Entity/Generate/ConfigTable/Fish.cs b/Entity/Generate/ConfigTable/Fish.cs new file mode 100644 index 0000000..d28a56a --- /dev/null +++ b/Entity/Generate/ConfigTable/Fish.cs @@ -0,0 +1,76 @@ + +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +using Luban; +using Newtonsoft.Json.Linq; + + + +namespace cfg +{ + +public sealed partial class Fish : Luban.BeanBase +{ + public Fish(JToken _buf) + { + JObject _obj = _buf as JObject; + Id = (int)_obj.GetValue("id"); + Name = (string)_obj.GetValue("name"); + MinWeight = (int)_obj.GetValue("min_weight"); + MaxWeight = (int)_obj.GetValue("max_weight"); + Accept = (int)_obj.GetValue("accept"); + } + + public static Fish DeserializeFish(JToken _buf) + { + return new Fish(_buf); + } + + /// + /// Id + /// + public readonly int Id; + /// + /// 鱼名字 + /// + public readonly string Name; + /// + /// 最小重量(克) + /// + public readonly int MinWeight; + /// + /// 最大重量(克) + /// + public readonly int MaxWeight; + /// + /// 接受的鱼饵配置组 + /// + public readonly int Accept; + + + public const int __ID__ = 2189944; + public override int GetTypeId() => __ID__; + + public void ResolveRef(Tables tables) + { + } + + public override string ToString() + { + return "{ " + + "id:" + Id + "," + + "name:" + Name + "," + + "minWeight:" + MinWeight + "," + + "maxWeight:" + MaxWeight + "," + + "accept:" + Accept + "," + + "}"; + } +} +} + diff --git a/Entity/Generate/ConfigTable/Goods.cs b/Entity/Generate/ConfigTable/Goods.cs new file mode 100644 index 0000000..40677d2 --- /dev/null +++ b/Entity/Generate/ConfigTable/Goods.cs @@ -0,0 +1,94 @@ + +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +using Luban; +using Newtonsoft.Json.Linq; + + + +namespace cfg +{ + +public sealed partial class Goods : Luban.BeanBase +{ + public Goods(JToken _buf) + { + JObject _obj = _buf as JObject; + Id = (int)_obj.GetValue("id"); + Group = (int)_obj.GetValue("group"); + { var __json0 = _obj.GetValue("items"); Items = new System.Collections.Generic.List((__json0 as JArray).Count); foreach(JToken __e0 in __json0) { int __v0; __v0 = (int)__e0; Items.Add(__v0); } } + Price1 = (int)_obj.GetValue("price1"); + Price2 = (int)_obj.GetValue("price2"); + { var __json0 = _obj.GetValue("label"); Label = new System.Collections.Generic.List((__json0 as JArray).Count); foreach(JToken __e0 in __json0) { int __v0; __v0 = (int)__e0; Label.Add(__v0); } } + Number = (int)_obj.GetValue("number"); + Disable = (int)_obj.GetValue("disable"); + } + + public static Goods DeserializeGoods(JToken _buf) + { + return new Goods(_buf); + } + + /// + /// Id + /// + public readonly int Id; + /// + /// 组 + /// + public readonly int Group; + /// + /// 物品 + /// + public readonly System.Collections.Generic.List Items; + /// + /// 银币价格 + /// + public readonly int Price1; + /// + /// 金币价格 + /// + public readonly int Price2; + /// + /// 标签 + /// + public readonly System.Collections.Generic.List Label; + /// + /// 可购买数量 + /// + public readonly int Number; + /// + /// 禁用状态 + /// + public readonly int Disable; + + + public const int __ID__ = 68986678; + public override int GetTypeId() => __ID__; + + public void ResolveRef(Tables tables) + { + } + + public override string ToString() + { + return "{ " + + "id:" + Id + "," + + "group:" + Group + "," + + "items:" + Luban.StringUtil.CollectionToString(Items) + "," + + "price1:" + Price1 + "," + + "price2:" + Price2 + "," + + "label:" + Luban.StringUtil.CollectionToString(Label) + "," + + "number:" + Number + "," + + "disable:" + Disable + "," + + "}"; + } +} +} + diff --git a/Entity/Generate/ConfigTable/Hook.cs b/Entity/Generate/ConfigTable/Hook.cs new file mode 100644 index 0000000..295d756 --- /dev/null +++ b/Entity/Generate/ConfigTable/Hook.cs @@ -0,0 +1,58 @@ + +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +using Luban; +using Newtonsoft.Json.Linq; + + + +namespace cfg +{ + +public sealed partial class Hook : Luban.BeanBase +{ + public Hook(JToken _buf) + { + JObject _obj = _buf as JObject; + Id = (int)_obj.GetValue("id"); + Ding = (int)_obj.GetValue("ding"); + } + + public static Hook DeserializeHook(JToken _buf) + { + return new Hook(_buf); + } + + /// + /// Id + /// + public readonly int Id; + /// + /// 长钉 + /// + public readonly int Ding; + + + public const int __ID__ = 2255171; + public override int GetTypeId() => __ID__; + + public void ResolveRef(Tables tables) + { + } + + public override string ToString() + { + return "{ " + + "id:" + Id + "," + + "ding:" + Ding + "," + + "}"; + } +} +} + diff --git a/Entity/Generate/ConfigTable/InitItemConfig.cs b/Entity/Generate/ConfigTable/InitItemConfig.cs new file mode 100644 index 0000000..0195c27 --- /dev/null +++ b/Entity/Generate/ConfigTable/InitItemConfig.cs @@ -0,0 +1,58 @@ + +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +using Luban; +using Newtonsoft.Json.Linq; + + + +namespace cfg +{ + +public sealed partial class InitItemConfig : Luban.BeanBase +{ + public InitItemConfig(JToken _buf) + { + JObject _obj = _buf as JObject; + Id = (int)_obj.GetValue("id"); + Count = (int)_obj.GetValue("count"); + } + + public static InitItemConfig DeserializeInitItemConfig(JToken _buf) + { + return new InitItemConfig(_buf); + } + + /// + /// Id + /// + public readonly int Id; + /// + /// 数量 + /// + public readonly int Count; + + + public const int __ID__ = 1451166085; + public override int GetTypeId() => __ID__; + + public void ResolveRef(Tables tables) + { + } + + public override string ToString() + { + return "{ " + + "id:" + Id + "," + + "count:" + Count + "," + + "}"; + } +} +} + diff --git a/Entity/Generate/ConfigTable/Item.cs b/Entity/Generate/ConfigTable/Item.cs new file mode 100644 index 0000000..6205232 --- /dev/null +++ b/Entity/Generate/ConfigTable/Item.cs @@ -0,0 +1,106 @@ + +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +using Luban; +using Newtonsoft.Json.Linq; + + + +namespace cfg +{ + +public sealed partial class Item : Luban.BeanBase +{ + public Item(JToken _buf) + { + JObject _obj = _buf as JObject; + Id = (int)_obj.GetValue("id"); + Type = (int)_obj.GetValue("type"); + Quality = (int)_obj.GetValue("quality"); + Brand = (int)_obj.GetValue("brand"); + Weight = (int)_obj.GetValue("weight"); + Length = (int)_obj.GetValue("length"); + Max = (int)_obj.GetValue("max"); + AutoUse = (int)_obj.GetValue("auto_use"); + { var __json0 = _obj.GetValue("result1"); Result1 = new System.Collections.Generic.List((__json0 as JArray).Count); foreach(JToken __e0 in __json0) { int __v0; __v0 = (int)__e0; Result1.Add(__v0); } } + { var __json0 = _obj.GetValue("result2"); Result2 = new System.Collections.Generic.List((__json0 as JArray).Count); foreach(JToken __e0 in __json0) { string __v0; __v0 = (string)__e0; Result2.Add(__v0); } } + } + + public static Item DeserializeItem(JToken _buf) + { + return new Item(_buf); + } + + /// + /// Id + /// + public readonly int Id; + /// + /// 子类型 + /// + public readonly int Type; + /// + /// 品质 + /// + public readonly int Quality; + /// + /// 品牌 + /// + public readonly int Brand; + /// + /// 重量(克) + /// + public readonly int Weight; + /// + /// 长度(毫米) + /// + public readonly int Length; + /// + /// 最大堆叠数量 + /// + public readonly int Max; + /// + /// 获得自动使用 + /// + public readonly int AutoUse; + /// + /// 使用参数1 + /// + public readonly System.Collections.Generic.List Result1; + /// + /// 使用参数2 + /// + public readonly System.Collections.Generic.List Result2; + + + public const int __ID__ = 2289459; + public override int GetTypeId() => __ID__; + + public void ResolveRef(Tables tables) + { + } + + public override string ToString() + { + return "{ " + + "id:" + Id + "," + + "type:" + Type + "," + + "quality:" + Quality + "," + + "brand:" + Brand + "," + + "weight:" + Weight + "," + + "length:" + Length + "," + + "max:" + Max + "," + + "autoUse:" + AutoUse + "," + + "result1:" + Luban.StringUtil.CollectionToString(Result1) + "," + + "result2:" + Luban.StringUtil.CollectionToString(Result2) + "," + + "}"; + } +} +} + diff --git a/Entity/Generate/ConfigTable/Line.cs b/Entity/Generate/ConfigTable/Line.cs new file mode 100644 index 0000000..837a232 --- /dev/null +++ b/Entity/Generate/ConfigTable/Line.cs @@ -0,0 +1,64 @@ + +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +using Luban; +using Newtonsoft.Json.Linq; + + + +namespace cfg +{ + +public sealed partial class Line : Luban.BeanBase +{ + public Line(JToken _buf) + { + JObject _obj = _buf as JObject; + Id = (int)_obj.GetValue("id"); + Strength = (int)_obj.GetValue("strength"); + Size = (int)_obj.GetValue("size"); + } + + public static Line DeserializeLine(JToken _buf) + { + return new Line(_buf); + } + + /// + /// Id + /// + public readonly int Id; + /// + /// 强度 + /// + public readonly int Strength; + /// + /// 尺寸 + /// + public readonly int Size; + + + public const int __ID__ = 2368532; + public override int GetTypeId() => __ID__; + + public void ResolveRef(Tables tables) + { + } + + public override string ToString() + { + return "{ " + + "id:" + Id + "," + + "strength:" + Strength + "," + + "size:" + Size + "," + + "}"; + } +} +} + diff --git a/Entity/Generate/ConfigTable/Lure.cs b/Entity/Generate/ConfigTable/Lure.cs new file mode 100644 index 0000000..420b1a7 --- /dev/null +++ b/Entity/Generate/ConfigTable/Lure.cs @@ -0,0 +1,70 @@ + +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +using Luban; +using Newtonsoft.Json.Linq; + + + +namespace cfg +{ + +public sealed partial class Lure : Luban.BeanBase +{ + public Lure(JToken _buf) + { + JObject _obj = _buf as JObject; + Id = (int)_obj.GetValue("id"); + { var __json0 = _obj.GetValue("hook"); Hook = new System.Collections.Generic.List((__json0 as JArray).Count); foreach(JToken __e0 in __json0) { int __v0; __v0 = (int)__e0; Hook.Add(__v0); } } + HookNum = (int)_obj.GetValue("hook_num"); + EfficacyBase = (int)_obj.GetValue("efficacy_base"); + } + + public static Lure DeserializeLure(JToken _buf) + { + return new Lure(_buf); + } + + /// + /// Id + /// + public readonly int Id; + /// + /// 鱼钩 + /// + public readonly System.Collections.Generic.List Hook; + /// + /// 装配鱼钩数量 + /// + public readonly int HookNum; + /// + /// 吸引力 + /// + public readonly int EfficacyBase; + + + public const int __ID__ = 2380188; + public override int GetTypeId() => __ID__; + + public void ResolveRef(Tables tables) + { + } + + public override string ToString() + { + return "{ " + + "id:" + Id + "," + + "hook:" + Luban.StringUtil.CollectionToString(Hook) + "," + + "hookNum:" + HookNum + "," + + "efficacyBase:" + EfficacyBase + "," + + "}"; + } +} +} + diff --git a/Entity/Generate/ConfigTable/Reel.cs b/Entity/Generate/ConfigTable/Reel.cs new file mode 100644 index 0000000..3904b52 --- /dev/null +++ b/Entity/Generate/ConfigTable/Reel.cs @@ -0,0 +1,70 @@ + +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +using Luban; +using Newtonsoft.Json.Linq; + + + +namespace cfg +{ + +public sealed partial class Reel : Luban.BeanBase +{ + public Reel(JToken _buf) + { + JObject _obj = _buf as JObject; + Id = (int)_obj.GetValue("id"); + ReelType = (int)_obj.GetValue("reel_type"); + { var __json0 = _obj.GetValue("gear_ratio"); GearRatio = new System.Collections.Generic.List((__json0 as JArray).Count); foreach(JToken __e0 in __json0) { float __v0; __v0 = (float)__e0; GearRatio.Add(__v0); } } + Strength = (int)_obj.GetValue("strength"); + } + + public static Reel DeserializeReel(JToken _buf) + { + return new Reel(_buf); + } + + /// + /// Id + /// + public readonly int Id; + /// + /// 鱼轮类型 + /// + public readonly int ReelType; + /// + /// 组件比 + /// + public readonly System.Collections.Generic.List GearRatio; + /// + /// 强度 + /// + public readonly int Strength; + + + public const int __ID__ = 2543162; + public override int GetTypeId() => __ID__; + + public void ResolveRef(Tables tables) + { + } + + public override string ToString() + { + return "{ " + + "id:" + Id + "," + + "reelType:" + ReelType + "," + + "gearRatio:" + Luban.StringUtil.CollectionToString(GearRatio) + "," + + "strength:" + Strength + "," + + "}"; + } +} +} + diff --git a/Entity/Generate/ConfigTable/Rod.cs b/Entity/Generate/ConfigTable/Rod.cs new file mode 100644 index 0000000..26c420f --- /dev/null +++ b/Entity/Generate/ConfigTable/Rod.cs @@ -0,0 +1,82 @@ + +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +using Luban; +using Newtonsoft.Json.Linq; + + + +namespace cfg +{ + +public sealed partial class Rod : Luban.BeanBase +{ + public Rod(JToken _buf) + { + JObject _obj = _buf as JObject; + Id = (int)_obj.GetValue("id"); + RodType = (int)_obj.GetValue("rod_type"); + Ring = (int)_obj.GetValue("ring"); + Strength = (int)_obj.GetValue("strength"); + MaxRange = (int)_obj.GetValue("max_range"); + ConstructionType = (int)_obj.GetValue("construction_type"); + } + + public static Rod DeserializeRod(JToken _buf) + { + return new Rod(_buf); + } + + /// + /// Id + /// + public readonly int Id; + /// + /// 鱼竿类型 + /// + public readonly int RodType; + /// + /// 导线圈 + /// + public readonly int Ring; + /// + /// 强度 + /// + public readonly int Strength; + /// + /// 最大范围 + /// + public readonly int MaxRange; + /// + /// 结构类型 + /// + public readonly int ConstructionType; + + + public const int __ID__ = 82343; + public override int GetTypeId() => __ID__; + + public void ResolveRef(Tables tables) + { + } + + public override string ToString() + { + return "{ " + + "id:" + Id + "," + + "rodType:" + RodType + "," + + "ring:" + Ring + "," + + "strength:" + Strength + "," + + "maxRange:" + MaxRange + "," + + "constructionType:" + ConstructionType + "," + + "}"; + } +} +} + diff --git a/Entity/Generate/ConfigTable/Shop.cs b/Entity/Generate/ConfigTable/Shop.cs new file mode 100644 index 0000000..307b6fe --- /dev/null +++ b/Entity/Generate/ConfigTable/Shop.cs @@ -0,0 +1,94 @@ + +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +using Luban; +using Newtonsoft.Json.Linq; + + + +namespace cfg +{ + +public sealed partial class Shop : Luban.BeanBase +{ + public Shop(JToken _buf) + { + JObject _obj = _buf as JObject; + Id = (int)_obj.GetValue("id"); + Group = (int)_obj.GetValue("group"); + { var __json0 = _obj.GetValue("items"); Items = new System.Collections.Generic.List((__json0 as JArray).Count); foreach(JToken __e0 in __json0) { int __v0; __v0 = (int)__e0; Items.Add(__v0); } } + Price1 = (int)_obj.GetValue("price1"); + Price2 = (int)_obj.GetValue("price2"); + { var __json0 = _obj.GetValue("label"); Label = new System.Collections.Generic.List((__json0 as JArray).Count); foreach(JToken __e0 in __json0) { int __v0; __v0 = (int)__e0; Label.Add(__v0); } } + Number = (int)_obj.GetValue("number"); + Disable = (int)_obj.GetValue("disable"); + } + + public static Shop DeserializeShop(JToken _buf) + { + return new Shop(_buf); + } + + /// + /// Id + /// + public readonly int Id; + /// + /// 组 + /// + public readonly int Group; + /// + /// 物品 + /// + public readonly System.Collections.Generic.List Items; + /// + /// 银币价格 + /// + public readonly int Price1; + /// + /// 金币价格 + /// + public readonly int Price2; + /// + /// 标签 + /// + public readonly System.Collections.Generic.List Label; + /// + /// 可购买数量 + /// + public readonly int Number; + /// + /// 禁用状态 + /// + public readonly int Disable; + + + public const int __ID__ = 2576150; + public override int GetTypeId() => __ID__; + + public void ResolveRef(Tables tables) + { + } + + public override string ToString() + { + return "{ " + + "id:" + Id + "," + + "group:" + Group + "," + + "items:" + Luban.StringUtil.CollectionToString(Items) + "," + + "price1:" + Price1 + "," + + "price2:" + Price2 + "," + + "label:" + Luban.StringUtil.CollectionToString(Label) + "," + + "number:" + Number + "," + + "disable:" + Disable + "," + + "}"; + } +} +} + diff --git a/Entity/Generate/ConfigTable/Tables.cs b/Entity/Generate/ConfigTable/Tables.cs new file mode 100644 index 0000000..6ab08f0 --- /dev/null +++ b/Entity/Generate/ConfigTable/Tables.cs @@ -0,0 +1,113 @@ + +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +using Newtonsoft.Json.Linq; + +namespace cfg +{ +public partial class Tables +{ + /// + /// 鱼饵 + /// + public TbBait TbBait {get; } + /// + /// 全局常量配置表 + /// + public TbBasicConfig TbBasicConfig {get; } + /// + /// 浮漂 + /// + public TbBobber TbBobber {get; } + /// + /// 菲德 + /// + public TbFeeder TbFeeder {get; } + /// + /// 鱼 + /// + public TbFish TbFish {get; } + /// + /// 商品 + /// + public TbGoods TbGoods {get; } + /// + /// 鱼钩 + /// + public TbHook TbHook {get; } + /// + /// 初始物品表 + /// + public TbInitItemConfig TbInitItemConfig {get; } + /// + /// 物品表 + /// + public TbItem TbItem {get; } + /// + /// 鱼线 + /// + public TbLine TbLine {get; } + /// + /// 路亚饵 + /// + public TbLure TbLure {get; } + /// + /// 渔轮 + /// + public TbReel TbReel {get; } + /// + /// 鱼竿 + /// + public TbRod TbRod {get; } + /// + /// 商店 + /// + public TbShop TbShop {get; } + + + public Tables(System.Func loader) + { + TbBait = new TbBait(loader("tbbait")); + TbBasicConfig = new TbBasicConfig(loader("tbbasicconfig")); + TbBobber = new TbBobber(loader("tbbobber")); + TbFeeder = new TbFeeder(loader("tbfeeder")); + TbFish = new TbFish(loader("tbfish")); + TbGoods = new TbGoods(loader("tbgoods")); + TbHook = new TbHook(loader("tbhook")); + TbInitItemConfig = new TbInitItemConfig(loader("tbinititemconfig")); + TbItem = new TbItem(loader("tbitem")); + TbLine = new TbLine(loader("tbline")); + TbLure = new TbLure(loader("tblure")); + TbReel = new TbReel(loader("tbreel")); + TbRod = new TbRod(loader("tbrod")); + TbShop = new TbShop(loader("tbshop")); + ResolveRef(); + } + + private void ResolveRef() + { + TbBait.ResolveRef(this); + TbBasicConfig.ResolveRef(this); + TbBobber.ResolveRef(this); + TbFeeder.ResolveRef(this); + TbFish.ResolveRef(this); + TbGoods.ResolveRef(this); + TbHook.ResolveRef(this); + TbInitItemConfig.ResolveRef(this); + TbItem.ResolveRef(this); + TbLine.ResolveRef(this); + TbLure.ResolveRef(this); + TbReel.ResolveRef(this); + TbRod.ResolveRef(this); + TbShop.ResolveRef(this); + } +} + +} + diff --git a/Entity/Generate/ConfigTable/TbBait.cs b/Entity/Generate/ConfigTable/TbBait.cs new file mode 100644 index 0000000..08c2af4 --- /dev/null +++ b/Entity/Generate/ConfigTable/TbBait.cs @@ -0,0 +1,58 @@ + +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +using Newtonsoft.Json.Linq; +using Luban; + + + +namespace cfg +{ + +/// +/// 鱼饵 +/// +public partial class TbBait +{ + private readonly System.Collections.Generic.Dictionary _dataMap; + private readonly System.Collections.Generic.List _dataList; + + public TbBait(JArray _buf) + { + _dataMap = new System.Collections.Generic.Dictionary(_buf.Count); + _dataList = new System.Collections.Generic.List(_buf.Count); + + foreach(JObject _ele in _buf) + { + Bait _v; + _v = global::cfg.Bait.DeserializeBait(_ele); + _dataList.Add(_v); + _dataMap.Add(_v.Id, _v); + } + } + + + public System.Collections.Generic.Dictionary DataMap => _dataMap; + public System.Collections.Generic.List DataList => _dataList; + + public Bait GetOrDefault(int key) => _dataMap.TryGetValue(key, out var v) ? v : default; + public Bait Get(int key) => _dataMap[key]; + public Bait this[int key] => _dataMap[key]; + + public void ResolveRef(Tables tables) + { + foreach(var _v in _dataList) + { + _v.ResolveRef(tables); + } + } + +} +} + diff --git a/Entity/Generate/ConfigTable/TbBasicConfig.cs b/Entity/Generate/ConfigTable/TbBasicConfig.cs new file mode 100644 index 0000000..72e4a2c --- /dev/null +++ b/Entity/Generate/ConfigTable/TbBasicConfig.cs @@ -0,0 +1,58 @@ + +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +using Newtonsoft.Json.Linq; +using Luban; + + + +namespace cfg +{ + +/// +/// 全局常量配置表 +/// +public partial class TbBasicConfig +{ + private readonly System.Collections.Generic.Dictionary _dataMap; + private readonly System.Collections.Generic.List _dataList; + + public TbBasicConfig(JArray _buf) + { + _dataMap = new System.Collections.Generic.Dictionary(_buf.Count); + _dataList = new System.Collections.Generic.List(_buf.Count); + + foreach(JObject _ele in _buf) + { + BasicConfig _v; + _v = global::cfg.BasicConfig.DeserializeBasicConfig(_ele); + _dataList.Add(_v); + _dataMap.Add(_v.X1, _v); + } + } + + + public System.Collections.Generic.Dictionary DataMap => _dataMap; + public System.Collections.Generic.List DataList => _dataList; + + public BasicConfig GetOrDefault(int key) => _dataMap.TryGetValue(key, out var v) ? v : default; + public BasicConfig Get(int key) => _dataMap[key]; + public BasicConfig this[int key] => _dataMap[key]; + + public void ResolveRef(Tables tables) + { + foreach(var _v in _dataList) + { + _v.ResolveRef(tables); + } + } + +} +} + diff --git a/Entity/Generate/ConfigTable/TbBobber.cs b/Entity/Generate/ConfigTable/TbBobber.cs new file mode 100644 index 0000000..ecb6a4d --- /dev/null +++ b/Entity/Generate/ConfigTable/TbBobber.cs @@ -0,0 +1,58 @@ + +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +using Newtonsoft.Json.Linq; +using Luban; + + + +namespace cfg +{ + +/// +/// 浮漂 +/// +public partial class TbBobber +{ + private readonly System.Collections.Generic.Dictionary _dataMap; + private readonly System.Collections.Generic.List _dataList; + + public TbBobber(JArray _buf) + { + _dataMap = new System.Collections.Generic.Dictionary(_buf.Count); + _dataList = new System.Collections.Generic.List(_buf.Count); + + foreach(JObject _ele in _buf) + { + Bobber _v; + _v = global::cfg.Bobber.DeserializeBobber(_ele); + _dataList.Add(_v); + _dataMap.Add(_v.Id, _v); + } + } + + + public System.Collections.Generic.Dictionary DataMap => _dataMap; + public System.Collections.Generic.List DataList => _dataList; + + public Bobber GetOrDefault(int key) => _dataMap.TryGetValue(key, out var v) ? v : default; + public Bobber Get(int key) => _dataMap[key]; + public Bobber this[int key] => _dataMap[key]; + + public void ResolveRef(Tables tables) + { + foreach(var _v in _dataList) + { + _v.ResolveRef(tables); + } + } + +} +} + diff --git a/Entity/Generate/ConfigTable/TbFeeder.cs b/Entity/Generate/ConfigTable/TbFeeder.cs new file mode 100644 index 0000000..46c0728 --- /dev/null +++ b/Entity/Generate/ConfigTable/TbFeeder.cs @@ -0,0 +1,58 @@ + +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +using Newtonsoft.Json.Linq; +using Luban; + + + +namespace cfg +{ + +/// +/// 菲德 +/// +public partial class TbFeeder +{ + private readonly System.Collections.Generic.Dictionary _dataMap; + private readonly System.Collections.Generic.List _dataList; + + public TbFeeder(JArray _buf) + { + _dataMap = new System.Collections.Generic.Dictionary(_buf.Count); + _dataList = new System.Collections.Generic.List(_buf.Count); + + foreach(JObject _ele in _buf) + { + Feeder _v; + _v = global::cfg.Feeder.DeserializeFeeder(_ele); + _dataList.Add(_v); + _dataMap.Add(_v.Id, _v); + } + } + + + public System.Collections.Generic.Dictionary DataMap => _dataMap; + public System.Collections.Generic.List DataList => _dataList; + + public Feeder GetOrDefault(int key) => _dataMap.TryGetValue(key, out var v) ? v : default; + public Feeder Get(int key) => _dataMap[key]; + public Feeder this[int key] => _dataMap[key]; + + public void ResolveRef(Tables tables) + { + foreach(var _v in _dataList) + { + _v.ResolveRef(tables); + } + } + +} +} + diff --git a/Entity/Generate/ConfigTable/TbFish.cs b/Entity/Generate/ConfigTable/TbFish.cs new file mode 100644 index 0000000..d6c4c06 --- /dev/null +++ b/Entity/Generate/ConfigTable/TbFish.cs @@ -0,0 +1,58 @@ + +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +using Newtonsoft.Json.Linq; +using Luban; + + + +namespace cfg +{ + +/// +/// 鱼 +/// +public partial class TbFish +{ + private readonly System.Collections.Generic.Dictionary _dataMap; + private readonly System.Collections.Generic.List _dataList; + + public TbFish(JArray _buf) + { + _dataMap = new System.Collections.Generic.Dictionary(_buf.Count); + _dataList = new System.Collections.Generic.List(_buf.Count); + + foreach(JObject _ele in _buf) + { + Fish _v; + _v = global::cfg.Fish.DeserializeFish(_ele); + _dataList.Add(_v); + _dataMap.Add(_v.Id, _v); + } + } + + + public System.Collections.Generic.Dictionary DataMap => _dataMap; + public System.Collections.Generic.List DataList => _dataList; + + public Fish GetOrDefault(int key) => _dataMap.TryGetValue(key, out var v) ? v : default; + public Fish Get(int key) => _dataMap[key]; + public Fish this[int key] => _dataMap[key]; + + public void ResolveRef(Tables tables) + { + foreach(var _v in _dataList) + { + _v.ResolveRef(tables); + } + } + +} +} + diff --git a/Entity/Generate/ConfigTable/TbGoods.cs b/Entity/Generate/ConfigTable/TbGoods.cs new file mode 100644 index 0000000..abadea5 --- /dev/null +++ b/Entity/Generate/ConfigTable/TbGoods.cs @@ -0,0 +1,58 @@ + +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +using Newtonsoft.Json.Linq; +using Luban; + + + +namespace cfg +{ + +/// +/// 商品 +/// +public partial class TbGoods +{ + private readonly System.Collections.Generic.Dictionary _dataMap; + private readonly System.Collections.Generic.List _dataList; + + public TbGoods(JArray _buf) + { + _dataMap = new System.Collections.Generic.Dictionary(_buf.Count); + _dataList = new System.Collections.Generic.List(_buf.Count); + + foreach(JObject _ele in _buf) + { + Goods _v; + _v = global::cfg.Goods.DeserializeGoods(_ele); + _dataList.Add(_v); + _dataMap.Add(_v.Id, _v); + } + } + + + public System.Collections.Generic.Dictionary DataMap => _dataMap; + public System.Collections.Generic.List DataList => _dataList; + + public Goods GetOrDefault(int key) => _dataMap.TryGetValue(key, out var v) ? v : default; + public Goods Get(int key) => _dataMap[key]; + public Goods this[int key] => _dataMap[key]; + + public void ResolveRef(Tables tables) + { + foreach(var _v in _dataList) + { + _v.ResolveRef(tables); + } + } + +} +} + diff --git a/Entity/Generate/ConfigTable/TbHook.cs b/Entity/Generate/ConfigTable/TbHook.cs new file mode 100644 index 0000000..ddda0d1 --- /dev/null +++ b/Entity/Generate/ConfigTable/TbHook.cs @@ -0,0 +1,58 @@ + +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +using Newtonsoft.Json.Linq; +using Luban; + + + +namespace cfg +{ + +/// +/// 鱼钩 +/// +public partial class TbHook +{ + private readonly System.Collections.Generic.Dictionary _dataMap; + private readonly System.Collections.Generic.List _dataList; + + public TbHook(JArray _buf) + { + _dataMap = new System.Collections.Generic.Dictionary(_buf.Count); + _dataList = new System.Collections.Generic.List(_buf.Count); + + foreach(JObject _ele in _buf) + { + Hook _v; + _v = global::cfg.Hook.DeserializeHook(_ele); + _dataList.Add(_v); + _dataMap.Add(_v.Id, _v); + } + } + + + public System.Collections.Generic.Dictionary DataMap => _dataMap; + public System.Collections.Generic.List DataList => _dataList; + + public Hook GetOrDefault(int key) => _dataMap.TryGetValue(key, out var v) ? v : default; + public Hook Get(int key) => _dataMap[key]; + public Hook this[int key] => _dataMap[key]; + + public void ResolveRef(Tables tables) + { + foreach(var _v in _dataList) + { + _v.ResolveRef(tables); + } + } + +} +} + diff --git a/Entity/Generate/ConfigTable/TbInitItemConfig.cs b/Entity/Generate/ConfigTable/TbInitItemConfig.cs new file mode 100644 index 0000000..2892966 --- /dev/null +++ b/Entity/Generate/ConfigTable/TbInitItemConfig.cs @@ -0,0 +1,58 @@ + +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +using Newtonsoft.Json.Linq; +using Luban; + + + +namespace cfg +{ + +/// +/// 初始物品表 +/// +public partial class TbInitItemConfig +{ + private readonly System.Collections.Generic.Dictionary _dataMap; + private readonly System.Collections.Generic.List _dataList; + + public TbInitItemConfig(JArray _buf) + { + _dataMap = new System.Collections.Generic.Dictionary(_buf.Count); + _dataList = new System.Collections.Generic.List(_buf.Count); + + foreach(JObject _ele in _buf) + { + InitItemConfig _v; + _v = global::cfg.InitItemConfig.DeserializeInitItemConfig(_ele); + _dataList.Add(_v); + _dataMap.Add(_v.Id, _v); + } + } + + + public System.Collections.Generic.Dictionary DataMap => _dataMap; + public System.Collections.Generic.List DataList => _dataList; + + public InitItemConfig GetOrDefault(int key) => _dataMap.TryGetValue(key, out var v) ? v : default; + public InitItemConfig Get(int key) => _dataMap[key]; + public InitItemConfig this[int key] => _dataMap[key]; + + public void ResolveRef(Tables tables) + { + foreach(var _v in _dataList) + { + _v.ResolveRef(tables); + } + } + +} +} + diff --git a/Entity/Generate/ConfigTable/TbItem.cs b/Entity/Generate/ConfigTable/TbItem.cs new file mode 100644 index 0000000..3372249 --- /dev/null +++ b/Entity/Generate/ConfigTable/TbItem.cs @@ -0,0 +1,58 @@ + +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +using Newtonsoft.Json.Linq; +using Luban; + + + +namespace cfg +{ + +/// +/// 物品表 +/// +public partial class TbItem +{ + private readonly System.Collections.Generic.Dictionary _dataMap; + private readonly System.Collections.Generic.List _dataList; + + public TbItem(JArray _buf) + { + _dataMap = new System.Collections.Generic.Dictionary(_buf.Count); + _dataList = new System.Collections.Generic.List(_buf.Count); + + foreach(JObject _ele in _buf) + { + Item _v; + _v = global::cfg.Item.DeserializeItem(_ele); + _dataList.Add(_v); + _dataMap.Add(_v.Id, _v); + } + } + + + public System.Collections.Generic.Dictionary DataMap => _dataMap; + public System.Collections.Generic.List DataList => _dataList; + + public Item GetOrDefault(int key) => _dataMap.TryGetValue(key, out var v) ? v : default; + public Item Get(int key) => _dataMap[key]; + public Item this[int key] => _dataMap[key]; + + public void ResolveRef(Tables tables) + { + foreach(var _v in _dataList) + { + _v.ResolveRef(tables); + } + } + +} +} + diff --git a/Entity/Generate/ConfigTable/TbLine.cs b/Entity/Generate/ConfigTable/TbLine.cs new file mode 100644 index 0000000..2b460ce --- /dev/null +++ b/Entity/Generate/ConfigTable/TbLine.cs @@ -0,0 +1,58 @@ + +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +using Newtonsoft.Json.Linq; +using Luban; + + + +namespace cfg +{ + +/// +/// 鱼线 +/// +public partial class TbLine +{ + private readonly System.Collections.Generic.Dictionary _dataMap; + private readonly System.Collections.Generic.List _dataList; + + public TbLine(JArray _buf) + { + _dataMap = new System.Collections.Generic.Dictionary(_buf.Count); + _dataList = new System.Collections.Generic.List(_buf.Count); + + foreach(JObject _ele in _buf) + { + Line _v; + _v = global::cfg.Line.DeserializeLine(_ele); + _dataList.Add(_v); + _dataMap.Add(_v.Id, _v); + } + } + + + public System.Collections.Generic.Dictionary DataMap => _dataMap; + public System.Collections.Generic.List DataList => _dataList; + + public Line GetOrDefault(int key) => _dataMap.TryGetValue(key, out var v) ? v : default; + public Line Get(int key) => _dataMap[key]; + public Line this[int key] => _dataMap[key]; + + public void ResolveRef(Tables tables) + { + foreach(var _v in _dataList) + { + _v.ResolveRef(tables); + } + } + +} +} + diff --git a/Entity/Generate/ConfigTable/TbLure.cs b/Entity/Generate/ConfigTable/TbLure.cs new file mode 100644 index 0000000..ba48100 --- /dev/null +++ b/Entity/Generate/ConfigTable/TbLure.cs @@ -0,0 +1,58 @@ + +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +using Newtonsoft.Json.Linq; +using Luban; + + + +namespace cfg +{ + +/// +/// 路亚饵 +/// +public partial class TbLure +{ + private readonly System.Collections.Generic.Dictionary _dataMap; + private readonly System.Collections.Generic.List _dataList; + + public TbLure(JArray _buf) + { + _dataMap = new System.Collections.Generic.Dictionary(_buf.Count); + _dataList = new System.Collections.Generic.List(_buf.Count); + + foreach(JObject _ele in _buf) + { + Lure _v; + _v = global::cfg.Lure.DeserializeLure(_ele); + _dataList.Add(_v); + _dataMap.Add(_v.Id, _v); + } + } + + + public System.Collections.Generic.Dictionary DataMap => _dataMap; + public System.Collections.Generic.List DataList => _dataList; + + public Lure GetOrDefault(int key) => _dataMap.TryGetValue(key, out var v) ? v : default; + public Lure Get(int key) => _dataMap[key]; + public Lure this[int key] => _dataMap[key]; + + public void ResolveRef(Tables tables) + { + foreach(var _v in _dataList) + { + _v.ResolveRef(tables); + } + } + +} +} + diff --git a/Entity/Generate/ConfigTable/TbReel.cs b/Entity/Generate/ConfigTable/TbReel.cs new file mode 100644 index 0000000..f45ee43 --- /dev/null +++ b/Entity/Generate/ConfigTable/TbReel.cs @@ -0,0 +1,58 @@ + +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +using Newtonsoft.Json.Linq; +using Luban; + + + +namespace cfg +{ + +/// +/// 渔轮 +/// +public partial class TbReel +{ + private readonly System.Collections.Generic.Dictionary _dataMap; + private readonly System.Collections.Generic.List _dataList; + + public TbReel(JArray _buf) + { + _dataMap = new System.Collections.Generic.Dictionary(_buf.Count); + _dataList = new System.Collections.Generic.List(_buf.Count); + + foreach(JObject _ele in _buf) + { + Reel _v; + _v = global::cfg.Reel.DeserializeReel(_ele); + _dataList.Add(_v); + _dataMap.Add(_v.Id, _v); + } + } + + + public System.Collections.Generic.Dictionary DataMap => _dataMap; + public System.Collections.Generic.List DataList => _dataList; + + public Reel GetOrDefault(int key) => _dataMap.TryGetValue(key, out var v) ? v : default; + public Reel Get(int key) => _dataMap[key]; + public Reel this[int key] => _dataMap[key]; + + public void ResolveRef(Tables tables) + { + foreach(var _v in _dataList) + { + _v.ResolveRef(tables); + } + } + +} +} + diff --git a/Entity/Generate/ConfigTable/TbRod.cs b/Entity/Generate/ConfigTable/TbRod.cs new file mode 100644 index 0000000..cb8e795 --- /dev/null +++ b/Entity/Generate/ConfigTable/TbRod.cs @@ -0,0 +1,58 @@ + +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +using Newtonsoft.Json.Linq; +using Luban; + + + +namespace cfg +{ + +/// +/// 鱼竿 +/// +public partial class TbRod +{ + private readonly System.Collections.Generic.Dictionary _dataMap; + private readonly System.Collections.Generic.List _dataList; + + public TbRod(JArray _buf) + { + _dataMap = new System.Collections.Generic.Dictionary(_buf.Count); + _dataList = new System.Collections.Generic.List(_buf.Count); + + foreach(JObject _ele in _buf) + { + Rod _v; + _v = global::cfg.Rod.DeserializeRod(_ele); + _dataList.Add(_v); + _dataMap.Add(_v.Id, _v); + } + } + + + public System.Collections.Generic.Dictionary DataMap => _dataMap; + public System.Collections.Generic.List DataList => _dataList; + + public Rod GetOrDefault(int key) => _dataMap.TryGetValue(key, out var v) ? v : default; + public Rod Get(int key) => _dataMap[key]; + public Rod this[int key] => _dataMap[key]; + + public void ResolveRef(Tables tables) + { + foreach(var _v in _dataList) + { + _v.ResolveRef(tables); + } + } + +} +} + diff --git a/Entity/Generate/ConfigTable/TbShop.cs b/Entity/Generate/ConfigTable/TbShop.cs new file mode 100644 index 0000000..a2388aa --- /dev/null +++ b/Entity/Generate/ConfigTable/TbShop.cs @@ -0,0 +1,58 @@ + +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +using Newtonsoft.Json.Linq; +using Luban; + + + +namespace cfg +{ + +/// +/// 商店 +/// +public partial class TbShop +{ + private readonly System.Collections.Generic.Dictionary _dataMap; + private readonly System.Collections.Generic.List _dataList; + + public TbShop(JArray _buf) + { + _dataMap = new System.Collections.Generic.Dictionary(_buf.Count); + _dataList = new System.Collections.Generic.List(_buf.Count); + + foreach(JObject _ele in _buf) + { + Shop _v; + _v = global::cfg.Shop.DeserializeShop(_ele); + _dataList.Add(_v); + _dataMap.Add(_v.Id, _v); + } + } + + + public System.Collections.Generic.Dictionary DataMap => _dataMap; + public System.Collections.Generic.List DataList => _dataList; + + public Shop GetOrDefault(int key) => _dataMap.TryGetValue(key, out var v) ? v : default; + public Shop Get(int key) => _dataMap[key]; + public Shop this[int key] => _dataMap[key]; + + public void ResolveRef(Tables tables) + { + foreach(var _v in _dataList) + { + _v.ResolveRef(tables); + } + } + +} +} + diff --git a/Entity/Generate/ConfigTable/vector2.cs b/Entity/Generate/ConfigTable/vector2.cs new file mode 100644 index 0000000..13dd65f --- /dev/null +++ b/Entity/Generate/ConfigTable/vector2.cs @@ -0,0 +1,50 @@ + +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +using Luban; +using Newtonsoft.Json.Linq; + + + +namespace cfg +{ + +public partial struct vector2 +{ + public vector2(JToken _buf) + { + JObject _obj = _buf as JObject; + X = (float)_obj.GetValue("x"); + Y = (float)_obj.GetValue("y"); + } + + public static vector2 Deserializevector2(JToken _buf) + { + return new vector2(_buf); + } + + public readonly float X; + public readonly float Y; + + + + public void ResolveRef(Tables tables) + { + } + + public override string ToString() + { + return "{ " + + "x:" + X + "," + + "y:" + Y + "," + + "}"; + } +} +} + diff --git a/Entity/Generate/ConfigTable/vector3.cs b/Entity/Generate/ConfigTable/vector3.cs new file mode 100644 index 0000000..23bd77d --- /dev/null +++ b/Entity/Generate/ConfigTable/vector3.cs @@ -0,0 +1,53 @@ + +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +using Luban; +using Newtonsoft.Json.Linq; + + + +namespace cfg +{ + +public partial struct vector3 +{ + public vector3(JToken _buf) + { + JObject _obj = _buf as JObject; + X = (float)_obj.GetValue("x"); + Y = (float)_obj.GetValue("y"); + Z = (float)_obj.GetValue("z"); + } + + public static vector3 Deserializevector3(JToken _buf) + { + return new vector3(_buf); + } + + public readonly float X; + public readonly float Y; + public readonly float Z; + + + + public void ResolveRef(Tables tables) + { + } + + public override string ToString() + { + return "{ " + + "x:" + X + "," + + "y:" + Y + "," + + "z:" + Z + "," + + "}"; + } +} +} + diff --git a/Entity/Generate/ConfigTable/vector4.cs b/Entity/Generate/ConfigTable/vector4.cs new file mode 100644 index 0000000..1eb6b6f --- /dev/null +++ b/Entity/Generate/ConfigTable/vector4.cs @@ -0,0 +1,56 @@ + +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +using Luban; +using Newtonsoft.Json.Linq; + + + +namespace cfg +{ + +public partial struct vector4 +{ + public vector4(JToken _buf) + { + JObject _obj = _buf as JObject; + X = (float)_obj.GetValue("x"); + Y = (float)_obj.GetValue("y"); + Z = (float)_obj.GetValue("z"); + W = (float)_obj.GetValue("w"); + } + + public static vector4 Deserializevector4(JToken _buf) + { + return new vector4(_buf); + } + + public readonly float X; + public readonly float Y; + public readonly float Z; + public readonly float W; + + + + public void ResolveRef(Tables tables) + { + } + + public override string ToString() + { + return "{ " + + "x:" + X + "," + + "y:" + Y + "," + + "z:" + Z + "," + + "w:" + W + "," + + "}"; + } +} +} + diff --git a/Entity/Generate/NetworkProtocol/InnerMessage.cs b/Entity/Generate/NetworkProtocol/InnerMessage.cs index 8ce56b8..6b7cf84 100644 --- a/Entity/Generate/NetworkProtocol/InnerMessage.cs +++ b/Entity/Generate/NetworkProtocol/InnerMessage.cs @@ -589,4 +589,93 @@ namespace Fantasy [ProtoMember(1)] public uint ErrorCode { get; set; } } + /// + /// Chat通知Gate发送一个全服广播的聊天信息 + /// +////////// ******** 聊天 *******///////////// + [Serializable] + [ProtoContract] + public partial class Chat2G_ChatMessage : AMessage, IAddressMessage + { + public static Chat2G_ChatMessage Create(bool autoReturn = true) + { + var chat2G_ChatMessage = MessageObjectPool.Rent(); + chat2G_ChatMessage.AutoReturn = autoReturn; + + if (!autoReturn) + { + chat2G_ChatMessage.SetIsPool(false); + } + + return chat2G_ChatMessage; + } + + public void Return() + { + if (!AutoReturn) + { + SetIsPool(true); + AutoReturn = true; + } + else if (!IsPool()) + { + return; + } + Dispose(); + } + + public void Dispose() + { + if (!IsPool()) return; + ChatInfoTree = default; + MessageObjectPool.Return(this); + } + public uint OpCode() { return InnerOpcode.Chat2G_ChatMessage; } + [ProtoMember(1)] + public ChatInfoTree ChatInfoTree { get; set; } + } + /// + /// 其他服务器发送聊天消息到Chat + /// + [Serializable] + [ProtoContract] + public partial class Other2Chat_ChatMessage : AMessage, IAddressMessage + { + public static Other2Chat_ChatMessage Create(bool autoReturn = true) + { + var other2Chat_ChatMessage = MessageObjectPool.Rent(); + other2Chat_ChatMessage.AutoReturn = autoReturn; + + if (!autoReturn) + { + other2Chat_ChatMessage.SetIsPool(false); + } + + return other2Chat_ChatMessage; + } + + public void Return() + { + if (!AutoReturn) + { + SetIsPool(true); + AutoReturn = true; + } + else if (!IsPool()) + { + return; + } + Dispose(); + } + + public void Dispose() + { + if (!IsPool()) return; + ChatInfoTree = default; + MessageObjectPool.Return(this); + } + public uint OpCode() { return InnerOpcode.Other2Chat_ChatMessage; } + [ProtoMember(1)] + public ChatInfoTree ChatInfoTree { get; set; } + } } \ No newline at end of file diff --git a/Entity/Generate/NetworkProtocol/InnerOpcode.cs b/Entity/Generate/NetworkProtocol/InnerOpcode.cs index 18bc561..b4ecf8f 100644 --- a/Entity/Generate/NetworkProtocol/InnerOpcode.cs +++ b/Entity/Generate/NetworkProtocol/InnerOpcode.cs @@ -18,5 +18,7 @@ namespace Fantasy public const uint Map2G_EnterMapResponse = 1207969556; public const uint G2Map_ExitRoomRequest = 1073751829; public const uint Map2G_ExiRoomResponse = 1207969557; + public const uint Chat2G_ChatMessage = 939534099; + public const uint Other2Chat_ChatMessage = 939534100; } } \ No newline at end of file diff --git a/Entity/Generate/NetworkProtocol/OuterMessage.cs b/Entity/Generate/NetworkProtocol/OuterMessage.cs index a42e338..b99cea1 100644 --- a/Entity/Generate/NetworkProtocol/OuterMessage.cs +++ b/Entity/Generate/NetworkProtocol/OuterMessage.cs @@ -2839,7 +2839,398 @@ namespace Fantasy [ProtoMember(2)] public long MailId { get; set; } } + /// + /// 发送一个聊天消息给Chat服务器,中间是经过Gate中转的 + /// ////////// ******** 频道聊天 *******///////////// + [Serializable] + [ProtoContract] + public partial class C2Chat_SendMessageRequest : AMessage, ICustomRouteRequest + { + public static C2Chat_SendMessageRequest Create(bool autoReturn = true) + { + var c2Chat_SendMessageRequest = MessageObjectPool.Rent(); + c2Chat_SendMessageRequest.AutoReturn = autoReturn; + + if (!autoReturn) + { + c2Chat_SendMessageRequest.SetIsPool(false); + } + + return c2Chat_SendMessageRequest; + } + + public void Return() + { + if (!AutoReturn) + { + SetIsPool(true); + AutoReturn = true; + } + else if (!IsPool()) + { + return; + } + Dispose(); + } + + public void Dispose() + { + if (!IsPool()) return; + if (ChatInfoTree != null) + { + ChatInfoTree.Dispose(); + ChatInfoTree = null; + } + MessageObjectPool.Return(this); + } + public uint OpCode() { return OuterOpcode.C2Chat_SendMessageRequest; } + [ProtoIgnore] + public Chat2C_SendMessageResponse ResponseType { get; set; } + [ProtoIgnore] + public int RouteType => Fantasy.RouteType.SocialRoute; + [ProtoMember(1)] + public ChatInfoTree ChatInfoTree { get; set; } + } + [Serializable] + [ProtoContract] + public partial class Chat2C_SendMessageResponse : AMessage, ICustomRouteResponse + { + public static Chat2C_SendMessageResponse Create(bool autoReturn = true) + { + var chat2C_SendMessageResponse = MessageObjectPool.Rent(); + chat2C_SendMessageResponse.AutoReturn = autoReturn; + + if (!autoReturn) + { + chat2C_SendMessageResponse.SetIsPool(false); + } + + return chat2C_SendMessageResponse; + } + + public void Return() + { + if (!AutoReturn) + { + SetIsPool(true); + AutoReturn = true; + } + else if (!IsPool()) + { + return; + } + Dispose(); + } + + public void Dispose() + { + if (!IsPool()) return; + ErrorCode = 0; + MessageObjectPool.Return(this); + } + public uint OpCode() { return OuterOpcode.Chat2C_SendMessageResponse; } + [ProtoMember(1)] + public uint ErrorCode { get; set; } + } + [Serializable] + [ProtoContract] + public partial class Chat2C_Message : AMessage, ICustomRouteMessage + { + public static Chat2C_Message Create(bool autoReturn = true) + { + var chat2C_Message = MessageObjectPool.Rent(); + chat2C_Message.AutoReturn = autoReturn; + + if (!autoReturn) + { + chat2C_Message.SetIsPool(false); + } + + return chat2C_Message; + } + + public void Return() + { + if (!AutoReturn) + { + SetIsPool(true); + AutoReturn = true; + } + else if (!IsPool()) + { + return; + } + Dispose(); + } + + public void Dispose() + { + if (!IsPool()) return; + if (ChatInfoTree != null) + { + ChatInfoTree.Dispose(); + ChatInfoTree = null; + } + MessageObjectPool.Return(this); + } + public uint OpCode() { return OuterOpcode.Chat2C_Message; } + [ProtoIgnore] + public int RouteType => Fantasy.RouteType.SocialRoute; + [ProtoMember(1)] + public ChatInfoTree ChatInfoTree { get; set; } + } + /// + /// 聊天消息树 + /// + [Serializable] + [ProtoContract] + public partial class ChatInfoTree : AMessage, IDisposable + { + public static ChatInfoTree Create(bool autoReturn = true) + { + var chatInfoTree = MessageObjectPool.Rent(); + chatInfoTree.AutoReturn = autoReturn; + + if (!autoReturn) + { + chatInfoTree.SetIsPool(false); + } + + return chatInfoTree; + } + + public void Return() + { + if (!AutoReturn) + { + SetIsPool(true); + AutoReturn = true; + } + else if (!IsPool()) + { + return; + } + Dispose(); + } + + public void Dispose() + { + if (!IsPool()) return; + ChatChannelType = default; + ChatChannelId = default; + UnitId = default; + UserName = default; + Target.Clear(); + Node.Clear(); + MessageObjectPool.Return(this); + } + [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 Target { get; set; } = new List(); + [ProtoMember(6)] + public List Node { get; set; } = new List(); + } + /// + /// 聊天信息节点 + /// + [Serializable] + [ProtoContract] + public partial class ChatInfoNode : AMessage, IDisposable + { + public static ChatInfoNode Create(bool autoReturn = true) + { + var chatInfoNode = MessageObjectPool.Rent(); + chatInfoNode.AutoReturn = autoReturn; + + if (!autoReturn) + { + chatInfoNode.SetIsPool(false); + } + + return chatInfoNode; + } + + public void Return() + { + if (!AutoReturn) + { + SetIsPool(true); + AutoReturn = true; + } + else if (!IsPool()) + { + return; + } + Dispose(); + } + + public void Dispose() + { + if (!IsPool()) return; + ChatNodeType = default; + ChatNodeEvent = default; + Content = default; + Color = default; + Data = null; + MessageObjectPool.Return(this); + } + [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; } + } + /// + /// 聊天位置信息节点 + /// + [Serializable] + [ProtoContract] + public partial class ChatPositionNode : AMessage, IDisposable + { + public static ChatPositionNode Create(bool autoReturn = true) + { + var chatPositionNode = MessageObjectPool.Rent(); + chatPositionNode.AutoReturn = autoReturn; + + if (!autoReturn) + { + chatPositionNode.SetIsPool(false); + } + + return chatPositionNode; + } + + public void Return() + { + if (!AutoReturn) + { + SetIsPool(true); + AutoReturn = true; + } + else if (!IsPool()) + { + return; + } + Dispose(); + } + + public void Dispose() + { + if (!IsPool()) return; + MapName = default; + PosX = default; + PosY = default; + PosZ = default; + MessageObjectPool.Return(this); + } + [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; } + } + /// + /// 聊天位置信息节点 + /// + [Serializable] + [ProtoContract] + public partial class ChatOpenUINode : AMessage, IDisposable + { + public static ChatOpenUINode Create(bool autoReturn = true) + { + var chatOpenUINode = MessageObjectPool.Rent(); + chatOpenUINode.AutoReturn = autoReturn; + + if (!autoReturn) + { + chatOpenUINode.SetIsPool(false); + } + + return chatOpenUINode; + } + + public void Return() + { + if (!AutoReturn) + { + SetIsPool(true); + AutoReturn = true; + } + else if (!IsPool()) + { + return; + } + Dispose(); + } + + public void Dispose() + { + if (!IsPool()) return; + UIName = default; + MessageObjectPool.Return(this); + } + [ProtoMember(1)] + public string UIName { get; set; } + } + /// + /// 聊天连接信息节点 + /// + [Serializable] + [ProtoContract] + public partial class ChatLinkNode : AMessage, IDisposable + { + public static ChatLinkNode Create(bool autoReturn = true) + { + var chatLinkNode = MessageObjectPool.Rent(); + chatLinkNode.AutoReturn = autoReturn; + + if (!autoReturn) + { + chatLinkNode.SetIsPool(false); + } + + return chatLinkNode; + } + + public void Return() + { + if (!AutoReturn) + { + SetIsPool(true); + AutoReturn = true; + } + else if (!IsPool()) + { + return; + } + Dispose(); + } + + public void Dispose() + { + if (!IsPool()) return; + Link = default; + MessageObjectPool.Return(this); + } + [ProtoMember(1)] + public string Link { get; set; } + } [Serializable] [ProtoContract] public partial class ChatUserInfo : AMessage, IDisposable @@ -4581,7 +4972,7 @@ namespace Fantasy MessageObjectPool.Return(this); } [ProtoMember(1)] - public uint ConfigId { get; set; } + public int ConfigId { get; set; } [ProtoMember(2)] public long Id { get; set; } [ProtoMember(3)] @@ -4631,18 +5022,18 @@ namespace Fantasy { if (!IsPool()) return; ConfigId = default; - Price = default; - Currency = default; + Price1 = default; + Price2 = default; Sort = default; Tag = default; MessageObjectPool.Return(this); } [ProtoMember(1)] - public uint ConfigId { get; set; } + public int ConfigId { get; set; } [ProtoMember(2)] - public uint Price { get; set; } + public uint Price1 { get; set; } [ProtoMember(3)] - public uint Currency { get; set; } + public uint Price2 { get; set; } [ProtoMember(4)] public uint Sort { get; set; } [ProtoMember(5)] @@ -4693,7 +5084,7 @@ namespace Fantasy MessageObjectPool.Return(this); } [ProtoMember(1)] - public uint ConfigId { get; set; } + public int ConfigId { get; set; } [ProtoMember(2)] public long Id { get; set; } [ProtoMember(3)] @@ -4795,7 +5186,7 @@ namespace Fantasy MessageObjectPool.Return(this); } [ProtoMember(1)] - public uint ConfigId { get; set; } + public int ConfigId { get; set; } [ProtoMember(2)] public int Level { get; set; } [ProtoMember(3)] diff --git a/Entity/Generate/NetworkProtocol/OuterOpcode.cs b/Entity/Generate/NetworkProtocol/OuterOpcode.cs index 187ada4..fda636e 100644 --- a/Entity/Generate/NetworkProtocol/OuterOpcode.cs +++ b/Entity/Generate/NetworkProtocol/OuterOpcode.cs @@ -61,29 +61,32 @@ namespace Fantasy public const uint S2C_DeleteMailResponse = 2415929119; public const uint S2C_HaveMail = 2147493663; public const uint S2C_MailState = 2147493664; - public const uint C2S_CreateChannelRequest = 2281711392; - public const uint S2C_CreateChannelResponse = 2415929120; - public const uint C2S_JoinChannelRequest = 2281711393; - public const uint S2C_JoinChannelResponse = 2415929121; - public const uint C2S_SendMessageRequest = 2281711394; - public const uint S2C_SendMessageResponse = 2415929122; - public const uint S2C_Message = 2147493665; - public const uint C2S_CreateClubRequest = 2281711395; - public const uint S2C_CreateClubResponse = 2415929123; - public const uint C2S_GetClubInfoRequest = 2281711396; - public const uint S2C_GetClubInfoResponse = 2415929124; - public const uint C2S_GetMemberListRequest = 2281711397; - public const uint S2C_GetMemberListResponse = 2415929125; - public const uint C2S_GetClubListRequest = 2281711398; - public const uint S2C_GetClubListResponse = 2415929126; - public const uint C2S_JoinClubRequest = 2281711399; - public const uint S2C_JoinClubResponse = 2415929127; - public const uint C2S_LeaveClubRequest = 2281711400; - public const uint S2C_LeaveClubResponse = 2415929128; - public const uint C2S_DissolveClubRequest = 2281711401; - public const uint S2C_DissolveClubResponse = 2415929129; - public const uint C2S_DisposeJoinRequest = 2281711402; - public const uint S2C_DisposeJoinResponse = 2415929130; - public const uint S2C_ClubChange = 2147493666; + public const uint C2Chat_SendMessageRequest = 2281711392; + public const uint Chat2C_SendMessageResponse = 2415929120; + public const uint Chat2C_Message = 2147493665; + public const uint C2S_CreateChannelRequest = 2281711393; + public const uint S2C_CreateChannelResponse = 2415929121; + public const uint C2S_JoinChannelRequest = 2281711394; + public const uint S2C_JoinChannelResponse = 2415929122; + public const uint C2S_SendMessageRequest = 2281711395; + public const uint S2C_SendMessageResponse = 2415929123; + public const uint S2C_Message = 2147493666; + public const uint C2S_CreateClubRequest = 2281711396; + public const uint S2C_CreateClubResponse = 2415929124; + public const uint C2S_GetClubInfoRequest = 2281711397; + public const uint S2C_GetClubInfoResponse = 2415929125; + public const uint C2S_GetMemberListRequest = 2281711398; + public const uint S2C_GetMemberListResponse = 2415929126; + public const uint C2S_GetClubListRequest = 2281711399; + public const uint S2C_GetClubListResponse = 2415929127; + public const uint C2S_JoinClubRequest = 2281711400; + public const uint S2C_JoinClubResponse = 2415929128; + public const uint C2S_LeaveClubRequest = 2281711401; + public const uint S2C_LeaveClubResponse = 2415929129; + public const uint C2S_DissolveClubRequest = 2281711402; + public const uint S2C_DissolveClubResponse = 2415929130; + public const uint C2S_DisposeJoinRequest = 2281711403; + public const uint S2C_DisposeJoinResponse = 2415929131; + public const uint S2C_ClubChange = 2147493667; } } \ No newline at end of file diff --git a/Entity/Modules/ConfigTable/Configs.cs b/Entity/Modules/ConfigTable/Configs.cs new file mode 100644 index 0000000..a840a61 --- /dev/null +++ b/Entity/Modules/ConfigTable/Configs.cs @@ -0,0 +1,20 @@ +using Newtonsoft.Json.Linq; + +namespace NBF; + +public static class Configs +{ + private static cfg.Tables _tables; + public static cfg.Tables Tables => _tables; + + public static void Initialize() + { + _tables = new cfg.Tables(LoadJson); + } + + private static JArray LoadJson(string file) + { + var gameConfigText = File.ReadAllText(Path.Combine(AppContext.BaseDirectory, "cfg", $"{file}.Json")); + return JArray.Parse(gameConfigText); + } +} \ No newline at end of file diff --git a/Entity/Modules/ConfigTable/Interface/IConfigTable.cs b/Entity/Modules/ConfigTable/Interface/IConfigTable.cs index faefeb5..69fd65f 100644 --- a/Entity/Modules/ConfigTable/Interface/IConfigTable.cs +++ b/Entity/Modules/ConfigTable/Interface/IConfigTable.cs @@ -5,6 +5,6 @@ namespace NBF.ConfigTable /// public interface IConfigTable { - public uint Key { get; } + public int Key { get; } } } \ No newline at end of file diff --git a/Entity/Social/Chat/ChatChannel.cs b/Entity/Social/Chat/ChatChannel.cs deleted file mode 100644 index 671ce59..0000000 --- a/Entity/Social/Chat/ChatChannel.cs +++ /dev/null @@ -1,51 +0,0 @@ -using System.Collections.Generic; -using Fantasy.Entitas; -using MongoDB.Bson.Serialization.Attributes; - -namespace NB.Chat; - -/// -/// 聊天频道实体 -/// -public class ChatChannel : Entity -{ - /// - /// 频道绑定id - /// - [BsonElement("cid")] public long ChannelId; - - /// - /// 频道类型 0.地图 1.工会频道 - /// - [BsonElement("type")] public uint ChannelType; - - /// - /// 频道名称 - /// - [BsonElement("name")] public string Name = ""; - - /// - /// 频道密码 - /// - [BsonElement("pass")] public string Password = ""; - - /// - /// 创建者 - /// - [BsonElement("cr")] public long Creator; - - /// - /// 创建时间 - /// - [BsonElement("ct")] public long CreateTime; - - /// - /// 频道地区 0,全球 非0地区 如果是地图频道则表示地图位置 - /// - [BsonElement("region")] public int Region; - - /// - /// 当前频道在线人数 - /// - [BsonIgnore] public readonly HashSet Units = new HashSet(); -} \ No newline at end of file diff --git a/Entity/Social/Chat/ChatChannelCenterComponent.cs b/Entity/Social/Chat/ChatChannelCenterComponent.cs deleted file mode 100644 index 3983f37..0000000 --- a/Entity/Social/Chat/ChatChannelCenterComponent.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System.Collections.Generic; -using Fantasy.Entitas; - -namespace NB.Chat; - -/// -/// 聊天频道管理 -/// -public class ChatChannelCenterComponent : Entity -{ - public readonly Dictionary Channels = new Dictionary(); -} \ No newline at end of file diff --git a/Entity/Social/Chat/Components/ChatChannelCenterComponent.cs b/Entity/Social/Chat/Components/ChatChannelCenterComponent.cs new file mode 100644 index 0000000..1329aca --- /dev/null +++ b/Entity/Social/Chat/Components/ChatChannelCenterComponent.cs @@ -0,0 +1,14 @@ +using Fantasy.Entitas; + +namespace NB.Chat; + +/// +/// 聊天中控中心 +/// 1、申请、创建、解散聊天频道。 +/// 2、管理聊天频道成员。 +/// 3、根据频道ID找到对应的频道。 +/// +public class ChatChannelCenterComponent : Entity +{ + public readonly Dictionary Channels = new(); +} \ No newline at end of file diff --git a/Entity/Social/Chat/Components/ChatChannelComponent.cs b/Entity/Social/Chat/Components/ChatChannelComponent.cs new file mode 100644 index 0000000..ed91eef --- /dev/null +++ b/Entity/Social/Chat/Components/ChatChannelComponent.cs @@ -0,0 +1,14 @@ +using Fantasy.Entitas; + +namespace NB.Chat; + +/// +/// 聊天频道实体 +/// 1、根据频道内的玩家进行广播聊天信息。 +/// 2、当前频道如果没有玩家的话,则自动销毁。 +/// 3、存放当前频道的玩家信息。 +/// +public sealed class ChatChannelComponent : Entity +{ + public readonly HashSet Units = new HashSet(); +} \ No newline at end of file diff --git a/Entity/Social/Chat/Enum/ChatChannelType.cs b/Entity/Social/Chat/Enum/ChatChannelType.cs new file mode 100644 index 0000000..12d6b76 --- /dev/null +++ b/Entity/Social/Chat/Enum/ChatChannelType.cs @@ -0,0 +1,50 @@ +namespace NB.Chat; + +/// +/// 聊天频道类型 +/// +[Flags] +public enum ChatChannelType +{ + None = 0, + World = 1 << 1, // 世界频道 + Private = 1 << 2, // 私聊频道 + System = 1 << 3, // 系统频道 + Broadcast = 1 << 4, // 广播频道 + Notice = 1 << 5, // 公告频道 + Team = 1 << 6, // 队伍频道 + Near = 1 << 7, // 附近频道 + CurrentMap = 1 << 8, // 当前地图频道 + + // 所有频道 + All = World | Private | System | Broadcast | Notice | Team | Near, + + // 其他聊天栏显示的频道 + Display = World | Private | System | Broadcast | Notice | Team | Near | CurrentMap +} + +/// +/// 聊天节点类型 +/// +public enum ChatNodeType +{ + None = 0, + Position = 1, // 位置节点 + OpenUI = 2, // 打开UI节点 + Link = 3, // 链接节点 + Item = 4, // 物品节点 + Text = 5, // 文本节点 + Image = 6, // 图片节点 +} + +/// +/// 聊天节点事件类型 +/// +public enum ChatNodeEvent +{ + None = 0, + OpenUI = 1, // 打开UI节点 + OpenLink = 2, // 点击链接节点 + UseItem = 3, // 使用物品节点 + Position = 4, // 位置节点 +} \ No newline at end of file diff --git a/Entity/Social/Chat/Model/ChatInfoTree.cs b/Entity/Social/Chat/Model/ChatInfoTree.cs new file mode 100644 index 0000000..dd1cb63 --- /dev/null +++ b/Entity/Social/Chat/Model/ChatInfoTree.cs @@ -0,0 +1,17 @@ +using System.Runtime.Serialization; +using Fantasy; +using LightProto; +using MongoDB.Bson.Serialization.Attributes; +using Newtonsoft.Json; + + +namespace Fantasy; + +public partial class ChatInfoTree +{ + [BsonIgnore] + [JsonIgnore] + [ProtoIgnore] + [IgnoreDataMember] + public Scene Scene { get; set; } +} \ No newline at end of file diff --git a/Entity/Social/Chat/Model/ChatUnit.cs b/Entity/Social/Chat/Model/ChatUnit.cs new file mode 100644 index 0000000..10f4447 --- /dev/null +++ b/Entity/Social/Chat/Model/ChatUnit.cs @@ -0,0 +1,11 @@ +// using Fantasy.Entitas; +// +// namespace NB.Chat; +// +// public class ChatUnit : Entity +// { +// public string UserName; +// public long GateRouteId; +// public readonly Dictionary Channels = new(); +// public readonly Dictionary SendTime = new Dictionary(); +// } \ No newline at end of file diff --git a/Entity/Social/SocialUnit.cs b/Entity/Social/SocialUnit.cs index cf86eb2..06840d6 100644 --- a/Entity/Social/SocialUnit.cs +++ b/Entity/Social/SocialUnit.cs @@ -13,11 +13,11 @@ public sealed class SocialUnit : Entity /// 当前所在地图 /// public long MapId; - - /// - /// 当前频道 - /// - public long CurrentChannel; + + + public readonly Dictionary Channels = new(); + public readonly Dictionary SendTime = new Dictionary(); + public override void Dispose() { diff --git a/Hotfix/Common/Handler/G2Common_EnterRequestHandler.cs b/Hotfix/Common/Handler/G2Common_EnterRequestHandler.cs index c1f414c..fe9fa24 100644 --- a/Hotfix/Common/Handler/G2Common_EnterRequestHandler.cs +++ b/Hotfix/Common/Handler/G2Common_EnterRequestHandler.cs @@ -4,6 +4,7 @@ using Fantasy.Async; using Fantasy.Network.Interface; using NB.Chat; using NB.Game; +using NBF.Social; namespace NB.Common; diff --git a/Hotfix/Common/Handler/G2Common_ExitRequestHandler.cs b/Hotfix/Common/Handler/G2Common_ExitRequestHandler.cs index 64f76a6..73ed1a2 100644 --- a/Hotfix/Common/Handler/G2Common_ExitRequestHandler.cs +++ b/Hotfix/Common/Handler/G2Common_ExitRequestHandler.cs @@ -4,6 +4,7 @@ using Fantasy.Async; using Fantasy.Network.Interface; using NB.Chat; using NB.Game; +using NBF.Social; namespace NB.Common; diff --git a/Hotfix/Game/Item/Helper/ItemFactory.cs b/Hotfix/Game/Item/Helper/ItemFactory.cs index 12d4209..68ef510 100644 --- a/Hotfix/Game/Item/Helper/ItemFactory.cs +++ b/Hotfix/Game/Item/Helper/ItemFactory.cs @@ -12,7 +12,7 @@ public static class ItemFactory /// /// /// - public static Item Create(Scene scene, uint configId, int count = 1) + public static Item Create(Scene scene, int configId, int count = 1) { var item = Entity.Create(scene, true, true); item.ConfigId = configId; diff --git a/Hotfix/Game/Item/Helper/ItemHelper.cs b/Hotfix/Game/Item/Helper/ItemHelper.cs index 721c67c..b8f1403 100644 --- a/Hotfix/Game/Item/Helper/ItemHelper.cs +++ b/Hotfix/Game/Item/Helper/ItemHelper.cs @@ -2,7 +2,7 @@ namespace NB.Game; public static class ItemHelper { - public static ItemBasicType GetType(uint id) + public static ItemBasicType GetType(int id) { return (ItemBasicType)(id / 10000); } diff --git a/Hotfix/Game/Item/PlayerItemContainerComponentSystem.cs b/Hotfix/Game/Item/PlayerItemContainerComponentSystem.cs index 4d66edb..d831aa9 100644 --- a/Hotfix/Game/Item/PlayerItemContainerComponentSystem.cs +++ b/Hotfix/Game/Item/PlayerItemContainerComponentSystem.cs @@ -95,7 +95,7 @@ public static class PlayerItemContainerComponentSystem #region Add - public static async FTask Add(this PlayerItemContainerComponent self, Dictionary items) + public static async FTask Add(this PlayerItemContainerComponent self, Dictionary items) { foreach (var (configId, count) in items) { @@ -105,7 +105,7 @@ public static class PlayerItemContainerComponentSystem await self.Save(); } - public static async FTask Add(this PlayerItemContainerComponent self, uint configId, int count, + public static async FTask Add(this PlayerItemContainerComponent self, int configId, int count, bool needSave = true) { var item = ItemFactory.Create(self.Scene, configId, count); diff --git a/Hotfix/Game/Player/Components/PlayerManageComponentSystem.cs b/Hotfix/Game/Player/Components/PlayerManageComponentSystem.cs index 6f9030c..6bb3d1b 100644 --- a/Hotfix/Game/Player/Components/PlayerManageComponentSystem.cs +++ b/Hotfix/Game/Player/Components/PlayerManageComponentSystem.cs @@ -158,27 +158,28 @@ public static class PlayerManageComponentSystem player.Exp = 999; player.Head = "xxx.png"; - var list = InitConfig.GetList(); + // var list = InitConfig.GetList(); + var list = Configs.Tables.TbInitItemConfig.DataList; - Dictionary> - addDic = new Dictionary>(); + Dictionary> + addDic = new Dictionary>(); foreach (var initConfig in list) { var itemType = ItemHelper.GetType(initConfig.Id); if (!addDic.TryGetValue(itemType, out var dic)) { - dic = new Dictionary(); + dic = new Dictionary(); addDic.Add(itemType, dic); } if (!dic.ContainsKey(initConfig.Id)) { - dic.Add(initConfig.Id, initConfig.Amount); + dic.Add(initConfig.Id, initConfig.Count); } else { - dic[initConfig.Id] += initConfig.Amount; + dic[initConfig.Id] += initConfig.Count; } } diff --git a/Hotfix/Game/Player/Entity/PlayerSystem.cs b/Hotfix/Game/Player/Entity/PlayerSystem.cs index 35ceb0f..77f936d 100644 --- a/Hotfix/Game/Player/Entity/PlayerSystem.cs +++ b/Hotfix/Game/Player/Entity/PlayerSystem.cs @@ -45,7 +45,7 @@ public static class PlayerSystem /// /// /// - public static async FTask AddItems(this Player self, Dictionary items) + public static async FTask AddItems(this Player self, Dictionary items) { var itemContainer = self.GetComponent(); diff --git a/Hotfix/Game/Wallet/PlayerWalletComponentSystem.cs b/Hotfix/Game/Wallet/PlayerWalletComponentSystem.cs index 31aeb99..b1576c5 100644 --- a/Hotfix/Game/Wallet/PlayerWalletComponentSystem.cs +++ b/Hotfix/Game/Wallet/PlayerWalletComponentSystem.cs @@ -25,7 +25,7 @@ public static class PlayerWalletComponentSystem /// /// /// - public static bool Have(this PlayerWalletComponent self, uint configId, int count) + public static bool Have(this PlayerWalletComponent self, int configId, int count) { if (self.Currency.TryGetValue(configId, out var value)) { @@ -38,7 +38,7 @@ public static class PlayerWalletComponentSystem return false; } - public static async FTask Add(this PlayerWalletComponent self, uint configId, int count) + public static async FTask Add(this PlayerWalletComponent self, int configId, int count) { if (count < 1) { @@ -54,7 +54,7 @@ public static class PlayerWalletComponentSystem await self.Save(); } - public static async FTask Sub(this PlayerWalletComponent self, uint configId, int count) + public static async FTask Sub(this PlayerWalletComponent self, int configId, int count) { if (count > 0) { diff --git a/Hotfix/Hotfix.csproj b/Hotfix/Hotfix.csproj index e60aa11..7725e43 100644 --- a/Hotfix/Hotfix.csproj +++ b/Hotfix/Hotfix.csproj @@ -12,4 +12,8 @@ + + + + \ No newline at end of file diff --git a/Hotfix/OnCreateSceneEvent.cs b/Hotfix/OnCreateSceneEvent.cs index 520ab29..c1f6599 100644 --- a/Hotfix/OnCreateSceneEvent.cs +++ b/Hotfix/OnCreateSceneEvent.cs @@ -140,8 +140,10 @@ public sealed class OnCreateSceneEvent : AsyncEventSystem Log.Info($"初始化 Social 场景: {scene.Id}"); //用于管理玩家的组件 scene.AddComponent(); - scene.AddComponent(); scene.AddComponent(); + //聊天 + // 聊天频道中控中心组件。 + scene.AddComponent(); await FTask.CompletedTask; } diff --git a/Hotfix/Social/Chat/Handler/C2S_CreateChannelRequestHandler.cs b/Hotfix/Social/Chat/Handler/C2S_CreateChannelRequestHandler.cs deleted file mode 100644 index 2acc730..0000000 --- a/Hotfix/Social/Chat/Handler/C2S_CreateChannelRequestHandler.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System; -using Fantasy; -using Fantasy.Async; -using Fantasy.Network.Interface; - -namespace NB.Chat; - -/// -/// 请求创建频道 -/// -public class - C2S_CreateChannelRequestHandler : AddressRPC -{ - protected override async FTask Run(SocialUnit entity, C2S_CreateChannelRequest request, - S2C_CreateChannelResponse response, Action reply) - { - var channelCenter = entity.Scene.GetComponent(); - if (channelCenter == null) - { - response.ErrorCode = ErrorCode.ErrServer; - return; - } - - var channel = await channelCenter.Create(entity); - - response.ChannelId = channel.Id; - } -} \ No newline at end of file diff --git a/Hotfix/Social/Chat/Handler/C2S_GetOfflineMessageRequestHandler.cs b/Hotfix/Social/Chat/Handler/C2S_GetOfflineMessageRequestHandler.cs deleted file mode 100644 index 54b4465..0000000 --- a/Hotfix/Social/Chat/Handler/C2S_GetOfflineMessageRequestHandler.cs +++ /dev/null @@ -1,24 +0,0 @@ -// using Fantasy; -// using Fantasy.Async; -// using Fantasy.Network.Interface; -// -// namespace NB.Chat; -// -// public class -// C2S_GetOfflineMessageRequestHandler : AddressRPC -// { -// protected override async FTask Run(SocialUnit entity, C2S_GetOfflineMessageRequest request, -// S2C_GetOfflineMessageResponse response, -// Action reply) -// { -// var chatUnitManage = entity.Scene.GetComponent(); -// if (chatUnitManage.NotSendMessage.TryGetValue(entity.Id, out var list)) -// { -// response.Message.AddRange(list); -// chatUnitManage.NotSendMessage.RemoveByKey(entity.Id); -// } -// -// await FTask.CompletedTask; -// } -// } \ No newline at end of file diff --git a/Hotfix/Social/Chat/Handler/C2S_JoinChannelRequestHandler.cs b/Hotfix/Social/Chat/Handler/C2S_JoinChannelRequestHandler.cs deleted file mode 100644 index eaecf3a..0000000 --- a/Hotfix/Social/Chat/Handler/C2S_JoinChannelRequestHandler.cs +++ /dev/null @@ -1,61 +0,0 @@ -using System; -using Fantasy; -using Fantasy.Async; -using Fantasy.Network.Interface; - -namespace NB.Chat; - -/// -/// 请求进入频道 -/// -public class - C2S_JoinChannelRequestHandler : AddressRPC -{ - protected override async FTask Run(SocialUnit entity, C2S_JoinChannelRequest request, - S2C_JoinChannelResponse response, Action reply) - { - if (request.Target < 1) - { - response.ErrorCode = ErrorCode.ErrArgs; - return; - } - - var channelCenter = entity.Scene.GetComponent(); - if (channelCenter == null) - { - response.ErrorCode = ErrorCode.ErrServer; - return; - } - - var oldChannelId = entity.CurrentChannel; - if (oldChannelId > 0) - { - //退出旧的频道 - var oldChannel = await channelCenter.Get(oldChannelId); - if (oldChannel != null) - { - oldChannel.Exit(entity); - } - } - - //加入新频道 - var newChannel = await channelCenter.Get(request.Target); - if (newChannel != null) - { - if (newChannel.ChannelType == 1) - { - //工会频道需要再工会才能加入 - } - else if (newChannel.ChannelType == 0) - { - //地图频道需要判断在这个地图才能加入 - } - - newChannel.Enter(entity); - } - else - { - response.ErrorCode = ErrorCode.ChatNotChannel; - } - } -} \ No newline at end of file diff --git a/Hotfix/Social/Chat/Handler/C2S_SendMessageRequestHandler.cs b/Hotfix/Social/Chat/Handler/C2S_SendMessageRequestHandler.cs deleted file mode 100644 index 7b2c57a..0000000 --- a/Hotfix/Social/Chat/Handler/C2S_SendMessageRequestHandler.cs +++ /dev/null @@ -1,156 +0,0 @@ -using System; -using System.Diagnostics; -using System.Text; -using Fantasy; -using Fantasy.Async; -using Fantasy.Helper; -using Fantasy.Network.Interface; -using NB.Game; - -namespace NB.Chat; - -public sealed class - C2S_SendMessageRequestHandler : AddressRPC -{ - protected override async FTask Run(SocialUnit socialUnit, C2S_SendMessageRequest request, - S2C_SendMessageResponse response, Action reply) - { - if (request.Target < 1) - { - response.ErrorCode = ErrorCode.ErrArgs; - return; - } - - SocialSceneHelper.BroadcastChannel(socialUnit.Scene, request.Target, new ChatMessageInfo() - { - SendTime = TimeHelper.Now, - Content = request.Message, - }); - // if (request.Type == 0) //频道聊天 - // { - // } - // else if (request.Type == 1) //私聊 - // { - // //发送私聊 - // SocialSceneHelper.PrivateMessage(socialUnit.Scene, socialUnit.Id, request.Target, new ChatMessageInfo() - // { - // SendTime = TimeHelper.Now, - // Content = request.Message, - // }); - // } - - - // var list = new List() - // { - // 337951357380329472, - // 337951357380329473, - // 337951357380329474, - // 337951357380329475, - // 337951357380329476, - // 337951357380329477, - // 337951357380329478, - // 337951357380329479, - // 337951357380329480, - // 337951357380329481, - // 337951357380329482, - // 337951357380329483, - // 337951357380329484, - // 337951357380329485, - // 337951357380329486, - // 337951357380329487, - // 337951357380329488, - // 337951357380329489, - // 337951357380329490, - // 337951357380329491, - // 337951357380329492, - // 337951357380329493, - // 337951357380329494, - // 337951357380329495, - // 337951357380329496, - // 337951357380329497, - // 337951357380329498, - // 337951357380329499, - // 337951357380329500, - // 337951357380329501, - // 337951357380329502, - // 337951357380329503, - // 337951357380329504, - // 337951357380329505, - // 337951357380329506, - // 337951357380329507, - // 337951357380329508, - // 337951357380329509, - // 337951357380329510, - // 337951357380329511, - // 337951357380329512, - // 337951357380329513, - // 337951357380329514, - // 337951357380329515, - // 337951357380329516, - // 337951357380329517, - // 337951357380329518, - // 337951357380329519, - // 337951357380329520, - // 337951357380329521, - // 337951357380329522, - // 337951357380329523, - // 337951357380329524, - // 337951357380329525, - // 337951357380329526, - // 337951357380329527, - // 337951357380329528, - // 337951357380329529, - // 337951357380329530, - // 337951357380329531, - // 337951357380329532, - // 337951357380329533, - // 337951357380329534, - // 337951357380329535, - // 337951357380329536, - // 337951357380329537, - // 337951357380329538, - // 337951357380329539, - // 337951357380329540, - // 337951357380329541, - // 337951357380329542, - // 337951357380329543, - // 337951357380329544, - // 337951357380329545, - // 337951357380329546, - // 337951357380329547, - // 337951357380329548, - // 337951357380329549, - // 337951357380329550, - // 337951357380329551, - // 337951357380329552, - // 337951357380329553, - // 337951357380329554, - // 337951357380329555, - // 337951357380329556, - // 337951357380329557, - // 337951357380329558, - // 337951357380329559, - // 337951357380329560, - // 337951357380329561, - // 337951357380329562, - // 337951357380329563, - // 337951357380329564, - // 337951357380329565, - // 337951357380329566, - // 337951357380329567, - // 337951357380329568, - // 337951357380329569, - // 337951357380329570, - // 337951357380329571 - // }; - // - // Stopwatch stopwatch = new Stopwatch(); - // stopwatch.Start(); - // var infoList = await CacheHandler.GetPlayerBasicCacheInfos(socialUnit.Scene,list); - // stopwatch.Stop(); - // Log.Info($"查询数量={infoList.Count} 耗时={stopwatch.ElapsedMilliseconds}"); - // - - await FTask.CompletedTask; - } -} \ No newline at end of file diff --git a/Hotfix/Social/Chat/Handler/Inner/G2Chat_LoginRequestHandler.cs b/Hotfix/Social/Chat/Handler/Inner/G2Chat_LoginRequestHandler.cs new file mode 100644 index 0000000..f546445 --- /dev/null +++ b/Hotfix/Social/Chat/Handler/Inner/G2Chat_LoginRequestHandler.cs @@ -0,0 +1,21 @@ +// using Fantasy; +// using Fantasy.Async; +// using Fantasy.Entitas; +// using Fantasy.Network.Interface; +// +// namespace NB.Chat; +// +// public sealed class G2Chat_LoginRequestHandler : AddressRPC +// { +// protected override async FTask Run(Scene scene, G2Chat_LoginRequest request, Chat2G_LoginResponse response, Action reply) +// { +// var chatUnit = scene.GetComponent().Add(request.UnitId, request.UserName, request.GateRouteId); +// response.ChatRouteId = chatUnit.RunTimeId; +// // 这里模拟创建一个频道用于测试用 +// var chatChannelCenterComponent = scene.GetComponent(); +// var chatChannelComponent = chatChannelCenterComponent.Apply(1); +// // 加入到聊天频道 +// chatChannelComponent.JoinChannel(request.UnitId); +// await FTask.CompletedTask; +// } +// } \ No newline at end of file diff --git a/Hotfix/Social/Chat/Handler/Inner/G2Chat_OfflineRequestHandler.cs b/Hotfix/Social/Chat/Handler/Inner/G2Chat_OfflineRequestHandler.cs new file mode 100644 index 0000000..d6cb227 --- /dev/null +++ b/Hotfix/Social/Chat/Handler/Inner/G2Chat_OfflineRequestHandler.cs @@ -0,0 +1,13 @@ +// using Fantasy.Async; +// using Fantasy.Network.Interface; +// +// namespace NB.Chat; +// +// public sealed class G2Chat_OfflineRequestHandler : AddressRPC +// { +// protected override async FTask Run(ChatUnit chatUnit, G2Chat_OfflineRequest request, Chat2G_OfflineResponse response, Action reply) +// { +// await FTask.CompletedTask; +// chatUnit.Scene.GetComponent().Remove(chatUnit.Id); +// } +// } \ No newline at end of file diff --git a/Hotfix/Social/Chat/Handler/Inner/Other2Chat_ChatMessageHandler.cs b/Hotfix/Social/Chat/Handler/Inner/Other2Chat_ChatMessageHandler.cs new file mode 100644 index 0000000..c0ccc97 --- /dev/null +++ b/Hotfix/Social/Chat/Handler/Inner/Other2Chat_ChatMessageHandler.cs @@ -0,0 +1,20 @@ +using Fantasy; +using Fantasy.Async; +using Fantasy.Network.Interface; + +namespace NB.Chat; + +public sealed class Other2Chat_ChatMessageHandler : Address +{ + protected override async FTask Run(SocialUnit chatUnit, Other2Chat_ChatMessage message) + { + var result = ChatSceneHelper.Distribution(chatUnit, message.ChatInfoTree, false); + + if (result != 0) + { + Log.Warning($"Other2Chat_ChatMessageHandler: Distribution failed, result: {result}"); + } + + await FTask.CompletedTask; + } +} \ No newline at end of file diff --git a/Hotfix/Social/Chat/Handler/Outer/C2Chat_SendMessageRequestHandler.cs b/Hotfix/Social/Chat/Handler/Outer/C2Chat_SendMessageRequestHandler.cs new file mode 100644 index 0000000..4b97446 --- /dev/null +++ b/Hotfix/Social/Chat/Handler/Outer/C2Chat_SendMessageRequestHandler.cs @@ -0,0 +1,14 @@ +using Fantasy; +using Fantasy.Async; +using Fantasy.Network.Interface; + +namespace NB.Chat; + +public sealed class C2Chat_SendMessageRequestHandler : AddressRPC +{ + protected override async FTask Run(SocialUnit chatUnit, C2Chat_SendMessageRequest request, Chat2C_SendMessageResponse response, Action reply) + { + response.ErrorCode = ChatSceneHelper.Distribution(chatUnit, request.ChatInfoTree); + await FTask.CompletedTask; + } +} \ No newline at end of file diff --git a/Hotfix/Social/Chat/Helper/ChatChannelCenterHelper.cs b/Hotfix/Social/Chat/Helper/ChatChannelCenterHelper.cs new file mode 100644 index 0000000..a4dbf97 --- /dev/null +++ b/Hotfix/Social/Chat/Helper/ChatChannelCenterHelper.cs @@ -0,0 +1,39 @@ +using Fantasy; + +namespace NB.Chat; + +public static class ChatChannelCenterHelper +{ + /// + /// 申请一个频道 + /// + /// + /// + /// + public static ChatChannelComponent Apply(Scene scene, long channelId) + { + return scene.GetComponent().Apply(channelId); + } + + /// + /// 尝试获取一个频道 + /// + /// + /// + /// + /// + public static bool TryGet(Scene scene, long channelId, out ChatChannelComponent channel) + { + return scene.GetComponent().TryGet(channelId, out channel); + } + + /// + /// 解散一个频道 + /// + /// + /// + public static void Disband(Scene scene, long channelId) + { + scene.GetComponent().Disband(channelId); + } +} \ No newline at end of file diff --git a/Hotfix/Social/Chat/Helper/ChatHelper.cs b/Hotfix/Social/Chat/Helper/ChatHelper.cs new file mode 100644 index 0000000..c8fefa4 --- /dev/null +++ b/Hotfix/Social/Chat/Helper/ChatHelper.cs @@ -0,0 +1,30 @@ +using Fantasy; +using Fantasy.Platform.Net; + +namespace NB.Chat; + +public static class ChatHelper +{ + /// + /// 发送一个聊天消息给ChatScene(不能在ChatScene中调用) + /// + /// + /// + /// + public static void SendChatMessage(Scene scene, long chatUnitRouteId, ChatInfoTree tree) + { + if (scene.SceneType == SceneType.Social) + { + Log.Warning("ChatHelper.SendChatMessage: scene is not a chat scene."); + return; + } + + var other2ChatChatMessage = new Other2Chat_ChatMessage() + { + ChatInfoTree = tree + }; + + // scene.NetworkMessagingComponent.SendInnerRoute(chatUnitRouteId, other2ChatChatMessage); + scene.NetworkMessagingComponent.Send(chatUnitRouteId, other2ChatChatMessage); + } +} \ No newline at end of file diff --git a/Hotfix/Social/Chat/Helper/ChatNodeFactory.cs b/Hotfix/Social/Chat/Helper/ChatNodeFactory.cs new file mode 100644 index 0000000..591c0e9 --- /dev/null +++ b/Hotfix/Social/Chat/Helper/ChatNodeFactory.cs @@ -0,0 +1,128 @@ +// using Fantasy; +// +// namespace NB.Chat +// { +// /// +// /// 聊天信息节点 +// /// +// public static class ChatNodeFactory +// { +// /// +// /// 添加文本节点 +// /// +// /// +// /// +// /// +// public static ChatInfoTree AddendTextNode(this ChatInfoTree chatInfoTree, string content) +// { +// var chatInfoNode = new ChatInfoNode() +// { +// ChatNodeType = (int)ChatNodeType.Text, +// Content = content +// }; +// chatInfoTree.Node.Add(chatInfoNode); +// return chatInfoTree; +// } +// +// /// +// /// 添加链接节点 +// /// +// /// +// /// +// /// +// /// +// public static ChatInfoTree AddendLinkNode(this ChatInfoTree chatInfoTree, string content, string link) +// { +// var chatLinkNode = new ChatLinkNode() +// { +// Link = link +// }; +// var serializerComponent = chatInfoTree.Scene.GetComponent(); +// var chatInfoNode = new ChatInfoNode() +// { +// ChatNodeType = (int)ChatNodeType.Link, +// ChatNodeEvent = (int)ChatNodeEvent.OpenLink, +// Content = content, +// Data = serializerComponent.Serialize(chatLinkNode) +// }; +// chatInfoTree.Node.Add(chatInfoNode); +// return chatInfoTree; +// } +// +// /// +// /// 添加图片节点 +// /// +// /// +// /// +// /// +// public static ChatInfoTree AddendImageNode(this ChatInfoTree chatInfoTree, string content) +// { +// var chatInfoNode = new ChatInfoNode() +// { +// ChatNodeType = (int)ChatNodeType.Image, +// Content = content +// }; +// chatInfoTree.Node.Add(chatInfoNode); +// return chatInfoTree; +// } +// +// /// +// /// 添加打开UI节点 +// /// +// /// +// /// +// /// +// /// +// public static ChatInfoTree AddendOpenUINode(this ChatInfoTree chatInfoTree, string content, string uiName) +// { +// var chatOpenUINode = new ChatOpenUINode() +// { +// UIName = uiName +// }; +// var serializerComponent = chatInfoTree.Scene.GetComponent(); +// var chatInfoNode = new ChatInfoNode() +// { +// ChatNodeType = (int)ChatNodeType.OpenUI, +// ChatNodeEvent = (int)ChatNodeEvent.OpenUI, +// Content = content, +// Data = serializerComponent.Serialize(chatOpenUINode) +// }; +// chatInfoTree.Node.Add(chatInfoNode); +// return chatInfoTree; +// } +// +// /// +// /// 添加位置节点 +// /// +// /// +// /// +// /// +// /// +// /// +// /// +// /// +// public static ChatInfoTree AddendPositionNode(this ChatInfoTree chatInfoTree, string content, string mapName, +// float mapX, float mapY, float mapZ) +// { +// var chatPositionNode = new ChatPositionNode() +// { +// MapName = mapName, +// PosX = mapX, +// PosY = mapY, +// PosZ = mapZ, +// }; +// +// var serializerComponent = chatInfoTree.Scene.GetComponent(); +// var chatInfoNode = new ChatInfoNode() +// { +// ChatNodeType = (int)ChatNodeType.Position, +// ChatNodeEvent = (int)ChatNodeEvent.Position, +// Content = content, +// Data = serializerComponent.Serialize(chatPositionNode) +// }; +// +// chatInfoTree.Node.Add(chatInfoNode); +// return chatInfoTree; +// } +// } +// } \ No newline at end of file diff --git a/Hotfix/Social/Chat/Helper/ChatSceneHelper.cs b/Hotfix/Social/Chat/Helper/ChatSceneHelper.cs new file mode 100644 index 0000000..7f390df --- /dev/null +++ b/Hotfix/Social/Chat/Helper/ChatSceneHelper.cs @@ -0,0 +1,258 @@ +using System.Threading.Channels; +using Fantasy; +using Fantasy.Helper; +using Fantasy.Platform.Net; +using NBF.Social; + +// ReSharper disable ConditionIsAlwaysTrueOrFalseAccordingToNullableAPIContract + +namespace NB.Chat; + +public static class ChatSceneHelper +{ + private const int ChatCD = 1000; + private const int MaxTextLength = 10; + private const int MaxShowItemCount = 2; + + /// + /// 聊天消息分发入口 + /// + /// + /// + /// + /// + public static uint Distribution(SocialUnit chatUnit, ChatInfoTree tree, bool isCheckSendTime = true) + { + var result = Condition(chatUnit, tree, isCheckSendTime); + + if (result != 0) + { + return result; + } + + switch ((ChatChannelType)tree.ChatChannelType) + { + case ChatChannelType.Broadcast: + { + Broadcast(chatUnit.Scene, tree); + return 0; + } + case ChatChannelType.Team: + { + return Channel(chatUnit, tree); + } + case ChatChannelType.Private: + { + return Private(chatUnit, tree); + } + default: + { + // 这个1代表当前频道不存在。 + return 1; + } + } + } + + /// + /// 聊天消息条件判断 + /// + /// + /// + /// + /// + private static uint Condition(SocialUnit chatUnit, ChatInfoTree tree, bool isCheckSendTime = true) + { + // 每个频道可能聊天的间隔都不一样。 + // 这里的条件判断,是根据频道的类型,来判断是否到达了聊天的间隔。 + var now = TimeHelper.Now; + + if (isCheckSendTime) + { + // 这里的间隔时间,是根据频道的类型,来获取的。 + chatUnit.SendTime.TryGetValue(tree.ChatChannelType, out var sendTime); + // 判定聊天间隔是否到达 + // 其实的话,这个ChatCD应该是根据频道的类型,来获取的。 + // 一般的话都是做一个配置表,通过配置表来获取不同频道的时间间隔。 + if (now - sendTime < ChatCD) + { + // 这个1代表当前频道聊天的间隔过短 + return 1; + } + } + + // 判定聊天内容是否超长 + + var itemCount = 0; + var chatTextSize = 0; + + foreach (var chatInfoNode in tree.Node) + { + switch ((ChatNodeType)chatInfoNode.ChatNodeType) + { + case ChatNodeType.Text: + { + chatTextSize += chatInfoNode.Content.Length; + break; + } + case ChatNodeType.Image: + { + // 规定图片占聊天消息的5个字符长度 + chatTextSize += 5; + break; + } + case ChatNodeType.OpenUI: + { + // 规定OpenUI占聊天消息的10个字符长度 + chatTextSize += 10; + break; + } + case ChatNodeType.Item: + { + itemCount++; + break; + } + } + } + + if (chatTextSize > MaxTextLength) + { + // 这个2代表当前频道聊天内容超长 + return 2; + } + + if (itemCount > MaxShowItemCount) + { + // 这个3代表当前频道聊天里道具数量过多 + return 3; + } + + if (isCheckSendTime) + { + // 更新当前频道的发送时间 + chatUnit.SendTime[tree.ChatChannelType] = now; + } + + return 0; + } + + #region 不同聊天频道的实现 + + /// + /// 广播消息 + /// + /// + /// + private static void Broadcast(Scene scene, ChatInfoTree tree) + { + var networkMessagingComponent = scene.NetworkMessagingComponent; + var chatMessage = new Chat2G_ChatMessage() + { + ChatInfoTree = tree + }; + + if (tree.Target.Count > 0) + { + var chatUnitManageComponent = scene.GetComponent(); + // 给一部分人广播消息 + foreach (var chatUnitId in tree.Target) + { + if (!chatUnitManageComponent.TryGet(chatUnitId, out var chatUnit)) + { + continue; + } + + // networkMessagingComponent.SendInnerRoute(chatUnit.GateRouteId, chatMessage); + networkMessagingComponent.Send(chatUnit.GateRouteId, chatMessage); + } + return; + } + + // 发送给所有Gate服务器,让Gate服务器转发给其他客户端 + var gateConfigs = SceneConfigData.Instance.GetSceneBySceneType(SceneType.Gate); + foreach (var gateSceneConfig in gateConfigs) + { + // 这里是要发送一个消息给Gate服务器,Gate服务器再转发给其他客户端 + // networkMessagingComponent.SendInnerRoute(gateSceneConfig.RouteId, chatMessage); + networkMessagingComponent.Send(gateSceneConfig.Address, chatMessage); + } + } + + /// + /// 发送频道消息 + /// + /// + /// + private static uint Channel(SocialUnit chatUnit, ChatInfoTree tree) + { + // 那组队,公会、地图、等这个的聊天,如何使用频道呢? + // 这里的频道,是指一个频道,比如一个公会的频道,一个队伍的频道,一个地图的频道。 + // 1、一般组队工会、地图等,都是有一个创建的一个逻辑,咱们个在这个创建的逻辑中,根据队伍、公会、地图的ID + // 把这些ID当做频道ID,然后发送到Chat服务器,先申请一个频道,把这个频道ID返回给创建公会队伍的逻辑。 + // 这时候,队伍公会、发送聊天消息的时候,就会根据这个ID来进行发送。 + // 2、地图同样道理,创建地图的时候,也会有一个创建的逻辑,这个逻辑会返回一个地图的ID,这个ID就是地图的频道ID。 + // 3、这这些ID根据频道类型,发送给客户端,客户端发送的时候,根据频道不同,拿不同的ID来发送。 + + // 课外: + // 客户端创建一个频道、拿到这个频道号,告诉其他人,其他人通过这个频道ID加入到这个频道。 + // 客户端创建一个频道,邀请其他人加入到这个频道,其他人可能客户端会接收一个协议,就是邀请你加入到这个频道,如果同意, + // 你就加入到这个频道(你点同意后,会发送一个消息给聊天服务器,聊天服务器会把你加入到这个频道)。 + + if (!chatUnit.Channels.TryGetValue(tree.ChatChannelId, out var channel)) + { + // 这个1代表当前频道不存在。 + return 1; + } + + channel.Send(tree); + return 0; + } + + /// + /// 发送私聊消息 + /// + /// + /// + /// + private static uint Private(SocialUnit chatUnit, ChatInfoTree tree) + { + // 私聊,就是两个玩家之间,直接聊天。 + // 1、首先,客户端需要知道对方的ID,这个ID是通过什么方式获取的呢? + // 2、客户端需要发送一个私聊消息给聊天服务器,聊天服务器需要把这个消息转发给对方。 + // 3、对方收到消息后,需要显示出来。 + // 4、聊天服务器需要记录这个私聊消息,并把这个消息转发给两个玩家。 + // 5、两个玩家收到消息后,需要显示出来。 + + if (tree.Target == null || tree.Target.Count <= 0) + { + // 这个1代表对方ID不的合法的。 + return 1; + } + + var targetChatUnitId = tree.Target[0]; + var scene = chatUnit.Scene; + if (!scene.GetComponent().TryGet(targetChatUnitId, out var targetChatUnit)) + { + // 这个2代表对方不在线。 + return 2; + } + + var networkMessagingComponent = scene.NetworkMessagingComponent; + var chatMessage = new Chat2C_Message() + { + ChatInfoTree = tree + }; + + // // 先给自己发送一个聊天消息。 + // networkMessagingComponent.SendInnerRoute(chatUnit.GateRouteId, chatMessage); + // // 然后再给对方发送一个聊天消息。 + // networkMessagingComponent.SendInnerRoute(targetChatUnit.GateRouteId, chatMessage); + + // 先给自己发送一个聊天消息。 + networkMessagingComponent.Send(chatUnit.GateRouteId, chatMessage); + // 然后再给对方发送一个聊天消息。 + networkMessagingComponent.Send(targetChatUnit.GateRouteId, chatMessage); + return 0; + } + + #endregion +} \ No newline at end of file diff --git a/Hotfix/Social/Chat/Helper/ChatTreeFactory.cs b/Hotfix/Social/Chat/Helper/ChatTreeFactory.cs new file mode 100644 index 0000000..a5f5cd7 --- /dev/null +++ b/Hotfix/Social/Chat/Helper/ChatTreeFactory.cs @@ -0,0 +1,121 @@ +using Fantasy; + +namespace NB.Chat; + +/// +/// 创建聊天树的总入口 +/// +public static class ChatTreeFactory +{ + /// + /// 创建世界聊天树 + /// + /// + /// + public static ChatInfoTree World(Scene scene) + { + return new ChatInfoTree() + { + Scene = scene, + ChatChannelType = (int)ChatChannelType.World, + }; + } + + /// + /// 创建私聊聊天树 + /// + /// + /// + public static ChatInfoTree Private(Scene scene) + { + return new ChatInfoTree() + { + Scene = scene, + ChatChannelType = (int)ChatChannelType.Private, + }; + } + + /// + /// 创建系统聊天树 + /// + /// + /// + public static ChatInfoTree System(Scene scene) + { + return new ChatInfoTree() + { + Scene = scene, + ChatChannelType = (int)ChatChannelType.System, + }; + } + + /// + /// 创建公广播聊天树 + /// + /// + /// + public static ChatInfoTree Broadcast(Scene scene) + { + return new ChatInfoTree() + { + Scene = scene, + ChatChannelType = (int)ChatChannelType.Broadcast, + }; + } + + /// + /// 创建公告聊天树 + /// + /// + /// + public static ChatInfoTree Notice(Scene scene) + { + return new ChatInfoTree() + { + Scene = scene, + ChatChannelType = (int)ChatChannelType.Notice, + }; + } + + /// + /// 创建队伍聊天树 + /// + /// + /// + public static ChatInfoTree Team(Scene scene) + { + return new ChatInfoTree() + { + Scene = scene, + ChatChannelType = (int)ChatChannelType.Team, + }; + } + + /// + /// 创建附近人聊天树 + /// + /// + /// + public static ChatInfoTree Near(Scene scene) + { + return new ChatInfoTree() + { + Scene = scene, + ChatChannelType = (int)ChatChannelType.Near, + }; + } + + /// + /// 创建当前地图聊天树 + /// + /// + /// + public static ChatInfoTree CurrentMap(Scene scene) + { + return new ChatInfoTree() + { + Scene = scene, + ChatChannelType = (int)ChatChannelType.CurrentMap, + }; + } +} \ No newline at end of file diff --git a/Hotfix/Social/Chat/Helper/ChatUnitFactory.cs b/Hotfix/Social/Chat/Helper/ChatUnitFactory.cs deleted file mode 100644 index 9df3471..0000000 --- a/Hotfix/Social/Chat/Helper/ChatUnitFactory.cs +++ /dev/null @@ -1,20 +0,0 @@ -using Fantasy; -using Fantasy.Entitas; - -namespace NB.Chat; - -public static class ChatUnitFactory -{ - /// - /// 创建一个新的Player - /// - /// - /// ToKen令牌传递过来的aId - /// 是否在创建的过程中保存到数据库 - /// - public static SocialUnit Create(Scene scene, long aId) - { - var player = Entity.Create(scene, aId, true, true); - return player; - } -} \ No newline at end of file diff --git a/Hotfix/Social/Chat/Helper/SocialSceneHelper.cs b/Hotfix/Social/Chat/Helper/SocialSceneHelper.cs deleted file mode 100644 index 972d99e..0000000 --- a/Hotfix/Social/Chat/Helper/SocialSceneHelper.cs +++ /dev/null @@ -1,173 +0,0 @@ -using System.Collections.Generic; -using Fantasy; -using Fantasy.Async; -using Fantasy.Platform.Net; - -namespace NB.Chat; - -public static class SocialSceneHelper -{ - #region 消息发送 - - /// - /// 发送一条私聊 - /// - /// - /// - /// - /// - public static void PrivateMessage(Scene scene, long selfId, long targetId, ChatMessageInfo message) - { - var chatUnitManage = scene.GetComponent(); - if (chatUnitManage == null) return; - var chatUnit = chatUnitManage.Get(targetId); - message.Type = 1; - message.Source = selfId; - if (chatUnit != null) - { - //对方在线 - BroadcastAll(scene, message, [targetId]); - } - else - { - //对方不在线,存入待领取列表,等待玩家下次登录领取 - chatUnitManage.SaveOfflineMessage(targetId, message); - } - } - - /// - /// 发送一条地图消息 - /// - /// - /// - /// - public static void BroadcastMap(Scene scene, long mapId, ChatMessageInfo message) - { - var chatUnitManage = scene.GetComponent(); - if (chatUnitManage == null) return; - HashSet targets = new HashSet(); - foreach (var (_, chatUnit) in chatUnitManage.Units) - { - if (chatUnit.MapId == mapId) - { - targets.Add(chatUnit.Id); - } - } - - if (targets.Count < 1) - { - Log.Info("地图在线人数为0,群发取消"); - return; - } - - BroadcastAll(scene, message, targets); - } - - /// - /// 发送一条频道消息 - /// - /// - /// - /// - public static void BroadcastChannel(Scene scene, long channelId, ChatMessageInfo message) - { - var chatUnitManage = scene.GetComponent(); - if (chatUnitManage == null) return; - HashSet targets = new HashSet(); - foreach (var (_, chatUnit) in chatUnitManage.Units) - { - if (chatUnit.CurrentChannel == channelId) - { - targets.Add(chatUnit.Id); - } - } - - if (targets.Count < 1) - { - Log.Info("频道在线人数为0,群发取消"); - return; - } - - BroadcastAll(scene, message, targets); - } - - /// - /// 广播消息给所有人 - /// - /// - /// - /// - public static void BroadcastAll(Scene scene, ChatMessageInfo message, HashSet? targets = null) - { - //发送给所有Gate服务器,让Gate转发给其他客户端 - var gateConfigs = SceneConfigData.Instance.GetSceneBySceneType(SceneType.Gate); - var sendMessage = new S2G_ChatMessage() - { - Message = message, - }; - if (targets != null && targets.Count > 0) - { - sendMessage.IdList.AddRange(targets); - } - - var networkMessagingComponent = scene.NetworkMessagingComponent; - foreach (var config in gateConfigs) - { - //发送给Gate服务器转发消息 - networkMessagingComponent.Send(config.Address, sendMessage); - } - } - - #endregion - - - #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); - // } - // - // 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/ChatChannelCenterComponentSystem.cs b/Hotfix/Social/Chat/System/ChatChannelCenterComponentSystem.cs index 805c9e8..635bc58 100644 --- a/Hotfix/Social/Chat/System/ChatChannelCenterComponentSystem.cs +++ b/Hotfix/Social/Chat/System/ChatChannelCenterComponentSystem.cs @@ -1,74 +1,42 @@ -using Fantasy.Async; -using Fantasy.Entitas; +using Fantasy.Entitas; using Fantasy.Entitas.Interface; -using Fantasy.Helper; + +#pragma warning disable CS8602 // Dereference of a possibly null reference. +#pragma warning disable CS8601 // Possible null reference assignment. namespace NB.Chat; -public class ChatChannelCenterComponentAwakeSystem : AwakeSystem -{ - protected override void Awake(ChatChannelCenterComponent self) - { - } -} - -public class ChatChannelCenterComponentDestroySystem : DestroySystem +public sealed class ChatChannelCenterComponentDestroySystem : DestroySystem { protected override void Destroy(ChatChannelCenterComponent self) { + foreach (var chatChannelComponent in self.Channels.Values.ToArray()) + { + chatChannelComponent.Dispose(); + } self.Channels.Clear(); } } public static class ChatChannelCenterComponentSystem { - /// - /// 获取一个频道 - /// - /// - /// - /// - public static async FTask Get(this ChatChannelCenterComponent self, long channelId) + public static ChatChannelComponent Apply(this ChatChannelCenterComponent self, long channelId) { if (self.Channels.TryGetValue(channelId, out var channel)) { return channel; } - //查数据库 - channel = await self.Scene.World.Database.Query(channelId, true); - if (channel != null) - { - self.Channels.Add(channel.Id, channel); - } - + channel = Entity.Create(self.Scene, channelId, true, true); + self.Channels.Add(channelId, channel); return channel; } - /// - /// 申请创建一个频道 - /// - /// - /// - /// - public static async FTask Create(this ChatChannelCenterComponent self, SocialUnit unit) + public static bool TryGet(this ChatChannelCenterComponent self, long channelId, out ChatChannelComponent channel) { - var channel = Entity.Create(self.Scene, true, true); - channel.Creator = unit.Role.RoleId; - channel.CreateTime = TimeHelper.Now; - self.Channels.Add(channel.Id, channel); - //保存到数据库 - await self.Scene.World.Database.Save(channel); - - return channel; + return self.Channels.TryGetValue(channelId, out channel); } - - /// - /// 解散 - /// - /// - /// public static void Disband(this ChatChannelCenterComponent self, long channelId) { if (self.Channels.Remove(channelId, out var channel)) @@ -76,6 +44,6 @@ public static class ChatChannelCenterComponentSystem return; } - channel?.Dispose(); + channel.Dispose(); } } \ No newline at end of file diff --git a/Hotfix/Social/Chat/System/ChatChannelComponentSystem.cs b/Hotfix/Social/Chat/System/ChatChannelComponentSystem.cs new file mode 100644 index 0000000..d59755a --- /dev/null +++ b/Hotfix/Social/Chat/System/ChatChannelComponentSystem.cs @@ -0,0 +1,89 @@ +using Fantasy; +using Fantasy.Entitas; +using NBF.Social; + +namespace NB.Chat; + +public class MemoryEntity : Entity +{ + +} + + +public static class ChatChannelComponentSystem +{ + public static void Send(this ChatChannelComponent self, ChatInfoTree tree) + { + var chatUnitManageComponent = self.Scene.GetComponent(); + var networkMessagingComponent = self.Scene.NetworkMessagingComponent; + var chatMessage = new Chat2C_Message() + { + ChatInfoTree = tree + }; + + foreach (var unitId in self.Units) + { + if (!chatUnitManageComponent.Units.TryGetValue(unitId, out var chatUnit)) + { + continue; + } + + // networkMessagingComponent.SendInnerRoute(chatUnit.GateRouteId, chatMessage); + networkMessagingComponent.Send(chatUnit.GateRouteId, chatMessage); + } + } + + public static bool JoinChannel(this ChatChannelComponent self, long chatUnitId) + { + var chatUnitManageComponent = self.Scene.GetComponent(); + + if (!chatUnitManageComponent.TryGet(chatUnitId, out var chatUnit)) + { + return false; + } + + // 将当前频道中加入该用户。 + self.Units.Add(chatUnitId); + // 给用户添加频道。 + if (!chatUnit.Channels.ContainsKey(self.Id)) + { + chatUnit.Channels.Add(self.Id, self); + } + // 可以在这里给客户端发送一个加入频道成功的消息。 + return true; + } + + public static bool IsJoinedChannel(this ChatChannelComponent self, long chatUnitId) + { + return self.Units.Contains(chatUnitId); + } + + public static void ExitChannel(this ChatChannelComponent self, long chatUnitId, bool isRemoveUnitChannel = true) + { + if (!self.Units.Contains(chatUnitId)) + { + return; + } + + var chatUnitManageComponent = self.Scene.GetComponent(); + + if (!chatUnitManageComponent.TryGet(chatUnitId, out var chatUnit)) + { + return; + } + + if (isRemoveUnitChannel) + { + // 给用户移除频道。 + chatUnit.Channels.Remove(self.Id); + } + + // 在当前频道中移除该用户。 + self.Units.Remove(chatUnitId); + // 如果当前频道中没有用户了,则销毁该频道。 + if (self.Units.Count == 0) + { + self.Dispose(); + } + } +} \ No newline at end of file diff --git a/Hotfix/Social/Chat/System/ChatChannelSystem.cs b/Hotfix/Social/Chat/System/ChatChannelSystem.cs deleted file mode 100644 index 3f0b845..0000000 --- a/Hotfix/Social/Chat/System/ChatChannelSystem.cs +++ /dev/null @@ -1,28 +0,0 @@ -using Fantasy; - -namespace NB.Chat; - -public static class ChatChannelSystem -{ - /// - /// 进入频道 - /// - /// - /// - public static void Enter(this ChatChannel channel, SocialUnit unit) - { - channel.Units.Add(unit.Id); - unit.CurrentChannel = channel.Id; - } - - /// - /// 离开频道 - /// - /// - /// - public static void Exit(this ChatChannel channel, SocialUnit unit) - { - channel.Units.Remove(unit.Id); - unit.CurrentChannel = 0; - } -} \ No newline at end of file diff --git a/Hotfix/Social/Chat/System/ChatUnitManageComponentSystem.cs b/Hotfix/Social/Chat/System/ChatUnitManageComponentSystem.cs index 9fdaf7b..741d76a 100644 --- a/Hotfix/Social/Chat/System/ChatUnitManageComponentSystem.cs +++ b/Hotfix/Social/Chat/System/ChatUnitManageComponentSystem.cs @@ -1,132 +1,70 @@ -using System.Collections.Generic; -using Fantasy; -using Fantasy.Async; -using Fantasy.Entitas; -using NB.Game; +// using Fantasy; +// using Fantasy.Entitas; +// using Fantasy.Entitas.Interface; +// +// #pragma warning disable CS8601 // Possible null reference assignment. +// +// namespace NB.Chat; +// +// public sealed class ChatUnitManageComponentDestroySystem : DestroySystem +// { +// protected override void Destroy(ChatUnitManageComponent self) +// { +// foreach (var chatUnit in self.Units.Values.ToArray()) +// { +// chatUnit.Dispose(); +// } +// +// self.Units.Clear(); +// } +// } -namespace NB.Chat; - -public static class ChatUnitManageComponentSystem -{ - #region 消息缓存 - - /// - /// 离线消息,进入待领取队列 - /// - /// - /// - /// - public static void SaveOfflineMessage(this SocialUnitManageComponent self, long targetId, ChatMessageInfo message) - { - // self.NotSendMessage.Add(targetId, message); - } - - #endregion - - #region 上线下线 - - /// - /// 玩家上线 - /// - /// - /// - /// - /// - public static async FTask Online(this SocialUnitManageComponent self, Scene scene, - long accountId, - long gateRouteId) - { - // var accountId = roleSimpleInfo.RoleId; - if (!self.TryGet(accountId, out var account)) - { - account = ChatUnitFactory.Create(scene, accountId); - self.Add(account); - } - - if (account != null) - { - await account.TryComponent(); - account.GateRouteId = gateRouteId; - // account.Role = roleSimpleInfo; - } - - await FTask.CompletedTask; - return account; - } - - public static async FTask Offline(this SocialUnitManageComponent self, Scene scene, long accountId, long gateRouteId) - { - if (self.TryGet(accountId, out var unit) && unit != null) - { - if (unit.GateRouteId == gateRouteId) - { - Log.Info("退出当前聊天服=="); - self.Remove(accountId); //如果当前网关和下线的网关一致 - } - } - - await FTask.CompletedTask; - } - - #endregion - - #region 获取&移除 - - public static void Add(this SocialUnitManageComponent self, SocialUnit account) - { - self.Units.Add(account.Id, account); - } - - public static SocialUnit? Get(this SocialUnitManageComponent self, long accountId) - { - return self.Units.GetValueOrDefault(accountId); - } - - public static bool TryGet(this SocialUnitManageComponent self, long accountId, out SocialUnit? account) - { - return self.Units.TryGetValue(accountId, out account); - } - - public static void Remove(this SocialUnitManageComponent self, long accountId, bool isDispose = true) - { - if (!self.Units.Remove(accountId, out var account)) - { - return; - } - - if (!isDispose) - { - return; - } - - account.Dispose(); - } - - #endregion - - #region 组件 - - /// - /// 尝试给增加相关组件 - /// - /// - /// - public static async FTask TryComponent(this SocialUnit socialUnit) where T : Entity, new() - { - if (socialUnit.GetComponent() == null) - { - var mailComponent = await socialUnit.Scene.World.Database.Query(socialUnit.Id, true); - if (mailComponent == null) - { - //如果没有邮件组件 - socialUnit.AddComponent(); - } - else - { - socialUnit.AddComponent(mailComponent); - } - } - } - - #endregion -} \ No newline at end of file +// public static class ChatUnitManageComponentSystem +// { +// public static ChatUnit Add(this ChatUnitManageComponent self, long unitId, string userName, long gateRouteId) +// { +// if (!self.Units.TryGetValue(unitId, out var chatUnit)) +// { +// chatUnit = Entity.Create(self.Scene, unitId, true, true); +// self.Units.Add(unitId, chatUnit); +// Log.Debug( +// $"Add ChatUnit Count: {self.Units.Count} UnitId: {unitId} UserName: {userName} GateRouteId: {gateRouteId}"); +// } +// else +// { +// Log.Debug($"ChatUnit: {chatUnit.UserName}({chatUnit.GateRouteId})"); +// } +// +// chatUnit.UserName = userName; +// chatUnit.GateRouteId = gateRouteId; +// return chatUnit; +// } +// +// public static ChatUnit? Get(this ChatUnitManageComponent self, long unitId) +// { +// return self.Units.GetValueOrDefault(unitId); +// } +// +// public static bool TryGet(this ChatUnitManageComponent self, long unitId, out ChatUnit chatUnit) +// { +// return self.Units.TryGetValue(unitId, out chatUnit); +// } +// +// public static void Remove(this ChatUnitManageComponent self, long unitId, bool isDispose = true) +// { +// // 由于退出频道的时候,也会检查该玩家是否在ChatUnitManageComponent中,所以这里不做移除操作。 +// if (!self.Units.TryGetValue(unitId, out var chatUnit)) +// { +// return; +// } +// +// if (isDispose) +// { +// chatUnit.Dispose(); +// } +// +// // 因为玩家已经执行了退出频道的操作了,所以要清除一下这个数据。 +// self.Units.Remove(unitId); +// Log.Debug($"Remove ChatUnit: {chatUnit.UserName}({chatUnit.GateRouteId}) Count: {self.Units.Count}"); +// } +// } \ No newline at end of file diff --git a/Hotfix/Social/Chat/System/ChatUnitSystem.cs b/Hotfix/Social/Chat/System/ChatUnitSystem.cs deleted file mode 100644 index 8c5199c..0000000 --- a/Hotfix/Social/Chat/System/ChatUnitSystem.cs +++ /dev/null @@ -1,11 +0,0 @@ -using Fantasy.Entitas.Interface; - -namespace NB.Chat; - -public class ChatUnitSystem : AwakeSystem -{ - protected override void Awake(SocialUnit self) - { - - } -} \ No newline at end of file diff --git a/Hotfix/Social/Mail/Handler/C2S_SendMailRequestHandler.cs b/Hotfix/Social/Mail/Handler/C2S_SendMailRequestHandler.cs index e4fc56b..2156055 100644 --- a/Hotfix/Social/Mail/Handler/C2S_SendMailRequestHandler.cs +++ b/Hotfix/Social/Mail/Handler/C2S_SendMailRequestHandler.cs @@ -58,12 +58,12 @@ public class C2S_SendMailRequestHandler : AddressRPC +{ + protected override void Destroy(SocialUnitManageComponent self) + { + foreach (var chatUnit in self.Units.Values.ToArray()) + { + chatUnit.Dispose(); + } + + self.Units.Clear(); + } +} + +public static class SocialUnitManageComponentSystem +{ + #region 消息缓存 + + /// + /// 离线消息,进入待领取队列 + /// + /// + /// + /// + public static void SaveOfflineMessage(this SocialUnitManageComponent self, long targetId, ChatMessageInfo message) + { + // self.NotSendMessage.Add(targetId, message); + } + + #endregion + + #region 上线下线 + + /// + /// 玩家上线 + /// + /// + /// + /// + /// + public static async FTask Online(this SocialUnitManageComponent self, Scene scene, + long accountId, + long gateRouteId) + { + // var accountId = roleSimpleInfo.RoleId; + if (!self.TryGet(accountId, out var account)) + { + account = Entity.Create(scene, accountId, true, true); + self.Add(account); + } + + if (account != null) + { + await account.TryComponent(); + account.GateRouteId = gateRouteId; + // account.Role = roleSimpleInfo; + } + + await FTask.CompletedTask; + return account; + } + + public static async FTask Offline(this SocialUnitManageComponent self, Scene scene, long accountId, + long gateRouteId) + { + if (self.TryGet(accountId, out var unit) && unit != null) + { + if (unit.GateRouteId == gateRouteId) + { + Log.Info("退出当前聊天服=="); + self.Remove(accountId); //如果当前网关和下线的网关一致 + } + } + + await FTask.CompletedTask; + } + + #endregion + + #region 获取&移除 + + public static void Add(this SocialUnitManageComponent self, SocialUnit account) + { + self.Units.Add(account.Id, account); + } + + public static SocialUnit? Get(this SocialUnitManageComponent self, long accountId) + { + return self.Units.GetValueOrDefault(accountId); + } + + public static bool TryGet(this SocialUnitManageComponent self, long accountId, out SocialUnit? account) + { + return self.Units.TryGetValue(accountId, out account); + } + + public static void Remove(this SocialUnitManageComponent self, long accountId, bool isDispose = true) + { + if (!self.Units.Remove(accountId, out var account)) + { + return; + } + + if (!isDispose) + { + return; + } + + account.Dispose(); + } + + #endregion + + #region 组件 + + /// + /// 尝试给增加相关组件 + /// + /// + /// + public static async FTask TryComponent(this SocialUnit socialUnit) where T : Entity, new() + { + if (socialUnit.GetComponent() == null) + { + var mailComponent = await socialUnit.Scene.World.Database.Query(socialUnit.Id, true); + if (mailComponent == null) + { + //如果没有邮件组件 + socialUnit.AddComponent(); + } + else + { + socialUnit.AddComponent(mailComponent); + } + } + } + + #endregion +} \ No newline at end of file diff --git a/Hotfix/Social/SocialUnitSystem.cs b/Hotfix/Social/SocialUnitSystem.cs new file mode 100644 index 0000000..2e564dd --- /dev/null +++ b/Hotfix/Social/SocialUnitSystem.cs @@ -0,0 +1,22 @@ +using Fantasy.Entitas.Interface; +#pragma warning disable CS8625 // Cannot convert null literal to non-nullable reference type. + +namespace NB.Chat; + +public sealed class SocialUnitDestroySystem : DestroySystem +{ + protected override void Destroy(SocialUnit self) + { + self.Role.Return(); + self.Role = null; + self.GateRouteId = 0; + // 退出当前ChatUnit拥有的所有频道 + foreach (var (_,chatChannelComponent) in self.Channels) + { + chatChannelComponent.ExitChannel(self.Id, false); + } + // 理论情况下,这个self.Channels不会存在因为数据的,因为上面已经给清空掉了。 + // 但是self.Channels.Clear();还是加上吧,防止以后忘记了。 + self.Channels.Clear(); + } +} \ No newline at end of file diff --git a/Main/Main.csproj b/Main/Main.csproj index 062c0e0..5290c58 100644 --- a/Main/Main.csproj +++ b/Main/Main.csproj @@ -24,5 +24,47 @@ Always + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + \ No newline at end of file diff --git a/Main/Program.cs b/Main/Program.cs index 4fffad9..9bf0c97 100644 --- a/Main/Program.cs +++ b/Main/Program.cs @@ -11,6 +11,7 @@ using System; using Fantasy; +using NBF; using NBF.ConfigTable; try @@ -20,7 +21,8 @@ try // 通过访问 AssemblyMarker 强制加载程序集并调用 ModuleInitializer // 注意:Native AOT 不存在延迟加载问题,所有程序集在编译时打包 AssemblyHelper.Initialize(); - ConfigTableHelper.Initialize(); + // ConfigTableHelper.Initialize(); + Configs.Initialize(); // 配置 NLog 日志基础设施 var logger = new Fantasy.NLog("Server"); // 使用 NLog 日志系统启动 Fantasy.Net 框架 diff --git a/Main/cfg/tbbait.json b/Main/cfg/tbbait.json new file mode 100644 index 0000000..8e343ca --- /dev/null +++ b/Main/cfg/tbbait.json @@ -0,0 +1,39 @@ +[ + { + "id": 70001, + "efficacy_base": 15, + "arr": [ + 250, + 1, + 2, + 3 + ], + "strength": 0 + }, + { + "id": 70002, + "efficacy_base": 15, + "arr": [ + 120, + 4, + 3 + ], + "strength": 0 + }, + { + "id": 70003, + "efficacy_base": 15, + "arr": [ + 120 + ], + "strength": 0 + }, + { + "id": 70004, + "efficacy_base": 15, + "arr": [ + 120 + ], + "strength": 0 + } +] \ No newline at end of file diff --git a/Main/cfg/tbbasicconfig.json b/Main/cfg/tbbasicconfig.json new file mode 100644 index 0000000..464e8f9 --- /dev/null +++ b/Main/cfg/tbbasicconfig.json @@ -0,0 +1,16 @@ +[ + { + "x1": 1101001101, + "x2": 150, + "x3": 500, + "x4": 50, + "x5": 10, + "x6": 4, + "x7": [ + 1, + 2, + 3, + 4 + ] + } +] \ No newline at end of file diff --git a/Main/cfg/tbbobber.json b/Main/cfg/tbbobber.json new file mode 100644 index 0000000..f792b1f --- /dev/null +++ b/Main/cfg/tbbobber.json @@ -0,0 +1,30 @@ +[ + { + "id": 50001, + "displacement": 40, + "night_light": [ + 0 + ] + }, + { + "id": 50002, + "displacement": 40, + "night_light": [ + 0 + ] + }, + { + "id": 50003, + "displacement": 40, + "night_light": [ + 0 + ] + }, + { + "id": 50004, + "displacement": 40, + "night_light": [ + 0 + ] + } +] \ No newline at end of file diff --git a/Main/cfg/tbfeeder.json b/Main/cfg/tbfeeder.json new file mode 100644 index 0000000..f2106e9 --- /dev/null +++ b/Main/cfg/tbfeeder.json @@ -0,0 +1,7 @@ +[ + { + "id": 110001, + "capacity": 100, + "weight": 5 + } +] \ No newline at end of file diff --git a/Main/cfg/tbfish.json b/Main/cfg/tbfish.json new file mode 100644 index 0000000..737c9b0 --- /dev/null +++ b/Main/cfg/tbfish.json @@ -0,0 +1,30 @@ +[ + { + "id": 210001, + "name": "鲤鱼", + "min_weight": 1, + "max_weight": 34, + "accept": 2100001 + }, + { + "id": 210002, + "name": "金鲫", + "min_weight": 1, + "max_weight": 34, + "accept": 2100001 + }, + { + "id": 210003, + "name": "银鲫", + "min_weight": 1, + "max_weight": 34, + "accept": 2100001 + }, + { + "id": 210004, + "name": "拟鲤", + "min_weight": 1, + "max_weight": 34, + "accept": 2100001 + } +] \ No newline at end of file diff --git a/Main/cfg/tbgoods.json b/Main/cfg/tbgoods.json new file mode 100644 index 0000000..8e81d09 --- /dev/null +++ b/Main/cfg/tbgoods.json @@ -0,0 +1,1290 @@ +[ + { + "id": 3030001, + "group": 0, + "items": [ + 30001 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3030002, + "group": 0, + "items": [ + 30002 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3030003, + "group": 0, + "items": [ + 30003 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3030004, + "group": 0, + "items": [ + 30004 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3030005, + "group": 0, + "items": [ + 30005 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3030006, + "group": 0, + "items": [ + 30006 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3030007, + "group": 0, + "items": [ + 30007 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3030008, + "group": 0, + "items": [ + 30008 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3030009, + "group": 0, + "items": [ + 30009 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3030010, + "group": 0, + "items": [ + 30010 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3030011, + "group": 0, + "items": [ + 30011 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3040011, + "group": 0, + "items": [ + 40001 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3040012, + "group": 0, + "items": [ + 40002 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3040013, + "group": 0, + "items": [ + 40003 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3040014, + "group": 0, + "items": [ + 40004 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3040015, + "group": 0, + "items": [ + 40005 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3040016, + "group": 0, + "items": [ + 40006 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3040017, + "group": 0, + "items": [ + 40007 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3040018, + "group": 0, + "items": [ + 40008 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3040019, + "group": 0, + "items": [ + 40009 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3040020, + "group": 0, + "items": [ + 40010 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3050001, + "group": 0, + "items": [ + 50001 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3050002, + "group": 0, + "items": [ + 50002 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3050003, + "group": 0, + "items": [ + 50003 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3050004, + "group": 0, + "items": [ + 50004 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3050005, + "group": 0, + "items": [ + 50005 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3050006, + "group": 0, + "items": [ + 50006 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3050007, + "group": 0, + "items": [ + 50007 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3050008, + "group": 0, + "items": [ + 50008 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3050009, + "group": 0, + "items": [ + 50009 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3050010, + "group": 0, + "items": [ + 50010 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3050011, + "group": 0, + "items": [ + 50011 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3050012, + "group": 0, + "items": [ + 50012 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3050013, + "group": 0, + "items": [ + 50013 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3050014, + "group": 0, + "items": [ + 50014 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3060001, + "group": 0, + "items": [ + 60001 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3060002, + "group": 0, + "items": [ + 60002 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3060003, + "group": 0, + "items": [ + 60003 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3060004, + "group": 0, + "items": [ + 60004 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3060005, + "group": 0, + "items": [ + 60005 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3060006, + "group": 0, + "items": [ + 60006 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3060007, + "group": 0, + "items": [ + 60007 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3060008, + "group": 0, + "items": [ + 60008 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3060009, + "group": 0, + "items": [ + 60009 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3060010, + "group": 0, + "items": [ + 60010 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3070001, + "group": 0, + "items": [ + 70001 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3070002, + "group": 0, + "items": [ + 70002 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3070003, + "group": 0, + "items": [ + 70003 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3070004, + "group": 0, + "items": [ + 70004 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3080001, + "group": 0, + "items": [ + 80001 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3080002, + "group": 0, + "items": [ + 80002 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3080003, + "group": 0, + "items": [ + 80003 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3080004, + "group": 0, + "items": [ + 80004 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3080005, + "group": 0, + "items": [ + 80005 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3080006, + "group": 0, + "items": [ + 80006 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3080007, + "group": 0, + "items": [ + 80007 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3080008, + "group": 0, + "items": [ + 80008 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3080009, + "group": 0, + "items": [ + 80009 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3080010, + "group": 0, + "items": [ + 80010 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3080011, + "group": 0, + "items": [ + 80011 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3080012, + "group": 0, + "items": [ + 80012 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3080013, + "group": 0, + "items": [ + 80013 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3090001, + "group": 3090001, + "items": [ + 90001 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3090002, + "group": 3090001, + "items": [ + 90002 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3090003, + "group": 3090001, + "items": [ + 90003 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3090004, + "group": 3090001, + "items": [ + 90004 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3090005, + "group": 3090005, + "items": [ + 90005 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3090006, + "group": 3090005, + "items": [ + 90006 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3090007, + "group": 0, + "items": [ + 90007 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3090008, + "group": 0, + "items": [ + 90008 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3090009, + "group": 0, + "items": [ + 90009 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3090010, + "group": 0, + "items": [ + 90010 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3090011, + "group": 0, + "items": [ + 90011 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3090012, + "group": 0, + "items": [ + 90012 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3090013, + "group": 0, + "items": [ + 90013 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3090014, + "group": 0, + "items": [ + 90014 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3090015, + "group": 0, + "items": [ + 90015 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3090016, + "group": 0, + "items": [ + 90016 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3090017, + "group": 0, + "items": [ + 90017 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3090018, + "group": 0, + "items": [ + 90018 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3090019, + "group": 0, + "items": [ + 90019 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3090020, + "group": 0, + "items": [ + 90020 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3100001, + "group": 0, + "items": [ + 100001 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3100002, + "group": 0, + "items": [ + 100002 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3100003, + "group": 0, + "items": [ + 100003 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3100004, + "group": 0, + "items": [ + 100004 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3100005, + "group": 0, + "items": [ + 100005 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3100006, + "group": 0, + "items": [ + 100006 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3100007, + "group": 0, + "items": [ + 100007 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3100008, + "group": 0, + "items": [ + 100008 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3100009, + "group": 0, + "items": [ + 100009 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3100010, + "group": 0, + "items": [ + 100010 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + } +] \ No newline at end of file diff --git a/Main/cfg/tbhook.json b/Main/cfg/tbhook.json new file mode 100644 index 0000000..e6e07f1 --- /dev/null +++ b/Main/cfg/tbhook.json @@ -0,0 +1,22 @@ +[ + { + "id": 90001, + "ding": 1 + }, + { + "id": 90002, + "ding": 1 + }, + { + "id": 90003, + "ding": 1 + }, + { + "id": 90004, + "ding": 1 + }, + { + "id": 90005, + "ding": 1 + } +] \ No newline at end of file diff --git a/Main/cfg/tbinititemconfig.json b/Main/cfg/tbinititemconfig.json new file mode 100644 index 0000000..c01121e --- /dev/null +++ b/Main/cfg/tbinititemconfig.json @@ -0,0 +1,386 @@ +[ + { + "id": 10001, + "count": 100 + }, + { + "id": 10002, + "count": 200 + }, + { + "id": 10003, + "count": 0 + }, + { + "id": 30001, + "count": 1 + }, + { + "id": 30002, + "count": 1 + }, + { + "id": 30003, + "count": 1 + }, + { + "id": 30004, + "count": 1 + }, + { + "id": 30005, + "count": 1 + }, + { + "id": 30006, + "count": 1 + }, + { + "id": 30007, + "count": 1 + }, + { + "id": 30008, + "count": 1 + }, + { + "id": 30009, + "count": 1 + }, + { + "id": 30010, + "count": 1 + }, + { + "id": 30011, + "count": 1 + }, + { + "id": 40001, + "count": 1 + }, + { + "id": 40002, + "count": 1 + }, + { + "id": 40003, + "count": 1 + }, + { + "id": 40004, + "count": 1 + }, + { + "id": 40005, + "count": 1 + }, + { + "id": 40006, + "count": 1 + }, + { + "id": 40007, + "count": 1 + }, + { + "id": 40008, + "count": 1 + }, + { + "id": 40009, + "count": 1 + }, + { + "id": 40010, + "count": 1 + }, + { + "id": 50001, + "count": 1 + }, + { + "id": 50002, + "count": 1 + }, + { + "id": 50003, + "count": 1 + }, + { + "id": 50004, + "count": 1 + }, + { + "id": 50005, + "count": 1 + }, + { + "id": 50006, + "count": 1 + }, + { + "id": 50007, + "count": 1 + }, + { + "id": 50008, + "count": 1 + }, + { + "id": 50009, + "count": 1 + }, + { + "id": 50010, + "count": 1 + }, + { + "id": 50011, + "count": 1 + }, + { + "id": 50012, + "count": 1 + }, + { + "id": 50013, + "count": 1 + }, + { + "id": 50014, + "count": 1 + }, + { + "id": 60001, + "count": 1 + }, + { + "id": 60002, + "count": 1 + }, + { + "id": 60003, + "count": 1 + }, + { + "id": 60004, + "count": 1 + }, + { + "id": 60005, + "count": 1 + }, + { + "id": 60006, + "count": 1 + }, + { + "id": 60007, + "count": 1 + }, + { + "id": 60008, + "count": 1 + }, + { + "id": 60009, + "count": 1 + }, + { + "id": 60010, + "count": 1 + }, + { + "id": 70001, + "count": 1 + }, + { + "id": 70002, + "count": 1 + }, + { + "id": 70003, + "count": 1 + }, + { + "id": 70004, + "count": 1 + }, + { + "id": 80001, + "count": 1 + }, + { + "id": 80002, + "count": 1 + }, + { + "id": 80003, + "count": 1 + }, + { + "id": 80004, + "count": 1 + }, + { + "id": 80005, + "count": 1 + }, + { + "id": 80006, + "count": 1 + }, + { + "id": 80007, + "count": 1 + }, + { + "id": 80008, + "count": 1 + }, + { + "id": 80009, + "count": 1 + }, + { + "id": 80010, + "count": 1 + }, + { + "id": 80011, + "count": 1 + }, + { + "id": 80012, + "count": 1 + }, + { + "id": 80013, + "count": 1 + }, + { + "id": 90001, + "count": 1 + }, + { + "id": 90002, + "count": 1 + }, + { + "id": 90003, + "count": 1 + }, + { + "id": 90004, + "count": 1 + }, + { + "id": 90005, + "count": 1 + }, + { + "id": 90006, + "count": 1 + }, + { + "id": 90007, + "count": 1 + }, + { + "id": 90008, + "count": 1 + }, + { + "id": 90009, + "count": 1 + }, + { + "id": 90010, + "count": 1 + }, + { + "id": 90011, + "count": 1 + }, + { + "id": 90012, + "count": 1 + }, + { + "id": 90013, + "count": 1 + }, + { + "id": 90014, + "count": 1 + }, + { + "id": 90015, + "count": 1 + }, + { + "id": 90016, + "count": 1 + }, + { + "id": 90017, + "count": 1 + }, + { + "id": 90018, + "count": 1 + }, + { + "id": 90019, + "count": 1 + }, + { + "id": 90020, + "count": 1 + }, + { + "id": 100001, + "count": 1 + }, + { + "id": 100002, + "count": 1 + }, + { + "id": 100003, + "count": 1 + }, + { + "id": 100004, + "count": 1 + }, + { + "id": 100005, + "count": 1 + }, + { + "id": 100006, + "count": 1 + }, + { + "id": 100007, + "count": 1 + }, + { + "id": 100008, + "count": 1 + }, + { + "id": 100009, + "count": 1 + }, + { + "id": 100010, + "count": 1 + }, + { + "id": 110001, + "count": 1 + } +] \ No newline at end of file diff --git a/Main/cfg/tbitem.json b/Main/cfg/tbitem.json new file mode 100644 index 0000000..4f91c4e --- /dev/null +++ b/Main/cfg/tbitem.json @@ -0,0 +1,1118 @@ +[ + { + "id": 30001, + "type": 301, + "quality": 5, + "brand": 0, + "weight": 0, + "length": 0, + "max": 0, + "auto_use": 0, + "result1": [], + "result2": [] + }, + { + "id": 30002, + "type": 302, + "quality": 5, + "brand": 0, + "weight": 0, + "length": 0, + "max": 0, + "auto_use": 0, + "result1": [], + "result2": [] + }, + { + "id": 30003, + "type": 303, + "quality": 5, + "brand": 0, + "weight": 0, + "length": 0, + "max": 0, + "auto_use": 0, + "result1": [], + "result2": [] + }, + { + "id": 30004, + "type": 304, + "quality": 4, + "brand": 0, + "weight": 0, + "length": 0, + "max": 0, + "auto_use": 0, + "result1": [], + "result2": [] + }, + { + "id": 30005, + "type": 305, + "quality": 5, + "brand": 0, + "weight": 0, + "length": 0, + "max": 0, + "auto_use": 0, + "result1": [], + "result2": [] + }, + { + "id": 30006, + "type": 306, + "quality": 4, + "brand": 0, + "weight": 0, + "length": 0, + "max": 0, + "auto_use": 0, + "result1": [], + "result2": [] + }, + { + "id": 30007, + "type": 307, + "quality": 3, + "brand": 0, + "weight": 0, + "length": 0, + "max": 0, + "auto_use": 0, + "result1": [], + "result2": [] + }, + { + "id": 30008, + "type": 308, + "quality": 3, + "brand": 0, + "weight": 0, + "length": 0, + "max": 0, + "auto_use": 0, + "result1": [], + "result2": [] + }, + { + "id": 30009, + "type": 309, + "quality": 4, + "brand": 0, + "weight": 0, + "length": 0, + "max": 0, + "auto_use": 0, + "result1": [], + "result2": [] + }, + { + "id": 30010, + "type": 310, + "quality": 5, + "brand": 0, + "weight": 0, + "length": 0, + "max": 0, + "auto_use": 0, + "result1": [], + "result2": [] + }, + { + "id": 30011, + "type": 311, + "quality": 4, + "brand": 0, + "weight": 0, + "length": 0, + "max": 0, + "auto_use": 0, + "result1": [], + "result2": [] + }, + { + "id": 40001, + "type": 401, + "quality": 3, + "brand": 0, + "weight": 0, + "length": 0, + "max": 0, + "auto_use": 0, + "result1": [], + "result2": [] + }, + { + "id": 40002, + "type": 401, + "quality": 4, + "brand": 0, + "weight": 0, + "length": 0, + "max": 0, + "auto_use": 0, + "result1": [], + "result2": [] + }, + { + "id": 40003, + "type": 402, + "quality": 1, + "brand": 0, + "weight": 0, + "length": 0, + "max": 0, + "auto_use": 0, + "result1": [], + "result2": [] + }, + { + "id": 40004, + "type": 402, + "quality": 1, + "brand": 0, + "weight": 0, + "length": 0, + "max": 0, + "auto_use": 0, + "result1": [], + "result2": [] + }, + { + "id": 40005, + "type": 403, + "quality": 1, + "brand": 0, + "weight": 0, + "length": 0, + "max": 0, + "auto_use": 0, + "result1": [], + "result2": [] + }, + { + "id": 40006, + "type": 403, + "quality": 1, + "brand": 0, + "weight": 0, + "length": 0, + "max": 0, + "auto_use": 0, + "result1": [], + "result2": [] + }, + { + "id": 40007, + "type": 401, + "quality": 1, + "brand": 0, + "weight": 0, + "length": 0, + "max": 0, + "auto_use": 0, + "result1": [], + "result2": [] + }, + { + "id": 40008, + "type": 401, + "quality": 1, + "brand": 0, + "weight": 0, + "length": 0, + "max": 0, + "auto_use": 0, + "result1": [], + "result2": [] + }, + { + "id": 40009, + "type": 403, + "quality": 1, + "brand": 0, + "weight": 0, + "length": 0, + "max": 0, + "auto_use": 0, + "result1": [], + "result2": [] + }, + { + "id": 40010, + "type": 403, + "quality": 1, + "brand": 0, + "weight": 0, + "length": 0, + "max": 0, + "auto_use": 0, + "result1": [], + "result2": [] + }, + { + "id": 50001, + "type": 501, + "quality": 1, + "brand": 1, + "weight": 0, + "length": 0, + "max": 0, + "auto_use": 0, + "result1": [], + "result2": [] + }, + { + "id": 50002, + "type": 501, + "quality": 2, + "brand": 0, + "weight": 0, + "length": 0, + "max": 0, + "auto_use": 0, + "result1": [], + "result2": [] + }, + { + "id": 50003, + "type": 501, + "quality": 3, + "brand": 0, + "weight": 0, + "length": 0, + "max": 0, + "auto_use": 0, + "result1": [], + "result2": [] + }, + { + "id": 50004, + "type": 501, + "quality": 4, + "brand": 0, + "weight": 0, + "length": 0, + "max": 0, + "auto_use": 0, + "result1": [], + "result2": [] + }, + { + "id": 50005, + "type": 501, + "quality": 1, + "brand": 0, + "weight": 0, + "length": 0, + "max": 0, + "auto_use": 0, + "result1": [], + "result2": [] + }, + { + "id": 50006, + "type": 501, + "quality": 1, + "brand": 0, + "weight": 0, + "length": 0, + "max": 0, + "auto_use": 0, + "result1": [], + "result2": [] + }, + { + "id": 50007, + "type": 501, + "quality": 1, + "brand": 0, + "weight": 0, + "length": 0, + "max": 0, + "auto_use": 0, + "result1": [], + "result2": [] + }, + { + "id": 50008, + "type": 501, + "quality": 1, + "brand": 0, + "weight": 0, + "length": 0, + "max": 0, + "auto_use": 0, + "result1": [], + "result2": [] + }, + { + "id": 50009, + "type": 501, + "quality": 1, + "brand": 0, + "weight": 0, + "length": 0, + "max": 0, + "auto_use": 0, + "result1": [], + "result2": [] + }, + { + "id": 50010, + "type": 501, + "quality": 1, + "brand": 0, + "weight": 0, + "length": 0, + "max": 0, + "auto_use": 0, + "result1": [], + "result2": [] + }, + { + "id": 50011, + "type": 501, + "quality": 1, + "brand": 0, + "weight": 0, + "length": 0, + "max": 0, + "auto_use": 0, + "result1": [], + "result2": [] + }, + { + "id": 50012, + "type": 501, + "quality": 1, + "brand": 0, + "weight": 0, + "length": 0, + "max": 0, + "auto_use": 0, + "result1": [], + "result2": [] + }, + { + "id": 50013, + "type": 501, + "quality": 1, + "brand": 0, + "weight": 0, + "length": 0, + "max": 0, + "auto_use": 0, + "result1": [], + "result2": [] + }, + { + "id": 50014, + "type": 501, + "quality": 1, + "brand": 0, + "weight": 0, + "length": 0, + "max": 0, + "auto_use": 0, + "result1": [], + "result2": [] + }, + { + "id": 60001, + "type": 601, + "quality": 1, + "brand": 0, + "weight": 0, + "length": 0, + "max": 0, + "auto_use": 0, + "result1": [], + "result2": [] + }, + { + "id": 60002, + "type": 601, + "quality": 1, + "brand": 0, + "weight": 0, + "length": 0, + "max": 0, + "auto_use": 0, + "result1": [], + "result2": [] + }, + { + "id": 60003, + "type": 601, + "quality": 1, + "brand": 0, + "weight": 0, + "length": 0, + "max": 0, + "auto_use": 0, + "result1": [], + "result2": [] + }, + { + "id": 60004, + "type": 601, + "quality": 1, + "brand": 0, + "weight": 0, + "length": 0, + "max": 0, + "auto_use": 0, + "result1": [], + "result2": [] + }, + { + "id": 60005, + "type": 601, + "quality": 1, + "brand": 0, + "weight": 0, + "length": 0, + "max": 0, + "auto_use": 0, + "result1": [], + "result2": [] + }, + { + "id": 60006, + "type": 601, + "quality": 1, + "brand": 0, + "weight": 0, + "length": 0, + "max": 0, + "auto_use": 0, + "result1": [], + "result2": [] + }, + { + "id": 60007, + "type": 601, + "quality": 1, + "brand": 0, + "weight": 0, + "length": 0, + "max": 0, + "auto_use": 0, + "result1": [], + "result2": [] + }, + { + "id": 60008, + "type": 601, + "quality": 1, + "brand": 0, + "weight": 0, + "length": 0, + "max": 0, + "auto_use": 0, + "result1": [], + "result2": [] + }, + { + "id": 60009, + "type": 601, + "quality": 1, + "brand": 0, + "weight": 0, + "length": 0, + "max": 0, + "auto_use": 0, + "result1": [], + "result2": [] + }, + { + "id": 60010, + "type": 601, + "quality": 1, + "brand": 0, + "weight": 0, + "length": 0, + "max": 0, + "auto_use": 0, + "result1": [], + "result2": [] + }, + { + "id": 70001, + "type": 701, + "quality": 1, + "brand": 0, + "weight": 0, + "length": 0, + "max": 0, + "auto_use": 0, + "result1": [], + "result2": [] + }, + { + "id": 70002, + "type": 701, + "quality": 2, + "brand": 0, + "weight": 0, + "length": 0, + "max": 0, + "auto_use": 0, + "result1": [], + "result2": [] + }, + { + "id": 70003, + "type": 701, + "quality": 2, + "brand": 0, + "weight": 0, + "length": 0, + "max": 0, + "auto_use": 0, + "result1": [], + "result2": [] + }, + { + "id": 70004, + "type": 701, + "quality": 3, + "brand": 0, + "weight": 0, + "length": 0, + "max": 0, + "auto_use": 0, + "result1": [], + "result2": [] + }, + { + "id": 80001, + "type": 801, + "quality": 1, + "brand": 0, + "weight": 0, + "length": 0, + "max": 0, + "auto_use": 0, + "result1": [], + "result2": [] + }, + { + "id": 80002, + "type": 801, + "quality": 2, + "brand": 0, + "weight": 0, + "length": 0, + "max": 0, + "auto_use": 0, + "result1": [], + "result2": [] + }, + { + "id": 80003, + "type": 801, + "quality": 3, + "brand": 0, + "weight": 0, + "length": 0, + "max": 0, + "auto_use": 0, + "result1": [], + "result2": [] + }, + { + "id": 80004, + "type": 801, + "quality": 4, + "brand": 0, + "weight": 0, + "length": 0, + "max": 0, + "auto_use": 0, + "result1": [], + "result2": [] + }, + { + "id": 80005, + "type": 801, + "quality": 1, + "brand": 0, + "weight": 0, + "length": 0, + "max": 0, + "auto_use": 0, + "result1": [], + "result2": [] + }, + { + "id": 80006, + "type": 801, + "quality": 1, + "brand": 0, + "weight": 0, + "length": 0, + "max": 0, + "auto_use": 0, + "result1": [], + "result2": [] + }, + { + "id": 80007, + "type": 801, + "quality": 1, + "brand": 0, + "weight": 0, + "length": 0, + "max": 0, + "auto_use": 0, + "result1": [], + "result2": [] + }, + { + "id": 80008, + "type": 801, + "quality": 1, + "brand": 0, + "weight": 0, + "length": 0, + "max": 0, + "auto_use": 0, + "result1": [], + "result2": [] + }, + { + "id": 80009, + "type": 801, + "quality": 1, + "brand": 0, + "weight": 0, + "length": 0, + "max": 0, + "auto_use": 0, + "result1": [], + "result2": [] + }, + { + "id": 80010, + "type": 801, + "quality": 1, + "brand": 0, + "weight": 0, + "length": 0, + "max": 0, + "auto_use": 0, + "result1": [], + "result2": [] + }, + { + "id": 80011, + "type": 801, + "quality": 1, + "brand": 0, + "weight": 0, + "length": 0, + "max": 0, + "auto_use": 0, + "result1": [], + "result2": [] + }, + { + "id": 80012, + "type": 801, + "quality": 1, + "brand": 0, + "weight": 0, + "length": 0, + "max": 0, + "auto_use": 0, + "result1": [], + "result2": [] + }, + { + "id": 80013, + "type": 801, + "quality": 1, + "brand": 0, + "weight": 0, + "length": 0, + "max": 0, + "auto_use": 0, + "result1": [], + "result2": [] + }, + { + "id": 90001, + "type": 901, + "quality": 1, + "brand": 0, + "weight": 0, + "length": 0, + "max": 0, + "auto_use": 0, + "result1": [], + "result2": [] + }, + { + "id": 90002, + "type": 901, + "quality": 1, + "brand": 0, + "weight": 0, + "length": 0, + "max": 0, + "auto_use": 0, + "result1": [], + "result2": [] + }, + { + "id": 90003, + "type": 901, + "quality": 1, + "brand": 0, + "weight": 0, + "length": 0, + "max": 0, + "auto_use": 0, + "result1": [], + "result2": [] + }, + { + "id": 90004, + "type": 901, + "quality": 1, + "brand": 0, + "weight": 0, + "length": 0, + "max": 0, + "auto_use": 0, + "result1": [], + "result2": [] + }, + { + "id": 90005, + "type": 901, + "quality": 1, + "brand": 0, + "weight": 0, + "length": 0, + "max": 0, + "auto_use": 0, + "result1": [], + "result2": [] + }, + { + "id": 90006, + "type": 901, + "quality": 1, + "brand": 0, + "weight": 0, + "length": 0, + "max": 0, + "auto_use": 0, + "result1": [], + "result2": [] + }, + { + "id": 90007, + "type": 901, + "quality": 1, + "brand": 0, + "weight": 0, + "length": 0, + "max": 0, + "auto_use": 0, + "result1": [], + "result2": [] + }, + { + "id": 90008, + "type": 901, + "quality": 1, + "brand": 0, + "weight": 0, + "length": 0, + "max": 0, + "auto_use": 0, + "result1": [], + "result2": [] + }, + { + "id": 90009, + "type": 901, + "quality": 1, + "brand": 0, + "weight": 0, + "length": 0, + "max": 0, + "auto_use": 0, + "result1": [], + "result2": [] + }, + { + "id": 90010, + "type": 901, + "quality": 1, + "brand": 0, + "weight": 0, + "length": 0, + "max": 0, + "auto_use": 0, + "result1": [], + "result2": [] + }, + { + "id": 90011, + "type": 901, + "quality": 1, + "brand": 0, + "weight": 0, + "length": 0, + "max": 0, + "auto_use": 0, + "result1": [], + "result2": [] + }, + { + "id": 90012, + "type": 901, + "quality": 1, + "brand": 0, + "weight": 0, + "length": 0, + "max": 0, + "auto_use": 0, + "result1": [], + "result2": [] + }, + { + "id": 90013, + "type": 901, + "quality": 1, + "brand": 0, + "weight": 0, + "length": 0, + "max": 0, + "auto_use": 0, + "result1": [], + "result2": [] + }, + { + "id": 90014, + "type": 901, + "quality": 1, + "brand": 0, + "weight": 0, + "length": 0, + "max": 0, + "auto_use": 0, + "result1": [], + "result2": [] + }, + { + "id": 90015, + "type": 901, + "quality": 1, + "brand": 0, + "weight": 0, + "length": 0, + "max": 0, + "auto_use": 0, + "result1": [], + "result2": [] + }, + { + "id": 90016, + "type": 901, + "quality": 1, + "brand": 0, + "weight": 0, + "length": 0, + "max": 0, + "auto_use": 0, + "result1": [], + "result2": [] + }, + { + "id": 90017, + "type": 901, + "quality": 1, + "brand": 0, + "weight": 0, + "length": 0, + "max": 0, + "auto_use": 0, + "result1": [], + "result2": [] + }, + { + "id": 90018, + "type": 901, + "quality": 1, + "brand": 0, + "weight": 0, + "length": 0, + "max": 0, + "auto_use": 0, + "result1": [], + "result2": [] + }, + { + "id": 90019, + "type": 901, + "quality": 1, + "brand": 0, + "weight": 0, + "length": 0, + "max": 0, + "auto_use": 0, + "result1": [], + "result2": [] + }, + { + "id": 90020, + "type": 901, + "quality": 1, + "brand": 0, + "weight": 0, + "length": 0, + "max": 0, + "auto_use": 0, + "result1": [], + "result2": [] + }, + { + "id": 100001, + "type": 1001, + "quality": 1, + "brand": 0, + "weight": 0, + "length": 0, + "max": 0, + "auto_use": 0, + "result1": [], + "result2": [] + }, + { + "id": 100002, + "type": 1001, + "quality": 1, + "brand": 0, + "weight": 0, + "length": 0, + "max": 0, + "auto_use": 0, + "result1": [], + "result2": [] + }, + { + "id": 100003, + "type": 1001, + "quality": 1, + "brand": 0, + "weight": 0, + "length": 0, + "max": 0, + "auto_use": 0, + "result1": [], + "result2": [] + }, + { + "id": 100004, + "type": 1001, + "quality": 1, + "brand": 0, + "weight": 0, + "length": 0, + "max": 0, + "auto_use": 0, + "result1": [], + "result2": [] + }, + { + "id": 100005, + "type": 1001, + "quality": 1, + "brand": 0, + "weight": 0, + "length": 0, + "max": 0, + "auto_use": 0, + "result1": [], + "result2": [] + }, + { + "id": 100006, + "type": 1001, + "quality": 1, + "brand": 0, + "weight": 0, + "length": 0, + "max": 0, + "auto_use": 0, + "result1": [], + "result2": [] + }, + { + "id": 100007, + "type": 1001, + "quality": 1, + "brand": 0, + "weight": 0, + "length": 0, + "max": 0, + "auto_use": 0, + "result1": [], + "result2": [] + }, + { + "id": 100008, + "type": 1001, + "quality": 1, + "brand": 0, + "weight": 0, + "length": 0, + "max": 0, + "auto_use": 0, + "result1": [], + "result2": [] + }, + { + "id": 100009, + "type": 1001, + "quality": 1, + "brand": 0, + "weight": 0, + "length": 0, + "max": 0, + "auto_use": 0, + "result1": [], + "result2": [] + }, + { + "id": 100010, + "type": 1001, + "quality": 1, + "brand": 0, + "weight": 0, + "length": 0, + "max": 0, + "auto_use": 0, + "result1": [], + "result2": [] + }, + { + "id": 110001, + "type": 1101, + "quality": 1, + "brand": 0, + "weight": 0, + "length": 0, + "max": 0, + "auto_use": 0, + "result1": [], + "result2": [] + } +] \ No newline at end of file diff --git a/Main/cfg/tbline.json b/Main/cfg/tbline.json new file mode 100644 index 0000000..8b604fe --- /dev/null +++ b/Main/cfg/tbline.json @@ -0,0 +1,12 @@ +[ + { + "id": 60001, + "strength": 40, + "size": 1 + }, + { + "id": 60002, + "strength": 40, + "size": 1 + } +] \ No newline at end of file diff --git a/Main/cfg/tblure.json b/Main/cfg/tblure.json new file mode 100644 index 0000000..74db0f8 --- /dev/null +++ b/Main/cfg/tblure.json @@ -0,0 +1,34 @@ +[ + { + "id": 80001, + "hook": [ + 700102 + ], + "hook_num": 1, + "efficacy_base": 50 + }, + { + "id": 80002, + "hook": [ + 700102 + ], + "hook_num": 1, + "efficacy_base": 50 + }, + { + "id": 80003, + "hook": [ + 0 + ], + "hook_num": 1, + "efficacy_base": 50 + }, + { + "id": 80004, + "hook": [ + 0 + ], + "hook_num": 1, + "efficacy_base": 50 + } +] \ No newline at end of file diff --git a/Main/cfg/tbreel.json b/Main/cfg/tbreel.json new file mode 100644 index 0000000..08c7c12 --- /dev/null +++ b/Main/cfg/tbreel.json @@ -0,0 +1,66 @@ +[ + { + "id": 40001, + "reel_type": 1, + "gear_ratio": [ + 7 + ], + "strength": 40 + }, + { + "id": 40002, + "reel_type": 1, + "gear_ratio": [ + 5 + ], + "strength": 40 + }, + { + "id": 40003, + "reel_type": 2, + "gear_ratio": [], + "strength": 0 + }, + { + "id": 40004, + "reel_type": 2, + "gear_ratio": [], + "strength": 0 + }, + { + "id": 40005, + "reel_type": 3, + "gear_ratio": [], + "strength": 0 + }, + { + "id": 40006, + "reel_type": 3, + "gear_ratio": [], + "strength": 0 + }, + { + "id": 40007, + "reel_type": 1, + "gear_ratio": [], + "strength": 0 + }, + { + "id": 40008, + "reel_type": 1, + "gear_ratio": [], + "strength": 0 + }, + { + "id": 40009, + "reel_type": 3, + "gear_ratio": [], + "strength": 0 + }, + { + "id": 40010, + "reel_type": 3, + "gear_ratio": [], + "strength": 0 + } +] \ No newline at end of file diff --git a/Main/cfg/tbrod.json b/Main/cfg/tbrod.json new file mode 100644 index 0000000..c82a668 --- /dev/null +++ b/Main/cfg/tbrod.json @@ -0,0 +1,90 @@ +[ + { + "id": 30001, + "rod_type": 1, + "ring": 0, + "strength": 40, + "max_range": 67, + "construction_type": 0 + }, + { + "id": 30002, + "rod_type": 3, + "ring": 2, + "strength": 40, + "max_range": 30, + "construction_type": 0 + }, + { + "id": 30003, + "rod_type": 2, + "ring": 1, + "strength": 40, + "max_range": 30, + "construction_type": 0 + }, + { + "id": 30004, + "rod_type": 1, + "ring": 1, + "strength": 40, + "max_range": 30, + "construction_type": 0 + }, + { + "id": 30005, + "rod_type": 2, + "ring": 1, + "strength": 40, + "max_range": 30, + "construction_type": 0 + }, + { + "id": 30006, + "rod_type": 2, + "ring": 1, + "strength": 40, + "max_range": 30, + "construction_type": 0 + }, + { + "id": 30007, + "rod_type": 2, + "ring": 1, + "strength": 40, + "max_range": 30, + "construction_type": 0 + }, + { + "id": 30008, + "rod_type": 2, + "ring": 1, + "strength": 40, + "max_range": 30, + "construction_type": 0 + }, + { + "id": 30009, + "rod_type": 2, + "ring": 1, + "strength": 40, + "max_range": 30, + "construction_type": 0 + }, + { + "id": 30010, + "rod_type": 2, + "ring": 1, + "strength": 40, + "max_range": 30, + "construction_type": 0 + }, + { + "id": 30011, + "rod_type": 2, + "ring": 1, + "strength": 40, + "max_range": 30, + "construction_type": 0 + } +] \ No newline at end of file diff --git a/Main/cfg/tbshop.json b/Main/cfg/tbshop.json new file mode 100644 index 0000000..8e81d09 --- /dev/null +++ b/Main/cfg/tbshop.json @@ -0,0 +1,1290 @@ +[ + { + "id": 3030001, + "group": 0, + "items": [ + 30001 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3030002, + "group": 0, + "items": [ + 30002 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3030003, + "group": 0, + "items": [ + 30003 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3030004, + "group": 0, + "items": [ + 30004 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3030005, + "group": 0, + "items": [ + 30005 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3030006, + "group": 0, + "items": [ + 30006 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3030007, + "group": 0, + "items": [ + 30007 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3030008, + "group": 0, + "items": [ + 30008 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3030009, + "group": 0, + "items": [ + 30009 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3030010, + "group": 0, + "items": [ + 30010 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3030011, + "group": 0, + "items": [ + 30011 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3040011, + "group": 0, + "items": [ + 40001 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3040012, + "group": 0, + "items": [ + 40002 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3040013, + "group": 0, + "items": [ + 40003 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3040014, + "group": 0, + "items": [ + 40004 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3040015, + "group": 0, + "items": [ + 40005 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3040016, + "group": 0, + "items": [ + 40006 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3040017, + "group": 0, + "items": [ + 40007 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3040018, + "group": 0, + "items": [ + 40008 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3040019, + "group": 0, + "items": [ + 40009 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3040020, + "group": 0, + "items": [ + 40010 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3050001, + "group": 0, + "items": [ + 50001 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3050002, + "group": 0, + "items": [ + 50002 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3050003, + "group": 0, + "items": [ + 50003 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3050004, + "group": 0, + "items": [ + 50004 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3050005, + "group": 0, + "items": [ + 50005 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3050006, + "group": 0, + "items": [ + 50006 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3050007, + "group": 0, + "items": [ + 50007 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3050008, + "group": 0, + "items": [ + 50008 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3050009, + "group": 0, + "items": [ + 50009 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3050010, + "group": 0, + "items": [ + 50010 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3050011, + "group": 0, + "items": [ + 50011 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3050012, + "group": 0, + "items": [ + 50012 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3050013, + "group": 0, + "items": [ + 50013 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3050014, + "group": 0, + "items": [ + 50014 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3060001, + "group": 0, + "items": [ + 60001 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3060002, + "group": 0, + "items": [ + 60002 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3060003, + "group": 0, + "items": [ + 60003 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3060004, + "group": 0, + "items": [ + 60004 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3060005, + "group": 0, + "items": [ + 60005 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3060006, + "group": 0, + "items": [ + 60006 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3060007, + "group": 0, + "items": [ + 60007 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3060008, + "group": 0, + "items": [ + 60008 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3060009, + "group": 0, + "items": [ + 60009 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3060010, + "group": 0, + "items": [ + 60010 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3070001, + "group": 0, + "items": [ + 70001 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3070002, + "group": 0, + "items": [ + 70002 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3070003, + "group": 0, + "items": [ + 70003 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3070004, + "group": 0, + "items": [ + 70004 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3080001, + "group": 0, + "items": [ + 80001 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3080002, + "group": 0, + "items": [ + 80002 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3080003, + "group": 0, + "items": [ + 80003 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3080004, + "group": 0, + "items": [ + 80004 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3080005, + "group": 0, + "items": [ + 80005 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3080006, + "group": 0, + "items": [ + 80006 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3080007, + "group": 0, + "items": [ + 80007 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3080008, + "group": 0, + "items": [ + 80008 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3080009, + "group": 0, + "items": [ + 80009 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3080010, + "group": 0, + "items": [ + 80010 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3080011, + "group": 0, + "items": [ + 80011 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3080012, + "group": 0, + "items": [ + 80012 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3080013, + "group": 0, + "items": [ + 80013 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3090001, + "group": 3090001, + "items": [ + 90001 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3090002, + "group": 3090001, + "items": [ + 90002 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3090003, + "group": 3090001, + "items": [ + 90003 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3090004, + "group": 3090001, + "items": [ + 90004 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3090005, + "group": 3090005, + "items": [ + 90005 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3090006, + "group": 3090005, + "items": [ + 90006 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3090007, + "group": 0, + "items": [ + 90007 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3090008, + "group": 0, + "items": [ + 90008 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3090009, + "group": 0, + "items": [ + 90009 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3090010, + "group": 0, + "items": [ + 90010 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3090011, + "group": 0, + "items": [ + 90011 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3090012, + "group": 0, + "items": [ + 90012 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3090013, + "group": 0, + "items": [ + 90013 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3090014, + "group": 0, + "items": [ + 90014 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3090015, + "group": 0, + "items": [ + 90015 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3090016, + "group": 0, + "items": [ + 90016 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3090017, + "group": 0, + "items": [ + 90017 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3090018, + "group": 0, + "items": [ + 90018 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3090019, + "group": 0, + "items": [ + 90019 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3090020, + "group": 0, + "items": [ + 90020 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3100001, + "group": 0, + "items": [ + 100001 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3100002, + "group": 0, + "items": [ + 100002 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3100003, + "group": 0, + "items": [ + 100003 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3100004, + "group": 0, + "items": [ + 100004 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3100005, + "group": 0, + "items": [ + 100005 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3100006, + "group": 0, + "items": [ + 100006 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3100007, + "group": 0, + "items": [ + 100007 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3100008, + "group": 0, + "items": [ + 100008 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3100009, + "group": 0, + "items": [ + 100009 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + }, + { + "id": 3100010, + "group": 0, + "items": [ + 100010 + ], + "price1": 2, + "price2": 1, + "label": [ + 0 + ], + "number": 0, + "disable": 0 + } +] \ No newline at end of file diff --git a/ThirdParty/Luban/BeanBase.cs b/ThirdParty/Luban/BeanBase.cs new file mode 100644 index 0000000..06d6021 --- /dev/null +++ b/ThirdParty/Luban/BeanBase.cs @@ -0,0 +1,28 @@ +// Copyright 2025 Code Philosophy +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + + +namespace Luban +{ + public abstract class BeanBase + { + public abstract int GetTypeId(); + } +} diff --git a/ThirdParty/Luban/ByteBuf.cs b/ThirdParty/Luban/ByteBuf.cs new file mode 100644 index 0000000..32557ad --- /dev/null +++ b/ThirdParty/Luban/ByteBuf.cs @@ -0,0 +1,1588 @@ +// Copyright 2025 Code Philosophy +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System; +using System.Diagnostics.CodeAnalysis; +using System.Numerics; +using System.Runtime.CompilerServices; +using System.Text; + +namespace Luban +{ + + public enum EDeserializeError + { + OK, + NOT_ENOUGH, + EXCEED_SIZE, + // UNMARSHAL_ERR, + } + + public class SerializationException : Exception + { + public SerializationException() { } + public SerializationException(string msg) : base(msg) { } + + public SerializationException(string message, Exception innerException) : base(message, innerException) + { + } + } + + public readonly struct SegmentSaveState + { + public SegmentSaveState(int readerIndex, int writerIndex) + { + ReaderIndex = readerIndex; + WriterIndex = writerIndex; + } + + public int ReaderIndex { get; } + + public int WriterIndex { get; } + } + + public sealed class ByteBuf : ICloneable, IEquatable + { + public ByteBuf() + { + Bytes = Array.Empty(); + ReaderIndex = WriterIndex = 0; + } + + public ByteBuf(int capacity) + { + Bytes = capacity > 0 ? new byte[capacity] : Array.Empty(); + ReaderIndex = 0; + WriterIndex = 0; + } + + public ByteBuf(byte[] bytes) + { + Bytes = bytes; + ReaderIndex = 0; + WriterIndex = Capacity; + } + + public ByteBuf(byte[] bytes, int readIndex, int writeIndex) + { + Bytes = bytes; + ReaderIndex = readIndex; + WriterIndex = writeIndex; + } + + public ByteBuf(int capacity, Action releaser) : this(capacity) + { + _releaser = releaser; + } + + public static ByteBuf Wrap(byte[] bytes) + { + return new ByteBuf(bytes, 0, bytes.Length); + } + + public void Replace(byte[] bytes) + { + Bytes = bytes; + ReaderIndex = 0; + WriterIndex = Capacity; + } + + public void Replace(byte[] bytes, int beginPos, int endPos) + { + Bytes = bytes; + ReaderIndex = beginPos; + WriterIndex = endPos; + } + + public int ReaderIndex { get; set; } + + public int WriterIndex { get; set; } + + private readonly Action _releaser; + + public int Capacity => Bytes.Length; + + public int Size { get { return WriterIndex - ReaderIndex; } } + + public bool Empty => WriterIndex <= ReaderIndex; + + public bool NotEmpty => WriterIndex > ReaderIndex; + + + public void AddWriteIndex(int add) + { + WriterIndex += add; + } + + public void AddReadIndex(int add) + { + ReaderIndex += add; + } + +#pragma warning disable CA1819 // 属性不应返回数组 + public byte[] Bytes { get; private set; } +#pragma warning restore CA1819 // 属性不应返回数组 + + public byte[] CopyData() + { + var n = Remaining; + if (n > 0) + { + var arr = new byte[n]; + Buffer.BlockCopy(Bytes, ReaderIndex, arr, 0, n); + return arr; + } + else + { + return Array.Empty(); + } + } + + public int Remaining { get { return WriterIndex - ReaderIndex; } } + + public void DiscardReadBytes() + { + WriterIndex -= ReaderIndex; + Array.Copy(Bytes, ReaderIndex, Bytes, 0, WriterIndex); + ReaderIndex = 0; + } + + public int NotCompactWritable { get { return Capacity - WriterIndex; } } + + public void WriteBytesWithoutSize(byte[] bs) + { + WriteBytesWithoutSize(bs, 0, bs.Length); + } + + public void WriteBytesWithoutSize(byte[] bs, int offset, int len) + { + EnsureWrite(len); + Buffer.BlockCopy(bs, offset, Bytes, WriterIndex, len); + WriterIndex += len; + } + + public void Clear() + { + ReaderIndex = WriterIndex = 0; + } + + private const int MIN_CAPACITY = 16; + + private static int PropSize(int initSize, int needSize) + { + for (int i = Math.Max(initSize, MIN_CAPACITY); ; i <<= 1) + { + if (i >= needSize) + { + return i; + } + } + } + + private void EnsureWrite0(int size) + { + var needSize = WriterIndex + size - ReaderIndex; + if (needSize < Capacity) + { + WriterIndex -= ReaderIndex; + Array.Copy(Bytes, ReaderIndex, Bytes, 0, WriterIndex); + ReaderIndex = 0; + } + else + { + int newCapacity = PropSize(Capacity, needSize); + var newBytes = new byte[newCapacity]; + WriterIndex -= ReaderIndex; + Buffer.BlockCopy(Bytes, ReaderIndex, newBytes, 0, WriterIndex); + ReaderIndex = 0; + Bytes = newBytes; + } + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public void EnsureWrite(int size) + { + if (WriterIndex + size > Capacity) + { + EnsureWrite0(size); + } + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + private void EnsureRead(int size) + { + if (ReaderIndex + size > WriterIndex) + { + throw new SerializationException(); + } + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + private bool CanRead(int size) + { + return (ReaderIndex + size <= WriterIndex); + } + + public void Append(byte x) + { + EnsureWrite(1); + Bytes[WriterIndex++] = x; + } + + public void WriteBool(bool b) + { + EnsureWrite(1); + Bytes[WriterIndex++] = (byte)(b ? 1 : 0); + } + + public bool ReadBool() + { + EnsureRead(1); + return Bytes[ReaderIndex++] != 0; + } + + public void WriteByte(byte x) + { + EnsureWrite(1); + Bytes[WriterIndex++] = x; + } + + public byte ReadByte() + { + EnsureRead(1); + return Bytes[ReaderIndex++]; + } + + + public void WriteShort(short x) + { + if (x >= 0) + { + if (x < 0x80) + { + EnsureWrite(1); + Bytes[WriterIndex++] = (byte)x; + return; + } + else if (x < 0x4000) + { + EnsureWrite(2); + Bytes[WriterIndex + 1] = (byte)x; + Bytes[WriterIndex] = (byte)((x >> 8) | 0x80); + WriterIndex += 2; + return; + } + } + EnsureWrite(3); + Bytes[WriterIndex] = 0xff; + Bytes[WriterIndex + 2] = (byte)x; + Bytes[WriterIndex + 1] = (byte)(x >> 8); + WriterIndex += 3; + } + + public short ReadShort() + { + EnsureRead(1); + int h = Bytes[ReaderIndex]; + if (h < 0x80) + { + ReaderIndex++; + return (short)h; + } + else if (h < 0xc0) + { + EnsureRead(2); + int x = ((h & 0x3f) << 8) | Bytes[ReaderIndex + 1]; + ReaderIndex += 2; + return (short)x; + } + else if ((h == 0xff)) + { + EnsureRead(3); + int x = (Bytes[ReaderIndex + 1] << 8) | Bytes[ReaderIndex + 2]; + ReaderIndex += 3; + return (short)x; + } + else + { + throw new SerializationException(); + } + } + + public short ReadFshort() + { + EnsureRead(2); + short x; +#if CPU_SUPPORT_MEMORY_NOT_ALIGN + unsafe + { + fixed (byte* b = &Bytes[ReaderIndex]) + { + x = *(short*)b; + } + } +#else + x = (short)((Bytes[ReaderIndex + 1] << 8) | Bytes[ReaderIndex]); + +#endif + ReaderIndex += 2; + return x; + } + + public void WriteFshort(short x) + { + EnsureWrite(2); +#if CPU_SUPPORT_MEMORY_NOT_ALIGN + unsafe + { + fixed (byte* b = &Bytes[WriterIndex]) + { + *(short*)b = x; + } + } +#else + Bytes[WriterIndex] = (byte)x; + Bytes[WriterIndex + 1] = (byte)(x >> 8); +#endif + WriterIndex += 2; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public void WriteInt(int x) + { + WriteUint((uint)x); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public int ReadInt() + { + return (int)ReadUint(); + } + + + public void WriteUint(uint x) + { + // 如果有修改,记得也把 EndWriteSegment改了 + // 0 111 1111 + if (x < 0x80) + { + EnsureWrite(1); + Bytes[WriterIndex++] = (byte)x; + } + else if (x < 0x4000) // 10 11 1111, - + { + EnsureWrite(2); + Bytes[WriterIndex + 1] = (byte)x; + Bytes[WriterIndex] = (byte)((x >> 8) | 0x80); + WriterIndex += 2; + } + else if (x < 0x200000) // 110 1 1111, -,- + { + EnsureWrite(3); + Bytes[WriterIndex + 2] = (byte)x; + Bytes[WriterIndex + 1] = (byte)(x >> 8); + Bytes[WriterIndex] = (byte)((x >> 16) | 0xc0); + WriterIndex += 3; + } + else if (x < 0x10000000) // 1110 1111,-,-,- + { + EnsureWrite(4); + Bytes[WriterIndex + 3] = (byte)x; + Bytes[WriterIndex + 2] = (byte)(x >> 8); + Bytes[WriterIndex + 1] = (byte)(x >> 16); + Bytes[WriterIndex] = (byte)((x >> 24) | 0xe0); + WriterIndex += 4; + } + else + { + EnsureWrite(5); + Bytes[WriterIndex] = 0xf0; + Bytes[WriterIndex + 4] = (byte)x; + Bytes[WriterIndex + 3] = (byte)(x >> 8); + Bytes[WriterIndex + 2] = (byte)(x >> 16); + Bytes[WriterIndex + 1] = (byte)(x >> 24); + WriterIndex += 5; + } + } + + public uint ReadUint() + { + /// + /// 警告! 如有修改,记得调整 TryDeserializeInplaceOctets + EnsureRead(1); + uint h = Bytes[ReaderIndex]; + if (h < 0x80) + { + ReaderIndex++; + return h; + } + else if (h < 0xc0) + { + EnsureRead(2); + uint x = ((h & 0x3f) << 8) | Bytes[ReaderIndex + 1]; + ReaderIndex += 2; + return x; + } + else if (h < 0xe0) + { + EnsureRead(3); + uint x = ((h & 0x1f) << 16) | ((uint)Bytes[ReaderIndex + 1] << 8) | Bytes[ReaderIndex + 2]; + ReaderIndex += 3; + return x; + } + else if (h < 0xf0) + { + + EnsureRead(4); + uint x = ((h & 0x0f) << 24) | ((uint)Bytes[ReaderIndex + 1] << 16) | ((uint)Bytes[ReaderIndex + 2] << 8) | Bytes[ReaderIndex + 3]; + ReaderIndex += 4; + return x; + } + else + { + EnsureRead(5); + uint x = ((uint)Bytes[ReaderIndex + 1] << 24) | ((uint)(Bytes[ReaderIndex + 2] << 16)) | ((uint)Bytes[ReaderIndex + 3] << 8) | Bytes[ReaderIndex + 4]; + ReaderIndex += 5; + return x; + } + } + + public unsafe void WriteUint_Unsafe(uint x) + { + // 0 111 1111 + if (x < 0x80) + { + EnsureWrite(1); + Bytes[WriterIndex++] = (byte)(x << 1); + } + else if (x < 0x4000)// 10 11 1111, - + { + EnsureWrite(2); + + fixed (byte* wb = &Bytes[WriterIndex]) + { + *(uint*)(wb) = (x << 2 | 0b01); + } + + WriterIndex += 2; + } + else if (x < 0x200000) // 110 1 1111, -,- + { + EnsureWrite(3); + + fixed (byte* wb = &Bytes[WriterIndex]) + { + *(uint*)(wb) = (x << 3 | 0b011); + } + WriterIndex += 3; + } + else if (x < 0x10000000) // 1110 1111,-,-,- + { + EnsureWrite(4); + fixed (byte* wb = &Bytes[WriterIndex]) + { + *(uint*)(wb) = (x << 4 | 0b0111); + } + WriterIndex += 4; + } + else + { + EnsureWrite(5); + fixed (byte* wb = &Bytes[WriterIndex]) + { + *(uint*)(wb) = (x << 5 | 0b01111); + } + WriterIndex += 5; + } + } + + public unsafe uint ReadUint_Unsafe() + { + /// + /// 警告! 如有修改,记得调整 TryDeserializeInplaceOctets + EnsureRead(1); + uint h = Bytes[ReaderIndex]; + if ((h & 0b1) == 0b0) + { + ReaderIndex++; + return (h >> 1); + } + else if ((h & 0b11) == 0b01) + { + EnsureRead(2); + fixed (byte* rb = &Bytes[ReaderIndex]) + { + ReaderIndex += 2; + return (*(uint*)rb) >> 2; + } + } + else if ((h & 0b111) == 0b011) + { + EnsureRead(3); + fixed (byte* rb = &Bytes[ReaderIndex]) + { + ReaderIndex += 3; + return (*(uint*)rb) >> 3; + } + } + else if ((h & 0b1111) == 0b0111) + { + EnsureRead(4); + fixed (byte* rb = &Bytes[ReaderIndex]) + { + ReaderIndex += 4; + return (*(uint*)rb) >> 4; + } + } + else + { + EnsureRead(5); + fixed (byte* rb = &Bytes[ReaderIndex]) + { + ReaderIndex += 5; + return (*(uint*)rb) >> 5; + } + } + } + + public int ReadFint() + { + EnsureRead(4); + int x; +#if CPU_SUPPORT_MEMORY_NOT_ALIGN + unsafe + { + fixed (byte* b = &Bytes[ReaderIndex]) + { + x = *(int*)b; + } + } +#else + x = (Bytes[ReaderIndex + 3] << 24) | (Bytes[ReaderIndex + 2] << 16) | (Bytes[ReaderIndex + 1] << 8) | (Bytes[ReaderIndex]); + +#endif + ReaderIndex += 4; + return x; + } + + + public void WriteFint(int x) + { + EnsureWrite(4); +#if CPU_SUPPORT_MEMORY_NOT_ALIGN + unsafe + { + fixed (byte* b = &Bytes[WriterIndex]) + { + *(int*)b = x; + } + } +#else + Bytes[WriterIndex] = (byte)x; + Bytes[WriterIndex + 1] = (byte)(x >> 8); + Bytes[WriterIndex + 2] = (byte)(x >> 16); + Bytes[WriterIndex + 3] = (byte)(x >> 24); +#endif + WriterIndex += 4; + } + + public int ReadFint_Safe() + { + EnsureRead(4); + int x; + + x = (Bytes[ReaderIndex + 3] << 24) | (Bytes[ReaderIndex + 2] << 16) | (Bytes[ReaderIndex + 1] << 8) | (Bytes[ReaderIndex]); + + ReaderIndex += 4; + return x; + } + + + public void WriteFint_Safe(int x) + { + EnsureWrite(4); + Bytes[WriterIndex] = (byte)x; + Bytes[WriterIndex + 1] = (byte)(x >> 8); + Bytes[WriterIndex + 2] = (byte)(x >> 16); + Bytes[WriterIndex + 3] = (byte)(x >> 24); + WriterIndex += 4; + } + + public void WriteLong(long x) + { + WriteUlong((ulong)x); + } + + public long ReadLong() + { + return (long)ReadUlong(); + } + + public void WriteNumberAsLong(double x) + { + WriteLong((long)x); + } + + public double ReadLongAsNumber() + { + return ReadLong(); + } + + private void WriteUlong(ulong x) + { + // 0 111 1111 + if (x < 0x80) + { + EnsureWrite(1); + Bytes[WriterIndex++] = (byte)x; + } + else if (x < 0x4000) // 10 11 1111, - + { + EnsureWrite(2); + Bytes[WriterIndex + 1] = (byte)x; + Bytes[WriterIndex] = (byte)((x >> 8) | 0x80); + WriterIndex += 2; + } + else if (x < 0x200000) // 110 1 1111, -,- + { + EnsureWrite(3); + Bytes[WriterIndex + 2] = (byte)x; + Bytes[WriterIndex + 1] = (byte)(x >> 8); + Bytes[WriterIndex] = (byte)((x >> 16) | 0xc0); + WriterIndex += 3; + } + else if (x < 0x10000000) // 1110 1111,-,-,- + { + EnsureWrite(4); + Bytes[WriterIndex + 3] = (byte)x; + Bytes[WriterIndex + 2] = (byte)(x >> 8); + Bytes[WriterIndex + 1] = (byte)(x >> 16); + Bytes[WriterIndex] = (byte)((x >> 24) | 0xe0); + WriterIndex += 4; + } + else if (x < 0x800000000L) // 1111 0xxx,-,-,-,- + { + EnsureWrite(5); + Bytes[WriterIndex + 4] = (byte)x; + Bytes[WriterIndex + 3] = (byte)(x >> 8); + Bytes[WriterIndex + 2] = (byte)(x >> 16); + Bytes[WriterIndex + 1] = (byte)(x >> 24); + Bytes[WriterIndex] = (byte)((x >> 32) | 0xf0); + WriterIndex += 5; + } + else if (x < 0x40000000000L) // 1111 10xx, + { + EnsureWrite(6); + Bytes[WriterIndex + 5] = (byte)x; + Bytes[WriterIndex + 4] = (byte)(x >> 8); + Bytes[WriterIndex + 3] = (byte)(x >> 16); + Bytes[WriterIndex + 2] = (byte)(x >> 24); + Bytes[WriterIndex + 1] = (byte)(x >> 32); + Bytes[WriterIndex] = (byte)((x >> 40) | 0xf8); + WriterIndex += 6; + } + else if (x < 0x200000000000L) // 1111 110x, + { + EnsureWrite(7); + Bytes[WriterIndex + 6] = (byte)x; + Bytes[WriterIndex + 5] = (byte)(x >> 8); + Bytes[WriterIndex + 4] = (byte)(x >> 16); + Bytes[WriterIndex + 3] = (byte)(x >> 24); + Bytes[WriterIndex + 2] = (byte)(x >> 32); + Bytes[WriterIndex + 1] = (byte)(x >> 40); + Bytes[WriterIndex] = (byte)((x >> 48) | 0xfc); + WriterIndex += 7; + } + else if (x < 0x100000000000000L) // 1111 1110 + { + EnsureWrite(8); + Bytes[WriterIndex + 7] = (byte)x; + Bytes[WriterIndex + 6] = (byte)(x >> 8); + Bytes[WriterIndex + 5] = (byte)(x >> 16); + Bytes[WriterIndex + 4] = (byte)(x >> 24); + Bytes[WriterIndex + 3] = (byte)(x >> 32); + Bytes[WriterIndex + 2] = (byte)(x >> 40); + Bytes[WriterIndex + 1] = (byte)(x >> 48); + Bytes[WriterIndex] = 0xfe; + WriterIndex += 8; + } + else // 1111 1111 + { + EnsureWrite(9); + Bytes[WriterIndex] = 0xff; + Bytes[WriterIndex + 8] = (byte)x; + Bytes[WriterIndex + 7] = (byte)(x >> 8); + Bytes[WriterIndex + 6] = (byte)(x >> 16); + Bytes[WriterIndex + 5] = (byte)(x >> 24); + Bytes[WriterIndex + 4] = (byte)(x >> 32); + Bytes[WriterIndex + 3] = (byte)(x >> 40); + Bytes[WriterIndex + 2] = (byte)(x >> 48); + Bytes[WriterIndex + 1] = (byte)(x >> 56); + WriterIndex += 9; + } + } + + public ulong ReadUlong() + { + EnsureRead(1); + uint h = Bytes[ReaderIndex]; + if (h < 0x80) + { + ReaderIndex++; + return h; + } + else if (h < 0xc0) + { + EnsureRead(2); + uint x = ((h & 0x3f) << 8) | Bytes[ReaderIndex + 1]; + ReaderIndex += 2; + return x; + } + else if (h < 0xe0) + { + EnsureRead(3); + uint x = ((h & 0x1f) << 16) | ((uint)Bytes[ReaderIndex + 1] << 8) | Bytes[ReaderIndex + 2]; + ReaderIndex += 3; + return x; + } + else if (h < 0xf0) + { + EnsureRead(4); + uint x = ((h & 0x0f) << 24) | ((uint)Bytes[ReaderIndex + 1] << 16) | ((uint)Bytes[ReaderIndex + 2] << 8) | Bytes[ReaderIndex + 3]; + ReaderIndex += 4; + return x; + } + else if (h < 0xf8) + { + EnsureRead(5); + uint xl = ((uint)Bytes[ReaderIndex + 1] << 24) | ((uint)(Bytes[ReaderIndex + 2] << 16)) | ((uint)Bytes[ReaderIndex + 3] << 8) | (Bytes[ReaderIndex + 4]); + uint xh = h & 0x07; + ReaderIndex += 5; + return ((ulong)xh << 32) | xl; + } + else if (h < 0xfc) + { + EnsureRead(6); + uint xl = ((uint)Bytes[ReaderIndex + 2] << 24) | ((uint)(Bytes[ReaderIndex + 3] << 16)) | ((uint)Bytes[ReaderIndex + 4] << 8) | (Bytes[ReaderIndex + 5]); + uint xh = ((h & 0x03) << 8) | Bytes[ReaderIndex + 1]; + ReaderIndex += 6; + return ((ulong)xh << 32) | xl; + } + else if (h < 0xfe) + { + EnsureRead(7); + uint xl = ((uint)Bytes[ReaderIndex + 3] << 24) | ((uint)(Bytes[ReaderIndex + 4] << 16)) | ((uint)Bytes[ReaderIndex + 5] << 8) | (Bytes[ReaderIndex + 6]); + uint xh = ((h & 0x01) << 16) | ((uint)Bytes[ReaderIndex + 1] << 8) | Bytes[ReaderIndex + 2]; + ReaderIndex += 7; + return ((ulong)xh << 32) | xl; + } + else if (h < 0xff) + { + EnsureRead(8); + uint xl = ((uint)Bytes[ReaderIndex + 4] << 24) | ((uint)(Bytes[ReaderIndex + 5] << 16)) | ((uint)Bytes[ReaderIndex + 6] << 8) | (Bytes[ReaderIndex + 7]); + uint xh = /*((h & 0x01) << 24) |*/ ((uint)Bytes[ReaderIndex + 1] << 16) | ((uint)Bytes[ReaderIndex + 2] << 8) | Bytes[ReaderIndex + 3]; + ReaderIndex += 8; + return ((ulong)xh << 32) | xl; + } + else + { + EnsureRead(9); + uint xl = ((uint)Bytes[ReaderIndex + 5] << 24) | ((uint)(Bytes[ReaderIndex + 6] << 16)) | ((uint)Bytes[ReaderIndex + 7] << 8) | (Bytes[ReaderIndex + 8]); + uint xh = ((uint)Bytes[ReaderIndex + 1] << 24) | ((uint)Bytes[ReaderIndex + 2] << 16) | ((uint)Bytes[ReaderIndex + 3] << 8) | Bytes[ReaderIndex + 4]; + ReaderIndex += 9; + return ((ulong)xh << 32) | xl; + } + } + + + public void WriteFlong(long x) + { + EnsureWrite(8); +#if CPU_SUPPORT_MEMORY_NOT_ALIGN + unsafe + { + fixed (byte* b = &Bytes[WriterIndex]) + { + *(long*)b = x; + } + } +#else + + Bytes[WriterIndex] = (byte)x; + Bytes[WriterIndex + 1] = (byte)(x >> 8); + Bytes[WriterIndex + 2] = (byte)(x >> 16); + Bytes[WriterIndex + 3] = (byte)(x >> 24); + Bytes[WriterIndex + 4] = (byte)(x >> 32); + Bytes[WriterIndex + 5] = (byte)(x >> 40); + Bytes[WriterIndex + 6] = (byte)(x >> 48); + Bytes[WriterIndex + 7] = (byte)(x >> 56); +#endif + WriterIndex += 8; + } + + public long ReadFlong() + { + EnsureRead(8); + long x; +#if CPU_SUPPORT_MEMORY_NOT_ALIGN + unsafe + { + fixed (byte* b = &Bytes[ReaderIndex]) + { + x = *(long*)b; + } + } +#else + int xl = (Bytes[ReaderIndex + 3] << 24) | ((Bytes[ReaderIndex + 2] << 16)) | (Bytes[ReaderIndex + 1] << 8) | (Bytes[ReaderIndex]); + int xh = (Bytes[ReaderIndex + 7] << 24) | (Bytes[ReaderIndex + 6] << 16) | (Bytes[ReaderIndex + 5] << 8) | Bytes[ReaderIndex + 4]; + x = ((long)xh << 32) | (long)xl; +#endif + ReaderIndex += 8; + return x; + } + + private static unsafe void Copy8(byte* dst, byte* src) + { + dst[0] = src[0]; + dst[1] = src[1]; + dst[2] = src[2]; + dst[3] = src[3]; + dst[4] = src[4]; + dst[5] = src[5]; + dst[6] = src[6]; + dst[7] = src[7]; + } + + private static unsafe void Copy4(byte* dst, byte* src) + { + dst[0] = src[0]; + dst[1] = src[1]; + dst[2] = src[2]; + dst[3] = src[3]; + } + + + //const bool isLittleEndian = true; + public void WriteFloat(float x) + { + EnsureWrite(4); + unsafe + { + fixed (byte* b = &Bytes[WriterIndex]) + { +#if !CPU_SUPPORT_MEMORY_NOT_ALIGN + if ((long)b % 4 == 0) + { + *(float*)b = x; + } + else + { + Copy4(b, (byte*)&x); + } +#else + *(float*)b = x; +#endif + } + } + + //if (!BitConverter.IsLittleEndian) + //{ + // Array.Reverse(data, endPos, 4); + //} + WriterIndex += 4; + } + + public float ReadFloat() + { + EnsureRead(4); + //if (!BitConverter.IsLittleEndian) + //{ + // Array.Reverse(data, beginPos, 4); + //} + float x; + unsafe + { + fixed (byte* b = &Bytes[ReaderIndex]) + { +#if !CPU_SUPPORT_MEMORY_NOT_ALIGN + if ((long)b % 4 == 0) + { + x = *(float*)b; + } + else + { + *((int*)&x) = (b[0]) | (b[1] << 8) | (b[2] << 16) | (b[3] << 24); + } +#else + x = *(float*)b; +#endif + } + } + + ReaderIndex += 4; + return x; + } + + public void WriteDouble(double x) + { + EnsureWrite(8); + unsafe + { + fixed (byte* b = &Bytes[WriterIndex]) + { +#if !CPU_SUPPORT_MEMORY_NOT_ALIGN + if ((long)b % 8 == 0) + { + *(double*)b = x; + } + else + { + Copy8(b, (byte*)&x); + } +#else + *(double*)b = x; +#endif + } + //if (!BitConverter.IsLittleEndian) + //{ + // Array.Reverse(data, endPos, 8); + //} + } + + WriterIndex += 8; + } + + public double ReadDouble() + { + EnsureRead(8); + //if (!BitConverter.IsLittleEndian) + //{ + // Array.Reverse(data, beginPos, 8); + //} + double x; + unsafe + { + fixed (byte* b = &Bytes[ReaderIndex]) + { +#if !CPU_SUPPORT_MEMORY_NOT_ALIGN + if ((long)b % 8 == 0) + { + x = *(double*)b; + } + else + { + int low = (b[0]) | (b[1] << 8) | (b[2] << 16) | (b[3] << 24); + int high = (b[4]) | (b[5] << 8) | (b[6] << 16) | (b[7] << 24); + *((long*)&x) = ((long)high << 32) | (uint)low; + } +#else + x = *(double*)b; +#endif + } + } + + ReaderIndex += 8; + return x; + } + + public void WriteSize(int n) + { + WriteUint((uint)n); + } + + public int ReadSize() + { + return (int)ReadUint(); + } + + // marshal int + // n -> (n << 1) ^ (n >> 31) + // Read + // (x >>> 1) ^ ((x << 31) >> 31) + // (x >>> 1) ^ -(n&1) + public void WriteSint(int x) + { + WriteUint(((uint)x << 1) ^ ((uint)x >> 31)); + } + + public int ReadSint() + { + uint x = ReadUint(); + return (int)((x >> 1) ^ ((x & 1) << 31)); + } + + + // marshal long + // n -> (n << 1) ^ (n >> 63) + // Read + // (x >>> 1) ^((x << 63) >> 63) + // (x >>> 1) ^ -(n&1L) + public void WriteSlong(long x) + { + WriteUlong(((ulong)x << 1) ^ ((ulong)x >> 63)); + } + + public long ReadSlong() + { + long x = ReadLong(); + return ((long)((ulong)x >> 1) ^ ((x & 1) << 63)); + } + + public void WriteString(string x) + { + var n = x != null ? Encoding.UTF8.GetByteCount(x) : 0; + WriteSize(n); + if (n > 0) + { + EnsureWrite(n); + Encoding.UTF8.GetBytes(x, 0, x.Length, Bytes, WriterIndex); + WriterIndex += n; + } + } + + // byte[], [start, end) + public static Func StringCacheFinder { get; set; } + + public string ReadString() + { + var n = ReadSize(); + if (n > 0) + { + EnsureRead(n); + string s; + + if (StringCacheFinder == null) + { + s = Encoding.UTF8.GetString(Bytes, ReaderIndex, n); + } + else + { + // 只缓存比较小的字符串 + s = StringCacheFinder(Bytes, ReaderIndex, n); + } + ReaderIndex += n; + return s; + } + else + { + return string.Empty; + } + } + + public void WriteBytes(byte[] x) + { + var n = x != null ? x.Length : 0; + WriteSize(n); + if (n > 0) + { + EnsureWrite(n); + x.CopyTo(Bytes, WriterIndex); + WriterIndex += n; + } + } + + public byte[] ReadBytes() + { + var n = ReadSize(); + if (n > 0) + { + EnsureRead(n); + var x = new byte[n]; + Buffer.BlockCopy(Bytes, ReaderIndex, x, 0, n); + ReaderIndex += n; + return x; + } + else + { + return Array.Empty(); + } + } + + // 以下是一些特殊类型 + + public void WriteComplex(Complex x) + { + WriteDouble(x.Real); + WriteDouble(x.Imaginary); + } + + public Complex ReadComplex() + { + var x = ReadDouble(); + var y = ReadDouble(); + return new Complex(x, y); + } + + public void WriteVector2(Vector2 x) + { + WriteFloat(x.X); + WriteFloat(x.Y); + } + + public Vector2 ReadVector2() + { + float x = ReadFloat(); + float y = ReadFloat(); + return new Vector2(x, y); + } + + public void WriteVector3(Vector3 x) + { + WriteFloat(x.X); + WriteFloat(x.Y); + WriteFloat(x.Z); + } + + public Vector3 ReadVector3() + { + float x = ReadFloat(); + float y = ReadFloat(); + float z = ReadFloat(); + return new Vector3(x, y, z); + } + + public void WriteVector4(Vector4 x) + { + WriteFloat(x.X); + WriteFloat(x.Y); + WriteFloat(x.Z); + WriteFloat(x.W); + } + + public Vector4 ReadVector4() + { + float x = ReadFloat(); + float y = ReadFloat(); + float z = ReadFloat(); + float w = ReadFloat(); + return new Vector4(x, y, z, w); + } + + + public void WriteQuaternion(Quaternion x) + { + WriteFloat(x.X); + WriteFloat(x.Y); + WriteFloat(x.Z); + WriteFloat(x.W); + } + + public Quaternion ReadQuaternion() + { + float x = ReadFloat(); + float y = ReadFloat(); + float z = ReadFloat(); + float w = ReadFloat(); + return new Quaternion(x, y, z, w); + } + + + public void WriteMatrix4x4(Matrix4x4 x) + { + WriteFloat(x.M11); + WriteFloat(x.M12); + WriteFloat(x.M13); + WriteFloat(x.M14); + WriteFloat(x.M21); + WriteFloat(x.M22); + WriteFloat(x.M23); + WriteFloat(x.M24); + WriteFloat(x.M31); + WriteFloat(x.M32); + WriteFloat(x.M33); + WriteFloat(x.M34); + WriteFloat(x.M41); + WriteFloat(x.M42); + WriteFloat(x.M43); + WriteFloat(x.M44); + } + + public Matrix4x4 ReadMatrix4x4() + { + float m11 = ReadFloat(); + float m12 = ReadFloat(); + float m13 = ReadFloat(); + float m14 = ReadFloat(); + float m21 = ReadFloat(); + float m22 = ReadFloat(); + float m23 = ReadFloat(); + float m24 = ReadFloat(); + float m31 = ReadFloat(); + float m32 = ReadFloat(); + float m33 = ReadFloat(); + float m34 = ReadFloat(); + float m41 = ReadFloat(); + float m42 = ReadFloat(); + float m43 = ReadFloat(); + float m44 = ReadFloat(); + return new Matrix4x4(m11, m12, m13, m14, + m21, m22, m23, m24, + m31, m32, m33, m34, + m41, m42, m43, m44); + } + + internal void SkipBytes() + { + int n = ReadSize(); + EnsureRead(n); + ReaderIndex += n; + } + + + public void WriteByteBufWithSize(ByteBuf o) + { + int n = o.Size; + if (n > 0) + { + WriteSize(n); + WriteBytesWithoutSize(o.Bytes, o.ReaderIndex, n); + } + else + { + WriteByte(0); + } + } + + public void WriteByteBufWithoutSize(ByteBuf o) + { + int n = o.Size; + if (n > 0) + { + WriteBytesWithoutSize(o.Bytes, o.ReaderIndex, n); + } + } + + public bool TryReadByte(out byte x) + { + if (CanRead(1)) + { + x = Bytes[ReaderIndex++]; + return true; + } + else + { + x = 0; + return false; + } + } + + public EDeserializeError TryDeserializeInplaceByteBuf(int maxSize, ByteBuf inplaceTempBody) + { + //if (!CanRead(1)) { return EDeserializeError.NOT_ENOUGH; } + int oldReadIndex = ReaderIndex; + bool commit = false; + try + { + int n; + int h = Bytes[ReaderIndex]; + if (h < 0x80) + { + ReaderIndex++; + n = h; + } + else if (h < 0xc0) + { + if (!CanRead(2)) { return EDeserializeError.NOT_ENOUGH; } + n = ((h & 0x3f) << 8) | Bytes[ReaderIndex + 1]; + ReaderIndex += 2; + } + else if (h < 0xe0) + { + if (!CanRead(3)) { return EDeserializeError.NOT_ENOUGH; } + n = ((h & 0x1f) << 16) | (Bytes[ReaderIndex + 1] << 8) | Bytes[ReaderIndex + 2]; + ReaderIndex += 3; + } + else if (h < 0xf0) + { + if (!CanRead(4)) { return EDeserializeError.NOT_ENOUGH; } + n = ((h & 0x0f) << 24) | (Bytes[ReaderIndex + 1] << 16) | (Bytes[ReaderIndex + 2] << 8) | Bytes[ReaderIndex + 3]; + ReaderIndex += 4; + } + else + { + return EDeserializeError.EXCEED_SIZE; + } + + if (n > maxSize) + { + return EDeserializeError.EXCEED_SIZE; + } + if (Remaining < n) + { + return EDeserializeError.NOT_ENOUGH; + } + + int inplaceReadIndex = ReaderIndex; + ReaderIndex += n; + + inplaceTempBody.Replace(Bytes, inplaceReadIndex, ReaderIndex); + commit = true; + } + finally + { + if (!commit) + { + ReaderIndex = oldReadIndex; + } + } + + return EDeserializeError.OK; + } + + public void WriteRawTag(byte b1) + { + EnsureWrite(1); + Bytes[WriterIndex++] = b1; + } + + public void WriteRawTag(byte b1, byte b2) + { + EnsureWrite(2); + Bytes[WriterIndex] = b1; + Bytes[WriterIndex + 1] = b2; + WriterIndex += 2; + } + + public void WriteRawTag(byte b1, byte b2, byte b3) + { + EnsureWrite(3); + Bytes[WriterIndex] = b1; + Bytes[WriterIndex + 1] = b2; + Bytes[WriterIndex + 2] = b3; + WriterIndex += 3; + } + + #region segment + + + public void BeginWriteSegment(out int oldSize) + { + oldSize = Size; + EnsureWrite(1); + WriterIndex += 1; + } + + public void EndWriteSegment(int oldSize) + { + int startPos = ReaderIndex + oldSize; + int segmentSize = WriterIndex - startPos - 1; + + // 0 111 1111 + if (segmentSize < 0x80) + { + Bytes[startPos] = (byte)segmentSize; + } + else if (segmentSize < 0x4000) // 10 11 1111, - + { + EnsureWrite(1); + Bytes[WriterIndex] = Bytes[startPos + 1]; + Bytes[startPos + 1] = (byte)segmentSize; + + Bytes[startPos] = (byte)((segmentSize >> 8) | 0x80); + WriterIndex += 1; + } + else if (segmentSize < 0x200000) // 110 1 1111, -,- + { + EnsureWrite(2); + Bytes[WriterIndex + 1] = Bytes[startPos + 2]; + Bytes[startPos + 2] = (byte)segmentSize; + + Bytes[WriterIndex] = Bytes[startPos + 1]; + Bytes[startPos + 1] = (byte)(segmentSize >> 8); + + Bytes[startPos] = (byte)((segmentSize >> 16) | 0xc0); + WriterIndex += 2; + } + else if (segmentSize < 0x10000000) // 1110 1111,-,-,- + { + EnsureWrite(3); + Bytes[WriterIndex + 2] = Bytes[startPos + 3]; + Bytes[startPos + 3] = (byte)segmentSize; + + Bytes[WriterIndex + 1] = Bytes[startPos + 2]; + Bytes[startPos + 2] = (byte)(segmentSize >> 8); + + Bytes[WriterIndex] = Bytes[startPos + 1]; + Bytes[startPos + 1] = (byte)(segmentSize >> 16); + + Bytes[startPos] = (byte)((segmentSize >> 24) | 0xe0); + WriterIndex += 3; + } + else + { + throw new SerializationException("exceed max segment size"); + } + } + + public void ReadSegment(out int startIndex, out int segmentSize) + { + EnsureRead(1); + int h = Bytes[ReaderIndex++]; + + startIndex = ReaderIndex; + + if (h < 0x80) + { + segmentSize = h; + ReaderIndex += segmentSize; + } + else if (h < 0xc0) + { + EnsureRead(1); + segmentSize = ((h & 0x3f) << 8) | Bytes[ReaderIndex]; + int endPos = ReaderIndex + segmentSize; + Bytes[ReaderIndex] = Bytes[endPos]; + ReaderIndex += segmentSize + 1; + } + else if (h < 0xe0) + { + EnsureRead(2); + segmentSize = ((h & 0x1f) << 16) | ((int)Bytes[ReaderIndex] << 8) | Bytes[ReaderIndex + 1]; + int endPos = ReaderIndex + segmentSize; + Bytes[ReaderIndex] = Bytes[endPos]; + Bytes[ReaderIndex + 1] = Bytes[endPos + 1]; + ReaderIndex += segmentSize + 2; + } + else if (h < 0xf0) + { + EnsureRead(3); + segmentSize = ((h & 0x0f) << 24) | ((int)Bytes[ReaderIndex] << 16) | ((int)Bytes[ReaderIndex + 1] << 8) | Bytes[ReaderIndex + 2]; + int endPos = ReaderIndex + segmentSize; + Bytes[ReaderIndex] = Bytes[endPos]; + Bytes[ReaderIndex + 1] = Bytes[endPos + 1]; + Bytes[ReaderIndex + 2] = Bytes[endPos + 2]; + ReaderIndex += segmentSize + 3; + } + else + { + throw new SerializationException("exceed max size"); + } + if (ReaderIndex > WriterIndex) + { + throw new SerializationException("segment data not enough"); + } + } + + public void ReadSegment(ByteBuf buf) + { + ReadSegment(out int startPos, out var size); + buf.Bytes = Bytes; + buf.ReaderIndex = startPos; + buf.WriterIndex = startPos + size; + } + + public void EnterSegment(out SegmentSaveState saveState) + { + ReadSegment(out int startPos, out int size); + + saveState = new SegmentSaveState(ReaderIndex, WriterIndex); + ReaderIndex = startPos; + WriterIndex = startPos + size; + } + + public void LeaveSegment(SegmentSaveState saveState) + { + ReaderIndex = saveState.ReaderIndex; + WriterIndex = saveState.WriterIndex; + } + + #endregion + + public override string ToString() + { + string[] datas = new string[WriterIndex - ReaderIndex]; + for (var i = ReaderIndex; i < WriterIndex; i++) + { + datas[i - ReaderIndex] = Bytes[i].ToString("X2"); + } + return string.Join(".", datas); + } + + public override bool Equals(object obj) + { + return (obj is ByteBuf other) && Equals(other); + } + + public bool Equals(ByteBuf other) + { + if (other == null) + { + return false; + } + if (Size != other.Size) + { + return false; + } + for (int i = 0, n = Size; i < n; i++) + { + if (Bytes[ReaderIndex + i] != other.Bytes[other.ReaderIndex + i]) + { + return false; + } + } + return true; + } + + public object Clone() + { + return new ByteBuf(CopyData()); + } + + + public static ByteBuf FromString(string value) + { + var ss = value.Split(','); + byte[] data = new byte[ss.Length]; + for (int i = 0; i < data.Length; i++) + { + data[i] = byte.Parse(ss[i]); + } + return new ByteBuf(data); + } + + public override int GetHashCode() + { + int hash = 17; + for (int i = ReaderIndex; i < WriterIndex; i++) + { + hash = hash * 23 + Bytes[i]; + } + return hash; + } + + public void Release() + { + _releaser?.Invoke(this); + } + +#if SUPPORT_PUERTS_ARRAYBUF + // -- add for puerts + public Puerts.ArrayBuffer ReadArrayBuffer() + { + return new Puerts.ArrayBuffer(ReadBytes()); + } + + public void WriteArrayBuffer(Puerts.ArrayBuffer bytes) + { + WriteBytes(bytes.Bytes); + } +#endif + } +} diff --git a/ThirdParty/Luban/StringUtil.cs b/ThirdParty/Luban/StringUtil.cs new file mode 100644 index 0000000..750d50f --- /dev/null +++ b/ThirdParty/Luban/StringUtil.cs @@ -0,0 +1,73 @@ +// Copyright 2025 Code Philosophy +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System.Collections.Generic; +using System.Text; + +namespace Luban +{ + public static class StringUtil + { + public static string ToStr(object o) + { + return ToStr(o, new StringBuilder()); + } + + public static string ToStr(object o, StringBuilder sb) + { + foreach (var p in o.GetType().GetFields()) + { + + sb.Append($"{p.Name} = {p.GetValue(o)},"); + } + + foreach (var p in o.GetType().GetProperties()) + { + sb.Append($"{p.Name} = {p.GetValue(o)},"); + } + return sb.ToString(); + } + + public static string ArrayToString(T[] arr) + { + return "[" + string.Join(",", arr) + "]"; + } + + + public static string CollectionToString(IEnumerable arr) + { + return "[" + string.Join(",", arr) + "]"; + } + + + public static string CollectionToString(IDictionary dic) + { + var sb = new StringBuilder(); + sb.Append('{'); + foreach (var e in dic) + { + sb.Append(e.Key).Append(':'); + sb.Append(e.Value).Append(','); + } + sb.Append('}'); + return sb.ToString(); + } + } +} diff --git a/ThirdParty/ThirdParty.csproj b/ThirdParty/ThirdParty.csproj index cd9a6d3..0590c88 100644 --- a/ThirdParty/ThirdParty.csproj +++ b/ThirdParty/ThirdParty.csproj @@ -8,6 +8,7 @@ + diff --git a/Tools/NetworkProtocol/Inner/InnerMessage.proto b/Tools/NetworkProtocol/Inner/InnerMessage.proto index 387d5cb..73925c7 100644 --- a/Tools/NetworkProtocol/Inner/InnerMessage.proto +++ b/Tools/NetworkProtocol/Inner/InnerMessage.proto @@ -82,3 +82,19 @@ message G2Map_ExitRoomRequest // IAddressRequest,Map2G_ExiRoomResponse message Map2G_ExiRoomResponse // IAddressResponse { } + + + +////////////// ******** 聊天 *******///////////// + +/// Chat通知Gate发送一个全服广播的聊天信息 +message Chat2G_ChatMessage // IAddressMessage +{ + ChatInfoTree ChatInfoTree = 1; +} +/// 其他服务器发送聊天消息到Chat +message Other2Chat_ChatMessage // IAddressMessage +{ + ChatInfoTree ChatInfoTree = 1; +} + diff --git a/Tools/NetworkProtocol/Outer/SocialMessage.proto b/Tools/NetworkProtocol/Outer/SocialMessage.proto index 9b73e67..eac8f52 100644 --- a/Tools/NetworkProtocol/Outer/SocialMessage.proto +++ b/Tools/NetworkProtocol/Outer/SocialMessage.proto @@ -75,6 +75,79 @@ message S2C_MailState // ICustomRouteMessage,SocialRoute } ////////////// ******** 频道聊天 *******///////////// + +/// 发送一个聊天消息给Chat服务器,中间是经过Gate中转的 +message C2Chat_SendMessageRequest // ICustomRouteRequest,Chat2C_SendMessageResponse,SocialRoute +{ + ChatInfoTree ChatInfoTree = 1; +} +message Chat2C_SendMessageResponse // ICustomRouteResponse +{ + +} + +// 该消息是Chat发送给Gate服务器,让Gate服务器自动转发到客户端 +message Chat2C_Message // ICustomRouteMessage,SocialRoute +{ + ChatInfoTree ChatInfoTree = 1; +} + +/// 聊天消息树 +message ChatInfoTree +{ + int32 ChatChannelType = 1; // 频道的类型 + int64 ChatChannelId = 2; // 频道的ID + int64 UnitId = 3; // 发送人的UnitId + string UserName = 4; // 发送人的名字 + repeated int64 Target = 5; // 接收聊天信息的目标数组 + repeated ChatInfoNode Node = 6; // 聊天节点 +} + +/// 聊天信息节点 +message ChatInfoNode +{ + int32 ChatNodeType = 1; // 节点类型(例如:超链接、普通的内容、表情...) + int32 ChatNodeEvent = 2; // 节点分发事件的类型(例如:点击某个字打开某个UI或者执行某些操作) + string Content = 3; // 信息内容 + string Color = 4; // 表示这个内容的颜色 + repeatedArray byte Data = 5; // 表示附加的一些数据 +} + +/// 聊天位置信息节点 +message ChatPositionNode +{ + string MapName = 1; + float PosX = 2; + float PosY = 3; + float PosZ = 4; +} + +/// 聊天位置信息节点 +message ChatOpenUINode +{ + string UIName = 1; +} + +/// 聊天连接信息节点 +message ChatLinkNode +{ + string Link = 1; +} + + + + + + + + + + + + + + + message ChatUserInfo { int64 Id = 1;//用户id diff --git a/Tools/NetworkProtocol/Outer/data/CommonProtoData.proto b/Tools/NetworkProtocol/Outer/data/CommonProtoData.proto index dd62e48..480dfa6 100644 --- a/Tools/NetworkProtocol/Outer/data/CommonProtoData.proto +++ b/Tools/NetworkProtocol/Outer/data/CommonProtoData.proto @@ -73,7 +73,7 @@ message ItemBindInfo ///物品信息 message ItemInfo { - uint32 ConfigId = 1; //配置id + int32 ConfigId = 1; //配置id int64 Id = 2; //物品id int32 Count = 3; //数量 int64 ExpirationTime = 4; //失效时间 @@ -83,9 +83,9 @@ message ItemInfo ///商店物品信息 message ShopItemInfo { - uint32 ConfigId = 1; //商品配置id - uint32 Price = 2; //价格 - uint32 Currency = 3; //货币类型 + int32 ConfigId = 1; //商品配置id + uint32 Price1 = 2; //价格1 + uint32 Price2 = 3; //价格2 uint32 Sort = 4; //排序 uint32 Tag = 5; //特殊标签 } @@ -93,7 +93,7 @@ message ShopItemInfo ///fish信息 message FishInfo { - uint32 ConfigId = 1; //配置id + int32 ConfigId = 1; //配置id int64 Id = 2; //物品id int32 Weight = 3; //重量 int64 GetTime = 4; //获得时间 @@ -112,7 +112,7 @@ message ActivityInfo ///技能情况 message SkillInfo { - uint32 ConfigId = 1; //技能配置id + int32 ConfigId = 1; //技能配置id int32 Level = 2; //技能等级 int32 Exp = 3; //技能经验 } \ No newline at end of file