feat(network): 基于 TSRPC 的网络同步模块 (#318)

- network-protocols: 共享协议包,使用 TSRPC CLI 生成完整类型验证
- network: 浏览器客户端,提供 NetworkPlugin、NetworkService 和同步系统
- network-server: Node.js 服务端,提供 GameServer 和房间管理
This commit is contained in:
YHH
2025-12-24 22:49:29 +08:00
committed by GitHub
parent dbc6793dc4
commit 235c432edb
35 changed files with 2727 additions and 88 deletions

View File

@@ -0,0 +1,65 @@
/**
* @esengine/network
*
* 基于 TSRPC 的网络同步模块(客户端)
* TSRPC-based network synchronization module (client)
*/
// ============================================================================
// Re-export from protocols | 从协议包重新导出
// ============================================================================
export type {
ServiceType,
Vec2,
IEntityState,
IPlayerInput,
MsgSync,
MsgInput,
MsgSpawn,
MsgDespawn,
ReqJoin,
ResJoin
} from '@esengine/network-protocols';
export { serviceProto } from '@esengine/network-protocols';
// ============================================================================
// Tokens | 服务令牌
// ============================================================================
export {
NetworkServiceToken,
NetworkSyncSystemToken,
NetworkSpawnSystemToken,
NetworkInputSystemToken
} from './tokens';
// ============================================================================
// Plugin | 插件
// ============================================================================
export { NetworkPlugin } from './NetworkPlugin';
// ============================================================================
// Services | 服务
// ============================================================================
export { NetworkService, ENetworkState } from './services/NetworkService';
export type { INetworkCallbacks } from './services/NetworkService';
// ============================================================================
// Components | 组件
// ============================================================================
export { NetworkIdentity } from './components/NetworkIdentity';
export { NetworkTransform } from './components/NetworkTransform';
// ============================================================================
// Systems | 系统
// ============================================================================
export { NetworkSyncSystem } from './systems/NetworkSyncSystem';
export { NetworkSpawnSystem } from './systems/NetworkSpawnSystem';
export type { PrefabFactory } from './systems/NetworkSpawnSystem';
export { NetworkInputSystem } from './systems/NetworkInputSystem';