@esengine/ecs-framework 2.4.4 → 2.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.cjs +1 -1
- package/index.cjs.map +1 -1
- package/index.d.ts +872 -21
- package/index.es5.js +1 -1
- package/index.es5.js.map +1 -1
- package/index.mjs +1 -1
- package/index.mjs.map +1 -1
- package/index.umd.js +1 -1
- package/index.umd.js.map +1 -1
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @esengine/ecs-framework v2.
|
|
2
|
+
* @esengine/ecs-framework v2.5.1
|
|
3
3
|
* TypeScript definitions
|
|
4
4
|
*/
|
|
5
5
|
/**
|
|
@@ -832,10 +832,16 @@ type ISceneDebugData = {
|
|
|
832
832
|
* @en Components in ECS architecture should be pure data containers.
|
|
833
833
|
* All game logic should be implemented in EntitySystem, not inside components.
|
|
834
834
|
*
|
|
835
|
+
* @zh **重要:所有 Component 子类都必须使用 @ECSComponent 装饰器!**
|
|
836
|
+
* @zh 该装饰器用于注册组件类型名称,是序列化、网络同步等功能正常工作的前提。
|
|
837
|
+
* @en **IMPORTANT: All Component subclasses MUST use the @ECSComponent decorator!**
|
|
838
|
+
* @en This decorator registers the component type name, which is required for serialization, network sync, etc.
|
|
839
|
+
*
|
|
835
840
|
* @example
|
|
836
|
-
* @zh
|
|
837
|
-
* @en
|
|
841
|
+
* @zh 正确做法:使用 @ECSComponent 装饰器
|
|
842
|
+
* @en Correct: Use @ECSComponent decorator
|
|
838
843
|
* ```typescript
|
|
844
|
+
* @ECSComponent('HealthComponent')
|
|
839
845
|
* class HealthComponent extends Component {
|
|
840
846
|
* public health: number = 100;
|
|
841
847
|
* public maxHealth: number = 100;
|
|
@@ -6367,7 +6373,9 @@ declare class Scene implements IScene {
|
|
|
6367
6373
|
*/
|
|
6368
6374
|
end(): void;
|
|
6369
6375
|
/**
|
|
6370
|
-
* 更新场景
|
|
6376
|
+
* @zh 更新场景
|
|
6377
|
+
* @en Update scene
|
|
6378
|
+
* @internal 由 SceneManager 或 World 调用,用户不应直接调用
|
|
6371
6379
|
*/
|
|
6372
6380
|
update(): void;
|
|
6373
6381
|
/**
|
|
@@ -11498,18 +11506,9 @@ declare class SceneManager implements IService {
|
|
|
11498
11506
|
*/
|
|
11499
11507
|
get api(): ECSFluentAPI | null;
|
|
11500
11508
|
/**
|
|
11501
|
-
* 更新场景
|
|
11502
|
-
*
|
|
11503
|
-
*
|
|
11504
|
-
* 会自动处理延迟场景切换。
|
|
11505
|
-
*
|
|
11506
|
-
* @example
|
|
11507
|
-
* ```typescript
|
|
11508
|
-
* function gameLoop(deltaTime: number) {
|
|
11509
|
-
* Core.update(deltaTime);
|
|
11510
|
-
* sceneManager.update(); // 每帧调用
|
|
11511
|
-
* }
|
|
11512
|
-
* ```
|
|
11509
|
+
* @zh 更新场景
|
|
11510
|
+
* @en Update scene
|
|
11511
|
+
* @internal 由 Core.update() 调用,用户不应直接调用
|
|
11513
11512
|
*/
|
|
11514
11513
|
update(): void;
|
|
11515
11514
|
/**
|
|
@@ -11993,9 +11992,7 @@ declare class WorldManager implements IService {
|
|
|
11993
11992
|
/**
|
|
11994
11993
|
* @zh 更新所有活跃的World
|
|
11995
11994
|
* @en Update all active Worlds
|
|
11996
|
-
*
|
|
11997
|
-
* @zh 应该在每帧的游戏循环中调用
|
|
11998
|
-
* @en Should be called in each frame of game loop
|
|
11995
|
+
* @internal 由 Core.update() 调用,用户不应直接调用
|
|
11999
11996
|
*/
|
|
12000
11997
|
updateAll(): void;
|
|
12001
11998
|
/**
|
|
@@ -13000,6 +12997,860 @@ declare function isHidden(entityTag: number): boolean;
|
|
|
13000
12997
|
*/
|
|
13001
12998
|
declare function isLocked(entityTag: number): boolean;
|
|
13002
12999
|
|
|
13000
|
+
/**
|
|
13001
|
+
* @zh 网络同步类型定义
|
|
13002
|
+
* @en Network synchronization type definitions
|
|
13003
|
+
*/
|
|
13004
|
+
/**
|
|
13005
|
+
* @zh 支持的同步数据类型
|
|
13006
|
+
* @en Supported sync data types
|
|
13007
|
+
*/
|
|
13008
|
+
type SyncType = 'boolean' | 'int8' | 'uint8' | 'int16' | 'uint16' | 'int32' | 'uint32' | 'float32' | 'float64' | 'string';
|
|
13009
|
+
/**
|
|
13010
|
+
* @zh 同步字段元数据
|
|
13011
|
+
* @en Sync field metadata
|
|
13012
|
+
*/
|
|
13013
|
+
interface SyncFieldMetadata {
|
|
13014
|
+
/**
|
|
13015
|
+
* @zh 字段索引(用于二进制编码)
|
|
13016
|
+
* @en Field index (for binary encoding)
|
|
13017
|
+
*/
|
|
13018
|
+
index: number;
|
|
13019
|
+
/**
|
|
13020
|
+
* @zh 字段名称
|
|
13021
|
+
* @en Field name
|
|
13022
|
+
*/
|
|
13023
|
+
name: string;
|
|
13024
|
+
/**
|
|
13025
|
+
* @zh 字段类型
|
|
13026
|
+
* @en Field type
|
|
13027
|
+
*/
|
|
13028
|
+
type: SyncType;
|
|
13029
|
+
}
|
|
13030
|
+
/**
|
|
13031
|
+
* @zh 组件同步元数据
|
|
13032
|
+
* @en Component sync metadata
|
|
13033
|
+
*/
|
|
13034
|
+
interface SyncMetadata {
|
|
13035
|
+
/**
|
|
13036
|
+
* @zh 组件类型 ID
|
|
13037
|
+
* @en Component type ID
|
|
13038
|
+
*/
|
|
13039
|
+
typeId: string;
|
|
13040
|
+
/**
|
|
13041
|
+
* @zh 同步字段列表(按索引排序)
|
|
13042
|
+
* @en Sync fields list (sorted by index)
|
|
13043
|
+
*/
|
|
13044
|
+
fields: SyncFieldMetadata[];
|
|
13045
|
+
/**
|
|
13046
|
+
* @zh 字段名到索引的映射
|
|
13047
|
+
* @en Field name to index mapping
|
|
13048
|
+
*/
|
|
13049
|
+
fieldIndexMap: Map<string, number>;
|
|
13050
|
+
}
|
|
13051
|
+
/**
|
|
13052
|
+
* @zh 同步操作类型
|
|
13053
|
+
* @en Sync operation type
|
|
13054
|
+
*/
|
|
13055
|
+
declare enum SyncOperation {
|
|
13056
|
+
/**
|
|
13057
|
+
* @zh 完整快照
|
|
13058
|
+
* @en Full snapshot
|
|
13059
|
+
*/
|
|
13060
|
+
FULL = 0,
|
|
13061
|
+
/**
|
|
13062
|
+
* @zh 增量更新
|
|
13063
|
+
* @en Delta update
|
|
13064
|
+
*/
|
|
13065
|
+
DELTA = 1,
|
|
13066
|
+
/**
|
|
13067
|
+
* @zh 实体生成
|
|
13068
|
+
* @en Entity spawn
|
|
13069
|
+
*/
|
|
13070
|
+
SPAWN = 2,
|
|
13071
|
+
/**
|
|
13072
|
+
* @zh 实体销毁
|
|
13073
|
+
* @en Entity despawn
|
|
13074
|
+
*/
|
|
13075
|
+
DESPAWN = 3
|
|
13076
|
+
}
|
|
13077
|
+
/**
|
|
13078
|
+
* @zh 各类型的字节大小
|
|
13079
|
+
* @en Byte size for each type
|
|
13080
|
+
*/
|
|
13081
|
+
declare const TYPE_SIZES: Record<SyncType, number>;
|
|
13082
|
+
/**
|
|
13083
|
+
* @zh 同步元数据的 Symbol 键
|
|
13084
|
+
* @en Symbol key for sync metadata
|
|
13085
|
+
*/
|
|
13086
|
+
declare const SYNC_METADATA: unique symbol;
|
|
13087
|
+
/**
|
|
13088
|
+
* @zh 变更追踪器的 Symbol 键
|
|
13089
|
+
* @en Symbol key for change tracker
|
|
13090
|
+
*/
|
|
13091
|
+
declare const CHANGE_TRACKER: unique symbol;
|
|
13092
|
+
|
|
13093
|
+
/**
|
|
13094
|
+
* @zh 组件变更追踪器
|
|
13095
|
+
* @en Component change tracker
|
|
13096
|
+
*
|
|
13097
|
+
* @zh 用于追踪 @sync 标记字段的变更,支持增量同步
|
|
13098
|
+
* @en Tracks changes to @sync marked fields for delta synchronization
|
|
13099
|
+
*/
|
|
13100
|
+
declare class ChangeTracker {
|
|
13101
|
+
/**
|
|
13102
|
+
* @zh 脏字段索引集合
|
|
13103
|
+
* @en Set of dirty field indices
|
|
13104
|
+
*/
|
|
13105
|
+
private _dirtyFields;
|
|
13106
|
+
/**
|
|
13107
|
+
* @zh 是否有任何变更
|
|
13108
|
+
* @en Whether there are any changes
|
|
13109
|
+
*/
|
|
13110
|
+
private _hasChanges;
|
|
13111
|
+
/**
|
|
13112
|
+
* @zh 上次同步的时间戳
|
|
13113
|
+
* @en Last sync timestamp
|
|
13114
|
+
*/
|
|
13115
|
+
private _lastSyncTime;
|
|
13116
|
+
/**
|
|
13117
|
+
* @zh 标记字段为脏
|
|
13118
|
+
* @en Mark field as dirty
|
|
13119
|
+
*
|
|
13120
|
+
* @param fieldIndex - @zh 字段索引 @en Field index
|
|
13121
|
+
*/
|
|
13122
|
+
setDirty(fieldIndex: number): void;
|
|
13123
|
+
/**
|
|
13124
|
+
* @zh 检查是否有变更
|
|
13125
|
+
* @en Check if there are any changes
|
|
13126
|
+
*/
|
|
13127
|
+
hasChanges(): boolean;
|
|
13128
|
+
/**
|
|
13129
|
+
* @zh 检查特定字段是否脏
|
|
13130
|
+
* @en Check if a specific field is dirty
|
|
13131
|
+
*
|
|
13132
|
+
* @param fieldIndex - @zh 字段索引 @en Field index
|
|
13133
|
+
*/
|
|
13134
|
+
isDirty(fieldIndex: number): boolean;
|
|
13135
|
+
/**
|
|
13136
|
+
* @zh 获取所有脏字段索引
|
|
13137
|
+
* @en Get all dirty field indices
|
|
13138
|
+
*/
|
|
13139
|
+
getDirtyFields(): number[];
|
|
13140
|
+
/**
|
|
13141
|
+
* @zh 获取脏字段数量
|
|
13142
|
+
* @en Get number of dirty fields
|
|
13143
|
+
*/
|
|
13144
|
+
getDirtyCount(): number;
|
|
13145
|
+
/**
|
|
13146
|
+
* @zh 清除所有变更标记
|
|
13147
|
+
* @en Clear all change marks
|
|
13148
|
+
*/
|
|
13149
|
+
clear(): void;
|
|
13150
|
+
/**
|
|
13151
|
+
* @zh 清除特定字段的变更标记
|
|
13152
|
+
* @en Clear change mark for a specific field
|
|
13153
|
+
*
|
|
13154
|
+
* @param fieldIndex - @zh 字段索引 @en Field index
|
|
13155
|
+
*/
|
|
13156
|
+
clearField(fieldIndex: number): void;
|
|
13157
|
+
/**
|
|
13158
|
+
* @zh 获取上次同步时间
|
|
13159
|
+
* @en Get last sync time
|
|
13160
|
+
*/
|
|
13161
|
+
get lastSyncTime(): number;
|
|
13162
|
+
/**
|
|
13163
|
+
* @zh 标记所有字段为脏(用于首次同步)
|
|
13164
|
+
* @en Mark all fields as dirty (for initial sync)
|
|
13165
|
+
*
|
|
13166
|
+
* @param fieldCount - @zh 字段数量 @en Field count
|
|
13167
|
+
*/
|
|
13168
|
+
markAllDirty(fieldCount: number): void;
|
|
13169
|
+
/**
|
|
13170
|
+
* @zh 重置追踪器
|
|
13171
|
+
* @en Reset tracker
|
|
13172
|
+
*/
|
|
13173
|
+
reset(): void;
|
|
13174
|
+
}
|
|
13175
|
+
|
|
13176
|
+
/**
|
|
13177
|
+
* @zh 网络同步装饰器
|
|
13178
|
+
* @en Network synchronization decorators
|
|
13179
|
+
*
|
|
13180
|
+
* @zh 提供 @sync 装饰器,用于标记需要网络同步的 Component 字段
|
|
13181
|
+
* @en Provides @sync decorator to mark Component fields for network synchronization
|
|
13182
|
+
*/
|
|
13183
|
+
|
|
13184
|
+
/**
|
|
13185
|
+
* @zh 同步字段装饰器
|
|
13186
|
+
* @en Sync field decorator
|
|
13187
|
+
*
|
|
13188
|
+
* @zh 标记 Component 字段为可网络同步。被标记的字段会自动追踪变更,
|
|
13189
|
+
* 并在值修改时触发变更追踪器。
|
|
13190
|
+
* @en Marks a Component field for network synchronization. Marked fields
|
|
13191
|
+
* automatically track changes and trigger the change tracker on modification.
|
|
13192
|
+
*
|
|
13193
|
+
* @param type - @zh 字段的同步类型 @en Sync type of the field
|
|
13194
|
+
*
|
|
13195
|
+
* @example
|
|
13196
|
+
* ```typescript
|
|
13197
|
+
* import { Component, ECSComponent } from '@esengine/ecs-framework';
|
|
13198
|
+
* import { sync } from '@esengine/ecs-framework';
|
|
13199
|
+
*
|
|
13200
|
+
* @ECSComponent('Player')
|
|
13201
|
+
* class PlayerComponent extends Component {
|
|
13202
|
+
* @sync("string") name: string = "";
|
|
13203
|
+
* @sync("uint16") score: number = 0;
|
|
13204
|
+
* @sync("float32") x: number = 0;
|
|
13205
|
+
* @sync("float32") y: number = 0;
|
|
13206
|
+
*
|
|
13207
|
+
* // 不带 @sync 的字段不会同步
|
|
13208
|
+
* // Fields without @sync will not be synchronized
|
|
13209
|
+
* localData: any;
|
|
13210
|
+
* }
|
|
13211
|
+
* ```
|
|
13212
|
+
*/
|
|
13213
|
+
declare function sync(type: SyncType): (target: any, propertyKey: string) => void;
|
|
13214
|
+
/**
|
|
13215
|
+
* @zh 获取组件类的同步元数据
|
|
13216
|
+
* @en Get sync metadata for a component class
|
|
13217
|
+
*
|
|
13218
|
+
* @param componentClass - @zh 组件类或组件实例 @en Component class or instance
|
|
13219
|
+
* @returns @zh 同步元数据,如果不存在则返回 null @en Sync metadata, or null if not exists
|
|
13220
|
+
*/
|
|
13221
|
+
declare function getSyncMetadata(componentClass: any): SyncMetadata | null;
|
|
13222
|
+
/**
|
|
13223
|
+
* @zh 检查组件是否有同步字段
|
|
13224
|
+
* @en Check if a component has sync fields
|
|
13225
|
+
*
|
|
13226
|
+
* @param component - @zh 组件类或组件实例 @en Component class or instance
|
|
13227
|
+
* @returns @zh 如果有同步字段返回 true @en Returns true if has sync fields
|
|
13228
|
+
*/
|
|
13229
|
+
declare function hasSyncFields(component: any): boolean;
|
|
13230
|
+
/**
|
|
13231
|
+
* @zh 获取组件实例的变更追踪器
|
|
13232
|
+
* @en Get change tracker of a component instance
|
|
13233
|
+
*
|
|
13234
|
+
* @param component - @zh 组件实例 @en Component instance
|
|
13235
|
+
* @returns @zh 变更追踪器,如果不存在则返回 null @en Change tracker, or null if not exists
|
|
13236
|
+
*/
|
|
13237
|
+
declare function getChangeTracker(component: any): ChangeTracker | null;
|
|
13238
|
+
/**
|
|
13239
|
+
* @zh 为组件实例初始化变更追踪器
|
|
13240
|
+
* @en Initialize change tracker for a component instance
|
|
13241
|
+
*
|
|
13242
|
+
* @zh 这个函数应该在组件首次添加到实体时调用。
|
|
13243
|
+
* 它会创建变更追踪器并标记所有字段为脏(用于首次同步)。
|
|
13244
|
+
* @en This function should be called when a component is first added to an entity.
|
|
13245
|
+
* It creates the change tracker and marks all fields as dirty (for initial sync).
|
|
13246
|
+
*
|
|
13247
|
+
* @param component - @zh 组件实例 @en Component instance
|
|
13248
|
+
* @returns @zh 变更追踪器 @en Change tracker
|
|
13249
|
+
*/
|
|
13250
|
+
declare function initChangeTracker(component: any): ChangeTracker;
|
|
13251
|
+
/**
|
|
13252
|
+
* @zh 清除组件实例的变更标记
|
|
13253
|
+
* @en Clear change marks for a component instance
|
|
13254
|
+
*
|
|
13255
|
+
* @zh 通常在同步完成后调用,清除所有脏标记
|
|
13256
|
+
* @en Usually called after sync is complete, clears all dirty marks
|
|
13257
|
+
*
|
|
13258
|
+
* @param component - @zh 组件实例 @en Component instance
|
|
13259
|
+
*/
|
|
13260
|
+
declare function clearChanges(component: any): void;
|
|
13261
|
+
/**
|
|
13262
|
+
* @zh 检查组件是否有变更
|
|
13263
|
+
* @en Check if a component has changes
|
|
13264
|
+
*
|
|
13265
|
+
* @param component - @zh 组件实例 @en Component instance
|
|
13266
|
+
* @returns @zh 如果有变更返回 true @en Returns true if has changes
|
|
13267
|
+
*/
|
|
13268
|
+
declare function hasChanges(component: any): boolean;
|
|
13269
|
+
|
|
13270
|
+
/**
|
|
13271
|
+
* @zh 变长整数编解码
|
|
13272
|
+
* @en Variable-length integer encoding/decoding
|
|
13273
|
+
*
|
|
13274
|
+
* @zh 使用 LEB128 编码方式,可变长度编码正整数。
|
|
13275
|
+
* 小数值使用更少字节,大数值使用更多字节。
|
|
13276
|
+
* @en Uses LEB128 encoding for variable-length integer encoding.
|
|
13277
|
+
* Small values use fewer bytes, large values use more bytes.
|
|
13278
|
+
*
|
|
13279
|
+
* | 值范围 | 字节数 |
|
|
13280
|
+
* |--------|--------|
|
|
13281
|
+
* | 0-127 | 1 |
|
|
13282
|
+
* | 128-16383 | 2 |
|
|
13283
|
+
* | 16384-2097151 | 3 |
|
|
13284
|
+
* | 2097152-268435455 | 4 |
|
|
13285
|
+
* | 268435456+ | 5 |
|
|
13286
|
+
*/
|
|
13287
|
+
/**
|
|
13288
|
+
* @zh 计算变长整数所需的字节数
|
|
13289
|
+
* @en Calculate bytes needed for a varint
|
|
13290
|
+
*
|
|
13291
|
+
* @param value - @zh 整数值 @en Integer value
|
|
13292
|
+
* @returns @zh 所需字节数 @en Bytes needed
|
|
13293
|
+
*/
|
|
13294
|
+
declare function varintSize(value: number): number;
|
|
13295
|
+
/**
|
|
13296
|
+
* @zh 编码变长整数到字节数组
|
|
13297
|
+
* @en Encode varint to byte array
|
|
13298
|
+
*
|
|
13299
|
+
* @param value - @zh 要编码的整数 @en Integer to encode
|
|
13300
|
+
* @param buffer - @zh 目标缓冲区 @en Target buffer
|
|
13301
|
+
* @param offset - @zh 写入偏移 @en Write offset
|
|
13302
|
+
* @returns @zh 写入后的新偏移 @en New offset after writing
|
|
13303
|
+
*/
|
|
13304
|
+
declare function encodeVarint(value: number, buffer: Uint8Array, offset: number): number;
|
|
13305
|
+
/**
|
|
13306
|
+
* @zh 从字节数组解码变长整数
|
|
13307
|
+
* @en Decode varint from byte array
|
|
13308
|
+
*
|
|
13309
|
+
* @param buffer - @zh 源缓冲区 @en Source buffer
|
|
13310
|
+
* @param offset - @zh 读取偏移 @en Read offset
|
|
13311
|
+
* @returns @zh [解码值, 新偏移] @en [decoded value, new offset]
|
|
13312
|
+
*/
|
|
13313
|
+
declare function decodeVarint(buffer: Uint8Array, offset: number): [number, number];
|
|
13314
|
+
/**
|
|
13315
|
+
* @zh 编码有符号整数(ZigZag 编码)
|
|
13316
|
+
* @en Encode signed integer (ZigZag encoding)
|
|
13317
|
+
*
|
|
13318
|
+
* @zh ZigZag 编码将有符号整数映射到无符号整数:
|
|
13319
|
+
* 0 → 0, -1 → 1, 1 → 2, -2 → 3, 2 → 4, ...
|
|
13320
|
+
* 这样小的负数也能用较少字节表示。
|
|
13321
|
+
* @en ZigZag encoding maps signed integers to unsigned:
|
|
13322
|
+
* 0 → 0, -1 → 1, 1 → 2, -2 → 3, 2 → 4, ...
|
|
13323
|
+
* This allows small negative numbers to use fewer bytes.
|
|
13324
|
+
*
|
|
13325
|
+
* @param value - @zh 有符号整数 @en Signed integer
|
|
13326
|
+
* @returns @zh ZigZag 编码后的值 @en ZigZag encoded value
|
|
13327
|
+
*/
|
|
13328
|
+
declare function zigzagEncode(value: number): number;
|
|
13329
|
+
/**
|
|
13330
|
+
* @zh 解码有符号整数(ZigZag 解码)
|
|
13331
|
+
* @en Decode signed integer (ZigZag decoding)
|
|
13332
|
+
*
|
|
13333
|
+
* @param value - @zh ZigZag 编码的值 @en ZigZag encoded value
|
|
13334
|
+
* @returns @zh 原始有符号整数 @en Original signed integer
|
|
13335
|
+
*/
|
|
13336
|
+
declare function zigzagDecode(value: number): number;
|
|
13337
|
+
/**
|
|
13338
|
+
* @zh 编码有符号变长整数
|
|
13339
|
+
* @en Encode signed varint
|
|
13340
|
+
*
|
|
13341
|
+
* @param value - @zh 有符号整数 @en Signed integer
|
|
13342
|
+
* @param buffer - @zh 目标缓冲区 @en Target buffer
|
|
13343
|
+
* @param offset - @zh 写入偏移 @en Write offset
|
|
13344
|
+
* @returns @zh 写入后的新偏移 @en New offset after writing
|
|
13345
|
+
*/
|
|
13346
|
+
declare function encodeSignedVarint(value: number, buffer: Uint8Array, offset: number): number;
|
|
13347
|
+
/**
|
|
13348
|
+
* @zh 解码有符号变长整数
|
|
13349
|
+
* @en Decode signed varint
|
|
13350
|
+
*
|
|
13351
|
+
* @param buffer - @zh 源缓冲区 @en Source buffer
|
|
13352
|
+
* @param offset - @zh 读取偏移 @en Read offset
|
|
13353
|
+
* @returns @zh [解码值, 新偏移] @en [decoded value, new offset]
|
|
13354
|
+
*/
|
|
13355
|
+
declare function decodeSignedVarint(buffer: Uint8Array, offset: number): [number, number];
|
|
13356
|
+
|
|
13357
|
+
/**
|
|
13358
|
+
* @zh 二进制写入器
|
|
13359
|
+
* @en Binary Writer
|
|
13360
|
+
*
|
|
13361
|
+
* @zh 提供高效的二进制数据写入功能,支持自动扩容
|
|
13362
|
+
* @en Provides efficient binary data writing with auto-expansion
|
|
13363
|
+
*/
|
|
13364
|
+
/**
|
|
13365
|
+
* @zh 二进制写入器
|
|
13366
|
+
* @en Binary writer for encoding data
|
|
13367
|
+
*/
|
|
13368
|
+
declare class BinaryWriter {
|
|
13369
|
+
/**
|
|
13370
|
+
* @zh 内部缓冲区
|
|
13371
|
+
* @en Internal buffer
|
|
13372
|
+
*/
|
|
13373
|
+
private _buffer;
|
|
13374
|
+
/**
|
|
13375
|
+
* @zh DataView 用于写入数值
|
|
13376
|
+
* @en DataView for writing numbers
|
|
13377
|
+
*/
|
|
13378
|
+
private _view;
|
|
13379
|
+
/**
|
|
13380
|
+
* @zh 当前写入位置
|
|
13381
|
+
* @en Current write position
|
|
13382
|
+
*/
|
|
13383
|
+
private _offset;
|
|
13384
|
+
/**
|
|
13385
|
+
* @zh 创建二进制写入器
|
|
13386
|
+
* @en Create binary writer
|
|
13387
|
+
*
|
|
13388
|
+
* @param initialCapacity - @zh 初始容量 @en Initial capacity
|
|
13389
|
+
*/
|
|
13390
|
+
constructor(initialCapacity?: number);
|
|
13391
|
+
/**
|
|
13392
|
+
* @zh 获取当前写入位置
|
|
13393
|
+
* @en Get current write position
|
|
13394
|
+
*/
|
|
13395
|
+
get offset(): number;
|
|
13396
|
+
/**
|
|
13397
|
+
* @zh 获取写入的数据
|
|
13398
|
+
* @en Get written data
|
|
13399
|
+
*
|
|
13400
|
+
* @returns @zh 包含写入数据的 Uint8Array @en Uint8Array containing written data
|
|
13401
|
+
*/
|
|
13402
|
+
toUint8Array(): Uint8Array;
|
|
13403
|
+
/**
|
|
13404
|
+
* @zh 重置写入器(清空数据但保留缓冲区)
|
|
13405
|
+
* @en Reset writer (clear data but keep buffer)
|
|
13406
|
+
*/
|
|
13407
|
+
reset(): void;
|
|
13408
|
+
/**
|
|
13409
|
+
* @zh 确保有足够空间
|
|
13410
|
+
* @en Ensure enough space
|
|
13411
|
+
*
|
|
13412
|
+
* @param size - @zh 需要的额外字节数 @en Extra bytes needed
|
|
13413
|
+
*/
|
|
13414
|
+
private ensureCapacity;
|
|
13415
|
+
/**
|
|
13416
|
+
* @zh 写入单个字节
|
|
13417
|
+
* @en Write single byte
|
|
13418
|
+
*/
|
|
13419
|
+
writeUint8(value: number): void;
|
|
13420
|
+
/**
|
|
13421
|
+
* @zh 写入有符号字节
|
|
13422
|
+
* @en Write signed byte
|
|
13423
|
+
*/
|
|
13424
|
+
writeInt8(value: number): void;
|
|
13425
|
+
/**
|
|
13426
|
+
* @zh 写入布尔值
|
|
13427
|
+
* @en Write boolean
|
|
13428
|
+
*/
|
|
13429
|
+
writeBoolean(value: boolean): void;
|
|
13430
|
+
/**
|
|
13431
|
+
* @zh 写入 16 位无符号整数(小端序)
|
|
13432
|
+
* @en Write 16-bit unsigned integer (little-endian)
|
|
13433
|
+
*/
|
|
13434
|
+
writeUint16(value: number): void;
|
|
13435
|
+
/**
|
|
13436
|
+
* @zh 写入 16 位有符号整数(小端序)
|
|
13437
|
+
* @en Write 16-bit signed integer (little-endian)
|
|
13438
|
+
*/
|
|
13439
|
+
writeInt16(value: number): void;
|
|
13440
|
+
/**
|
|
13441
|
+
* @zh 写入 32 位无符号整数(小端序)
|
|
13442
|
+
* @en Write 32-bit unsigned integer (little-endian)
|
|
13443
|
+
*/
|
|
13444
|
+
writeUint32(value: number): void;
|
|
13445
|
+
/**
|
|
13446
|
+
* @zh 写入 32 位有符号整数(小端序)
|
|
13447
|
+
* @en Write 32-bit signed integer (little-endian)
|
|
13448
|
+
*/
|
|
13449
|
+
writeInt32(value: number): void;
|
|
13450
|
+
/**
|
|
13451
|
+
* @zh 写入 32 位浮点数(小端序)
|
|
13452
|
+
* @en Write 32-bit float (little-endian)
|
|
13453
|
+
*/
|
|
13454
|
+
writeFloat32(value: number): void;
|
|
13455
|
+
/**
|
|
13456
|
+
* @zh 写入 64 位浮点数(小端序)
|
|
13457
|
+
* @en Write 64-bit float (little-endian)
|
|
13458
|
+
*/
|
|
13459
|
+
writeFloat64(value: number): void;
|
|
13460
|
+
/**
|
|
13461
|
+
* @zh 写入变长整数
|
|
13462
|
+
* @en Write variable-length integer
|
|
13463
|
+
*/
|
|
13464
|
+
writeVarint(value: number): void;
|
|
13465
|
+
/**
|
|
13466
|
+
* @zh 写入字符串(UTF-8 编码,带长度前缀)
|
|
13467
|
+
* @en Write string (UTF-8 encoded with length prefix)
|
|
13468
|
+
*/
|
|
13469
|
+
writeString(value: string): void;
|
|
13470
|
+
/**
|
|
13471
|
+
* @zh 写入原始字节
|
|
13472
|
+
* @en Write raw bytes
|
|
13473
|
+
*/
|
|
13474
|
+
writeBytes(data: Uint8Array): void;
|
|
13475
|
+
/**
|
|
13476
|
+
* @zh 字符串转 UTF-8 字节(后备方案)
|
|
13477
|
+
* @en String to UTF-8 bytes (fallback)
|
|
13478
|
+
*/
|
|
13479
|
+
private stringToUtf8Bytes;
|
|
13480
|
+
}
|
|
13481
|
+
|
|
13482
|
+
/**
|
|
13483
|
+
* @zh 二进制读取器
|
|
13484
|
+
* @en Binary Reader
|
|
13485
|
+
*
|
|
13486
|
+
* @zh 提供高效的二进制数据读取功能
|
|
13487
|
+
* @en Provides efficient binary data reading
|
|
13488
|
+
*/
|
|
13489
|
+
/**
|
|
13490
|
+
* @zh 二进制读取器
|
|
13491
|
+
* @en Binary reader for decoding data
|
|
13492
|
+
*/
|
|
13493
|
+
declare class BinaryReader {
|
|
13494
|
+
/**
|
|
13495
|
+
* @zh 数据缓冲区
|
|
13496
|
+
* @en Data buffer
|
|
13497
|
+
*/
|
|
13498
|
+
private _buffer;
|
|
13499
|
+
/**
|
|
13500
|
+
* @zh DataView 用于读取数值
|
|
13501
|
+
* @en DataView for reading numbers
|
|
13502
|
+
*/
|
|
13503
|
+
private _view;
|
|
13504
|
+
/**
|
|
13505
|
+
* @zh 当前读取位置
|
|
13506
|
+
* @en Current read position
|
|
13507
|
+
*/
|
|
13508
|
+
private _offset;
|
|
13509
|
+
/**
|
|
13510
|
+
* @zh 创建二进制读取器
|
|
13511
|
+
* @en Create binary reader
|
|
13512
|
+
*
|
|
13513
|
+
* @param buffer - @zh 要读取的数据 @en Data to read
|
|
13514
|
+
*/
|
|
13515
|
+
constructor(buffer: Uint8Array);
|
|
13516
|
+
/**
|
|
13517
|
+
* @zh 获取当前读取位置
|
|
13518
|
+
* @en Get current read position
|
|
13519
|
+
*/
|
|
13520
|
+
get offset(): number;
|
|
13521
|
+
/**
|
|
13522
|
+
* @zh 设置读取位置
|
|
13523
|
+
* @en Set read position
|
|
13524
|
+
*/
|
|
13525
|
+
set offset(value: number);
|
|
13526
|
+
/**
|
|
13527
|
+
* @zh 获取剩余可读字节数
|
|
13528
|
+
* @en Get remaining readable bytes
|
|
13529
|
+
*/
|
|
13530
|
+
get remaining(): number;
|
|
13531
|
+
/**
|
|
13532
|
+
* @zh 检查是否有更多数据可读
|
|
13533
|
+
* @en Check if there's more data to read
|
|
13534
|
+
*/
|
|
13535
|
+
hasMore(): boolean;
|
|
13536
|
+
/**
|
|
13537
|
+
* @zh 读取单个字节
|
|
13538
|
+
* @en Read single byte
|
|
13539
|
+
*/
|
|
13540
|
+
readUint8(): number;
|
|
13541
|
+
/**
|
|
13542
|
+
* @zh 读取有符号字节
|
|
13543
|
+
* @en Read signed byte
|
|
13544
|
+
*/
|
|
13545
|
+
readInt8(): number;
|
|
13546
|
+
/**
|
|
13547
|
+
* @zh 读取布尔值
|
|
13548
|
+
* @en Read boolean
|
|
13549
|
+
*/
|
|
13550
|
+
readBoolean(): boolean;
|
|
13551
|
+
/**
|
|
13552
|
+
* @zh 读取 16 位无符号整数(小端序)
|
|
13553
|
+
* @en Read 16-bit unsigned integer (little-endian)
|
|
13554
|
+
*/
|
|
13555
|
+
readUint16(): number;
|
|
13556
|
+
/**
|
|
13557
|
+
* @zh 读取 16 位有符号整数(小端序)
|
|
13558
|
+
* @en Read 16-bit signed integer (little-endian)
|
|
13559
|
+
*/
|
|
13560
|
+
readInt16(): number;
|
|
13561
|
+
/**
|
|
13562
|
+
* @zh 读取 32 位无符号整数(小端序)
|
|
13563
|
+
* @en Read 32-bit unsigned integer (little-endian)
|
|
13564
|
+
*/
|
|
13565
|
+
readUint32(): number;
|
|
13566
|
+
/**
|
|
13567
|
+
* @zh 读取 32 位有符号整数(小端序)
|
|
13568
|
+
* @en Read 32-bit signed integer (little-endian)
|
|
13569
|
+
*/
|
|
13570
|
+
readInt32(): number;
|
|
13571
|
+
/**
|
|
13572
|
+
* @zh 读取 32 位浮点数(小端序)
|
|
13573
|
+
* @en Read 32-bit float (little-endian)
|
|
13574
|
+
*/
|
|
13575
|
+
readFloat32(): number;
|
|
13576
|
+
/**
|
|
13577
|
+
* @zh 读取 64 位浮点数(小端序)
|
|
13578
|
+
* @en Read 64-bit float (little-endian)
|
|
13579
|
+
*/
|
|
13580
|
+
readFloat64(): number;
|
|
13581
|
+
/**
|
|
13582
|
+
* @zh 读取变长整数
|
|
13583
|
+
* @en Read variable-length integer
|
|
13584
|
+
*/
|
|
13585
|
+
readVarint(): number;
|
|
13586
|
+
/**
|
|
13587
|
+
* @zh 读取字符串(UTF-8 编码,带长度前缀)
|
|
13588
|
+
* @en Read string (UTF-8 encoded with length prefix)
|
|
13589
|
+
*/
|
|
13590
|
+
readString(): string;
|
|
13591
|
+
/**
|
|
13592
|
+
* @zh 读取原始字节
|
|
13593
|
+
* @en Read raw bytes
|
|
13594
|
+
*
|
|
13595
|
+
* @param length - @zh 要读取的字节数 @en Number of bytes to read
|
|
13596
|
+
*/
|
|
13597
|
+
readBytes(length: number): Uint8Array;
|
|
13598
|
+
/**
|
|
13599
|
+
* @zh 查看下一个字节但不移动读取位置
|
|
13600
|
+
* @en Peek next byte without advancing read position
|
|
13601
|
+
*/
|
|
13602
|
+
peekUint8(): number;
|
|
13603
|
+
/**
|
|
13604
|
+
* @zh 跳过指定字节数
|
|
13605
|
+
* @en Skip specified number of bytes
|
|
13606
|
+
*/
|
|
13607
|
+
skip(count: number): void;
|
|
13608
|
+
/**
|
|
13609
|
+
* @zh 检查边界
|
|
13610
|
+
* @en Check bounds
|
|
13611
|
+
*/
|
|
13612
|
+
private checkBounds;
|
|
13613
|
+
/**
|
|
13614
|
+
* @zh UTF-8 字节转字符串(后备方案)
|
|
13615
|
+
* @en UTF-8 bytes to string (fallback)
|
|
13616
|
+
*/
|
|
13617
|
+
private utf8BytesToString;
|
|
13618
|
+
}
|
|
13619
|
+
|
|
13620
|
+
/**
|
|
13621
|
+
* @zh 组件状态编码器
|
|
13622
|
+
* @en Component state encoder
|
|
13623
|
+
*
|
|
13624
|
+
* @zh 将 ECS Component 的 @sync 字段编码为二进制格式
|
|
13625
|
+
* @en Encodes @sync fields of ECS Components to binary format
|
|
13626
|
+
*/
|
|
13627
|
+
|
|
13628
|
+
/**
|
|
13629
|
+
* @zh 编码组件的完整状态
|
|
13630
|
+
* @en Encode full state of a component
|
|
13631
|
+
*
|
|
13632
|
+
* @zh 格式: [fieldCount: varint] ([fieldIndex: uint8] [value])...
|
|
13633
|
+
* @en Format: [fieldCount: varint] ([fieldIndex: uint8] [value])...
|
|
13634
|
+
*
|
|
13635
|
+
* @param component - @zh 组件实例 @en Component instance
|
|
13636
|
+
* @param metadata - @zh 组件同步元数据 @en Component sync metadata
|
|
13637
|
+
* @param writer - @zh 二进制写入器 @en Binary writer
|
|
13638
|
+
*/
|
|
13639
|
+
declare function encodeComponentFull(component: Component, metadata: SyncMetadata, writer: BinaryWriter): void;
|
|
13640
|
+
/**
|
|
13641
|
+
* @zh 编码组件的增量状态(只编码脏字段)
|
|
13642
|
+
* @en Encode delta state of a component (only dirty fields)
|
|
13643
|
+
*
|
|
13644
|
+
* @zh 格式: [dirtyCount: varint] ([fieldIndex: uint8] [value])...
|
|
13645
|
+
* @en Format: [dirtyCount: varint] ([fieldIndex: uint8] [value])...
|
|
13646
|
+
*
|
|
13647
|
+
* @param component - @zh 组件实例 @en Component instance
|
|
13648
|
+
* @param metadata - @zh 组件同步元数据 @en Component sync metadata
|
|
13649
|
+
* @param tracker - @zh 变更追踪器 @en Change tracker
|
|
13650
|
+
* @param writer - @zh 二进制写入器 @en Binary writer
|
|
13651
|
+
* @returns @zh 是否有数据编码 @en Whether any data was encoded
|
|
13652
|
+
*/
|
|
13653
|
+
declare function encodeComponentDelta(component: Component, metadata: SyncMetadata, tracker: ChangeTracker, writer: BinaryWriter): boolean;
|
|
13654
|
+
/**
|
|
13655
|
+
* @zh 编码实体的所有同步组件
|
|
13656
|
+
* @en Encode all sync components of an entity
|
|
13657
|
+
*
|
|
13658
|
+
* @zh 格式:
|
|
13659
|
+
* [entityId: uint32]
|
|
13660
|
+
* [componentCount: varint]
|
|
13661
|
+
* ([typeIdLength: varint] [typeId: string] [componentData])...
|
|
13662
|
+
*
|
|
13663
|
+
* @en Format:
|
|
13664
|
+
* [entityId: uint32]
|
|
13665
|
+
* [componentCount: varint]
|
|
13666
|
+
* ([typeIdLength: varint] [typeId: string] [componentData])...
|
|
13667
|
+
*
|
|
13668
|
+
* @param entity - @zh 实体 @en Entity
|
|
13669
|
+
* @param writer - @zh 二进制写入器 @en Binary writer
|
|
13670
|
+
* @param deltaOnly - @zh 只编码增量 @en Only encode delta
|
|
13671
|
+
* @returns @zh 编码的组件数量 @en Number of components encoded
|
|
13672
|
+
*/
|
|
13673
|
+
declare function encodeEntity(entity: Entity, writer: BinaryWriter, deltaOnly?: boolean): number;
|
|
13674
|
+
/**
|
|
13675
|
+
* @zh 编码状态快照(多个实体)
|
|
13676
|
+
* @en Encode state snapshot (multiple entities)
|
|
13677
|
+
*
|
|
13678
|
+
* @zh 格式:
|
|
13679
|
+
* [operation: uint8] (FULL=0, DELTA=1, SPAWN=2, DESPAWN=3)
|
|
13680
|
+
* [entityCount: varint]
|
|
13681
|
+
* (entityData)...
|
|
13682
|
+
*
|
|
13683
|
+
* @en Format:
|
|
13684
|
+
* [operation: uint8] (FULL=0, DELTA=1, SPAWN=2, DESPAWN=3)
|
|
13685
|
+
* [entityCount: varint]
|
|
13686
|
+
* (entityData)...
|
|
13687
|
+
*
|
|
13688
|
+
* @param entities - @zh 要编码的实体数组 @en Entities to encode
|
|
13689
|
+
* @param operation - @zh 同步操作类型 @en Sync operation type
|
|
13690
|
+
* @returns @zh 编码后的二进制数据 @en Encoded binary data
|
|
13691
|
+
*/
|
|
13692
|
+
declare function encodeSnapshot(entities: Entity[], operation?: SyncOperation): Uint8Array;
|
|
13693
|
+
/**
|
|
13694
|
+
* @zh 编码实体生成消息
|
|
13695
|
+
* @en Encode entity spawn message
|
|
13696
|
+
*
|
|
13697
|
+
* @param entity - @zh 生成的实体 @en Spawned entity
|
|
13698
|
+
* @param prefabType - @zh 预制体类型(可选)@en Prefab type (optional)
|
|
13699
|
+
* @returns @zh 编码后的二进制数据 @en Encoded binary data
|
|
13700
|
+
*/
|
|
13701
|
+
declare function encodeSpawn(entity: Entity, prefabType?: string): Uint8Array;
|
|
13702
|
+
/**
|
|
13703
|
+
* @zh 编码实体销毁消息
|
|
13704
|
+
* @en Encode entity despawn message
|
|
13705
|
+
*
|
|
13706
|
+
* @param entityId - @zh 销毁的实体 ID @en Despawned entity ID
|
|
13707
|
+
* @returns @zh 编码后的二进制数据 @en Encoded binary data
|
|
13708
|
+
*/
|
|
13709
|
+
declare function encodeDespawn(entityId: number): Uint8Array;
|
|
13710
|
+
/**
|
|
13711
|
+
* @zh 编码批量实体销毁消息
|
|
13712
|
+
* @en Encode batch entity despawn message
|
|
13713
|
+
*
|
|
13714
|
+
* @param entityIds - @zh 销毁的实体 ID 数组 @en Despawned entity IDs
|
|
13715
|
+
* @returns @zh 编码后的二进制数据 @en Encoded binary data
|
|
13716
|
+
*/
|
|
13717
|
+
declare function encodeDespawnBatch(entityIds: number[]): Uint8Array;
|
|
13718
|
+
|
|
13719
|
+
/**
|
|
13720
|
+
* @zh 组件状态解码器
|
|
13721
|
+
* @en Component state decoder
|
|
13722
|
+
*
|
|
13723
|
+
* @zh 从二进制格式解码并应用到 ECS Component
|
|
13724
|
+
* @en Decodes binary format and applies to ECS Components
|
|
13725
|
+
*/
|
|
13726
|
+
|
|
13727
|
+
/**
|
|
13728
|
+
* @zh 解码并应用组件数据
|
|
13729
|
+
* @en Decode and apply component data
|
|
13730
|
+
*
|
|
13731
|
+
* @param component - @zh 组件实例 @en Component instance
|
|
13732
|
+
* @param metadata - @zh 组件同步元数据 @en Component sync metadata
|
|
13733
|
+
* @param reader - @zh 二进制读取器 @en Binary reader
|
|
13734
|
+
*/
|
|
13735
|
+
declare function decodeComponent(component: Component, metadata: SyncMetadata, reader: BinaryReader): void;
|
|
13736
|
+
/**
|
|
13737
|
+
* @zh 解码实体快照结果
|
|
13738
|
+
* @en Decode entity snapshot result
|
|
13739
|
+
*/
|
|
13740
|
+
interface DecodeEntityResult {
|
|
13741
|
+
/**
|
|
13742
|
+
* @zh 实体 ID
|
|
13743
|
+
* @en Entity ID
|
|
13744
|
+
*/
|
|
13745
|
+
entityId: number;
|
|
13746
|
+
/**
|
|
13747
|
+
* @zh 是否为新实体
|
|
13748
|
+
* @en Whether it's a new entity
|
|
13749
|
+
*/
|
|
13750
|
+
isNew: boolean;
|
|
13751
|
+
/**
|
|
13752
|
+
* @zh 解码的组件类型列表
|
|
13753
|
+
* @en List of decoded component types
|
|
13754
|
+
*/
|
|
13755
|
+
componentTypes: string[];
|
|
13756
|
+
}
|
|
13757
|
+
/**
|
|
13758
|
+
* @zh 解码并应用实体数据
|
|
13759
|
+
* @en Decode and apply entity data
|
|
13760
|
+
*
|
|
13761
|
+
* @param scene - @zh 场景 @en Scene
|
|
13762
|
+
* @param reader - @zh 二进制读取器 @en Binary reader
|
|
13763
|
+
* @param entityMap - @zh 实体 ID 映射(可选)@en Entity ID mapping (optional)
|
|
13764
|
+
* @returns @zh 解码结果 @en Decode result
|
|
13765
|
+
*/
|
|
13766
|
+
declare function decodeEntity(scene: Scene, reader: BinaryReader, entityMap?: Map<number, Entity>): DecodeEntityResult;
|
|
13767
|
+
/**
|
|
13768
|
+
* @zh 解码快照结果
|
|
13769
|
+
* @en Decode snapshot result
|
|
13770
|
+
*/
|
|
13771
|
+
interface DecodeSnapshotResult {
|
|
13772
|
+
/**
|
|
13773
|
+
* @zh 操作类型
|
|
13774
|
+
* @en Operation type
|
|
13775
|
+
*/
|
|
13776
|
+
operation: SyncOperation;
|
|
13777
|
+
/**
|
|
13778
|
+
* @zh 解码的实体列表
|
|
13779
|
+
* @en List of decoded entities
|
|
13780
|
+
*/
|
|
13781
|
+
entities: DecodeEntityResult[];
|
|
13782
|
+
}
|
|
13783
|
+
/**
|
|
13784
|
+
* @zh 解码状态快照
|
|
13785
|
+
* @en Decode state snapshot
|
|
13786
|
+
*
|
|
13787
|
+
* @param scene - @zh 场景 @en Scene
|
|
13788
|
+
* @param data - @zh 二进制数据 @en Binary data
|
|
13789
|
+
* @param entityMap - @zh 实体 ID 映射(可选)@en Entity ID mapping (optional)
|
|
13790
|
+
* @returns @zh 解码结果 @en Decode result
|
|
13791
|
+
*/
|
|
13792
|
+
declare function decodeSnapshot(scene: Scene, data: Uint8Array, entityMap?: Map<number, Entity>): DecodeSnapshotResult;
|
|
13793
|
+
/**
|
|
13794
|
+
* @zh 解码生成消息结果
|
|
13795
|
+
* @en Decode spawn message result
|
|
13796
|
+
*/
|
|
13797
|
+
interface DecodeSpawnResult {
|
|
13798
|
+
/**
|
|
13799
|
+
* @zh 实体
|
|
13800
|
+
* @en Entity
|
|
13801
|
+
*/
|
|
13802
|
+
entity: Entity;
|
|
13803
|
+
/**
|
|
13804
|
+
* @zh 预制体类型
|
|
13805
|
+
* @en Prefab type
|
|
13806
|
+
*/
|
|
13807
|
+
prefabType: string;
|
|
13808
|
+
/**
|
|
13809
|
+
* @zh 解码的组件类型列表
|
|
13810
|
+
* @en List of decoded component types
|
|
13811
|
+
*/
|
|
13812
|
+
componentTypes: string[];
|
|
13813
|
+
}
|
|
13814
|
+
/**
|
|
13815
|
+
* @zh 解码实体生成消息
|
|
13816
|
+
* @en Decode entity spawn message
|
|
13817
|
+
*
|
|
13818
|
+
* @param scene - @zh 场景 @en Scene
|
|
13819
|
+
* @param data - @zh 二进制数据 @en Binary data
|
|
13820
|
+
* @param entityMap - @zh 实体 ID 映射(可选)@en Entity ID mapping (optional)
|
|
13821
|
+
* @returns @zh 解码结果,如果不是 SPAWN 消息则返回 null @en Decode result, or null if not a SPAWN message
|
|
13822
|
+
*/
|
|
13823
|
+
declare function decodeSpawn(scene: Scene, data: Uint8Array, entityMap?: Map<number, Entity>): DecodeSpawnResult | null;
|
|
13824
|
+
/**
|
|
13825
|
+
* @zh 解码销毁消息结果
|
|
13826
|
+
* @en Decode despawn message result
|
|
13827
|
+
*/
|
|
13828
|
+
interface DecodeDespawnResult {
|
|
13829
|
+
/**
|
|
13830
|
+
* @zh 销毁的实体 ID 列表
|
|
13831
|
+
* @en List of despawned entity IDs
|
|
13832
|
+
*/
|
|
13833
|
+
entityIds: number[];
|
|
13834
|
+
}
|
|
13835
|
+
/**
|
|
13836
|
+
* @zh 解码实体销毁消息
|
|
13837
|
+
* @en Decode entity despawn message
|
|
13838
|
+
*
|
|
13839
|
+
* @param data - @zh 二进制数据 @en Binary data
|
|
13840
|
+
* @returns @zh 解码结果,如果不是 DESPAWN 消息则返回 null @en Decode result, or null if not a DESPAWN message
|
|
13841
|
+
*/
|
|
13842
|
+
declare function decodeDespawn(data: Uint8Array): DecodeDespawnResult | null;
|
|
13843
|
+
/**
|
|
13844
|
+
* @zh 处理销毁消息(从场景中移除实体)
|
|
13845
|
+
* @en Process despawn message (remove entities from scene)
|
|
13846
|
+
*
|
|
13847
|
+
* @param scene - @zh 场景 @en Scene
|
|
13848
|
+
* @param data - @zh 二进制数据 @en Binary data
|
|
13849
|
+
* @param entityMap - @zh 实体 ID 映射(可选)@en Entity ID mapping (optional)
|
|
13850
|
+
* @returns @zh 移除的实体 ID 列表 @en List of removed entity IDs
|
|
13851
|
+
*/
|
|
13852
|
+
declare function processDespawn(scene: Scene, data: Uint8Array, entityMap?: Map<number, Entity>): number[];
|
|
13853
|
+
|
|
13003
13854
|
type ITimer<TContext = unknown> = {
|
|
13004
13855
|
context: TContext;
|
|
13005
13856
|
/**
|
|
@@ -16261,5 +17112,5 @@ declare function getFullPlatformConfig(): Promise<any>;
|
|
|
16261
17112
|
declare function supportsFeature(feature: 'worker' | 'shared-array-buffer' | 'transferable-objects' | 'module-worker'): boolean;
|
|
16262
17113
|
declare function hasAdapter(): boolean;
|
|
16263
17114
|
|
|
16264
|
-
export { AdvancedProfilerCollector, After, AutoProfiler, Before, BinarySerializer, BitMask64Utils, Bits, COMPONENT_DEPENDENCIES, COMPONENT_EDITOR_OPTIONS, COMPONENT_TYPE_NAME, ChangeOperation, Colors, CommandBuffer, CommandType, CompiledQuery, Component, ComponentDataCollector, ComponentPool, ComponentPoolManager, ComponentRegistry, ComponentSerializer, ComponentSparseSet, ComponentStorage, ConsoleLogger, Core, CycleDependencyError, DEFAULT_PROFILER_CONFIG, DEFAULT_STAGE_ORDER, DebugConfigService, DebugManager, DebugPlugin, DeepCopy, ECSComponent, ECSEventType, ECSFluentAPI, ECSSystem, EEntityLifecyclePolicy, EMPTY_GUID, ENTITY_REF_METADATA, EVENT_TYPES, Emitter, EnableSoA, Entity, EntityDataCollector, EntityHandleManager, EntityList, EntityProcessorList, EntityRef, EntitySerializer, EntitySystem, EntityTags, EpochManager, EventBus, EventPriority, EventTypeValidator, Float32, Float64, FuncPack, GEN_BITS, GEN_MASK, GlobalComponentRegistry, GlobalEventBus, GlobalManager, HierarchyComponent, HierarchySystem, INDEX_BITS, INDEX_MASK, IdentifierPool, IgnoreSerialization, InSet, IncrementalSerializer, InjectProperty, Injectable, Int16, Int32, Int8, IntervalSystem, LogLevel, Logger, LoggerManager, MAX_ENTITIES, MAX_GENERATION, Matcher, MigrationBuilder, NULL_HANDLE, NumberExtension, PREFAB_FORMAT_VERSION, PROPERTY_METADATA, PassiveSystem, PerformanceDataCollector, PerformanceMonitor, PerformanceWarningType, PlatformDetector, PlatformManager, PlatformWorkerPool, PluginManager, PluginServiceRegistry, PluginState, Pool, PoolManager, PrefabInstanceComponent, PrefabSerializer, ProcessingSystem, Profile, ProfileCategory, ProfileClass, ProfilerSDK, Property, QuerySystem, ReactiveQuery, ReactiveQueryChangeType, ReferenceTracker, RuntimeModeService, RuntimeModeToken, SCHEDULING_METADATA, SERIALIZABLE_METADATA, SERIALIZE_FIELD, SERIALIZE_OPTIONS, SYSTEM_TYPE_NAME, Scene, SceneDataCollector, SceneManager, SceneSerializer, Serializable, SerializationContext, Serialize, SerializeArray, SerializeAsMap, SerializeAsSet, SerializeMap, SerializeSet, ServiceContainer, ServiceLifetime, SoAStorage, SparseSet, Stage, SystemDataCollector, SystemDependencyGraph, SystemScheduler, Time, Timer, TimerManager, TypeSafeEventSystem, TypeUtils, TypedEntityBuilder, TypedQueryBuilder, TypedQueryResult, Uint16, Uint32, Uint8, Uint8Clamped, Updatable, ValueSerializer, VersionMigrationManager, WebSocketManager, WorkerEntitySystem, World, WorldManager, addAndConfigure, addEntityTag, buildEntity, createECSAPI, createEditorModeService, createInstance, createLogger, createQuery, createServiceToken, createStandaloneModeService, genOf, generateGUID, getBasicWorkerConfig, getComponentDependencies, getComponentEditorOptions, getComponentInstanceEditorOptions, getComponentInstanceTypeName, getComponentTypeName, getComponents, getCurrentAdapter, getEntityRefMetadata, getEntityRefProperties, getFullPlatformConfig, getGlobalWithMiniGame, getOrAddComponent, getPerformanceWithMemory, getPropertyInjectMetadata, getPropertyMetadata, getSceneByEntityId, getSchedulingMetadata, getSerializationMetadata, getSystemInstanceMetadata, getSystemInstanceTypeName, getSystemMetadata, getSystemTypeName, getUpdatableMetadata, handleEquals, handleToString, hasAdapter, hasAnyComponent, hasComponents, hasECSComponentDecorator, hasEntityRef, hasEntityTag, hasPropertyMetadata, hasSchedulingMetadata, indexOf, injectProperties, isComponentArray, isComponentHiddenInInspector, isComponentInstanceHiddenInInspector, isComponentType, isEntityRefProperty, isFolder, isHidden, isLocked, isSerializable, isUpdatable, isValidGUID, isValidHandle, makeHandle, queryFor, queryForAll, registerInjectable, registerPlatformAdapter, removeEntityTag, requireComponent, resetLoggerColors, setGlobalLogLevel, setLoggerColors, setLoggerFactory, supportsFeature, tryGetComponent, updateComponent };
|
|
16265
|
-
export type { AnyComponentConstructor, AutoProfilerConfig, BitMask64Data, CallGraphNode, ComponentChange, ComponentConstructor, ComponentDebugInfo, ComponentEditorOptions, ComponentInstance, ComponentMigrationFunction, ComponentOptions, ComponentType, ComponentTypeMap, ComponentTypeName, ComponentTypeNames, ComponentTypeWithMetadata, DataOnly, DeepPartial, DeepReadonly, DeferredCommand, DeserializationStrategy, ECSDebugStats, EntityChange, EntityDebugInfo, EntityHandle, EntityRefMetadata, EntityRefRecord, EntityTagValue, EntityWithComponents, EnumOption, EventListenerConfig, EventStats, ExtractComponents, FieldSerializeOptions, IAdvancedProfilerData, IAlipayMiniGameAPI, IBaiduMiniGameAPI, IByteDanceMiniGameAPI, IChromeMemoryInfo, IComponent, IComponentDebugData, IComponentEventData, IComponentRegistry, IComponentTypeMetadata, ICoreConfig, IECSDebugConfig, IECSDebugData, IEntityDebugData, IEntityEventData, IEntityHierarchyNode, IEventBus, IEventData, IEventListenerConfig, IEventStats, IGlobalThisWithMiniGame, ILogger, IMiniGamePlatformAPI, IPerformanceDebugData, IPerformanceEventData, IPerformanceWithMemory, IPlatformAdapter, IPlugin, IPluginMetadata, IPoolable, IRuntimeMode, IScene, ISceneConfig, ISceneDebugData, ISceneEventData, ISceneFactory, IService, ISystemBase, ISystemDebugData, ISystemEventData, ITimer, IUpdatable, IWeChatMiniGameAPI, IWorkerPoolStatus, IWorkerSystemConfig, IWorldConfig, IWorldManagerConfig, IncrementalSerializationFormat, IncrementalSerializationOptions, IncrementalSnapshot, InjectableMetadata, InstanceTypes, LoggerColorConfig, LoggerConfig, LongTaskInfo, MemorySnapshot, MigrationFunction, PartialComponent, PerformanceData, PerformanceStats, PerformanceThresholds, PerformanceWarning, PlatformConfig, PlatformDetectionResult, PlatformWorker, PoolStats, PrefabComponentTypeEntry, PrefabCreateOptions, PrefabData, PrefabInstantiateOptions, PrefabMetadata, ProcessingMode, ProfileCounter, ProfileFrame, ProfileReport, ProfileSample, ProfileSampleStats, ProfilerConfig, PropertyAction, PropertyAssetType, PropertyControl, PropertyOptions, PropertyType, QueryResult$1 as QueryResult, ReactiveQueryChange, ReactiveQueryConfig, ReactiveQueryListener, ReadonlyComponent, RuntimeModeConfig, SampleHandle, SceneDataChange, SceneDebugInfo, SceneDeserializationOptions, SceneMigrationFunction, SceneSerializationOptions, SerializableComponent, SerializableFields, SerializableOptions, SerializableValue, SerializationFormat, SerializationMetadata, SerializedComponent, SerializedEntity, SerializedEntityRef, SerializedPrefabEntity, SerializedScene, ServiceIdentifier, ServiceToken, ServiceType, SharedArrayBufferProcessFunction, SupportedTypedArray, SystemDebugInfo, SystemDependencyInfo, SystemEntityType, SystemLifecycleHooks, SystemMetadata, SystemSchedulingMetadata, SystemStage, TypeDef as TypeHandler, TypeSafeBuilder, TypedEventHandler, TypedQueryCondition, TypedValue, UpdatableMetadata, ValidComponent, ValidComponentArray, WorkerCreationOptions, WorkerProcessFunction, WorkerSystemConfig };
|
|
17115
|
+
export { AdvancedProfilerCollector, After, AutoProfiler, Before, BinaryReader, BinarySerializer, BinaryWriter, BitMask64Utils, Bits, CHANGE_TRACKER, COMPONENT_DEPENDENCIES, COMPONENT_EDITOR_OPTIONS, COMPONENT_TYPE_NAME, ChangeOperation, ChangeTracker, Colors, CommandBuffer, CommandType, CompiledQuery, Component, ComponentDataCollector, ComponentPool, ComponentPoolManager, ComponentRegistry, ComponentSerializer, ComponentSparseSet, ComponentStorage, ConsoleLogger, Core, CycleDependencyError, DEFAULT_PROFILER_CONFIG, DEFAULT_STAGE_ORDER, DebugConfigService, DebugManager, DebugPlugin, DeepCopy, ECSComponent, ECSEventType, ECSFluentAPI, ECSSystem, EEntityLifecyclePolicy, EMPTY_GUID, ENTITY_REF_METADATA, EVENT_TYPES, Emitter, EnableSoA, Entity, EntityDataCollector, EntityHandleManager, EntityList, EntityProcessorList, EntityRef, EntitySerializer, EntitySystem, EntityTags, EpochManager, EventBus, EventPriority, EventTypeValidator, Float32, Float64, FuncPack, GEN_BITS, GEN_MASK, GlobalComponentRegistry, GlobalEventBus, GlobalManager, HierarchyComponent, HierarchySystem, INDEX_BITS, INDEX_MASK, IdentifierPool, IgnoreSerialization, InSet, IncrementalSerializer, InjectProperty, Injectable, Int16, Int32, Int8, IntervalSystem, LogLevel, Logger, LoggerManager, MAX_ENTITIES, MAX_GENERATION, Matcher, MigrationBuilder, NULL_HANDLE, NumberExtension, PREFAB_FORMAT_VERSION, PROPERTY_METADATA, PassiveSystem, PerformanceDataCollector, PerformanceMonitor, PerformanceWarningType, PlatformDetector, PlatformManager, PlatformWorkerPool, PluginManager, PluginServiceRegistry, PluginState, Pool, PoolManager, PrefabInstanceComponent, PrefabSerializer, ProcessingSystem, Profile, ProfileCategory, ProfileClass, ProfilerSDK, Property, QuerySystem, ReactiveQuery, ReactiveQueryChangeType, ReferenceTracker, RuntimeModeService, RuntimeModeToken, SCHEDULING_METADATA, SERIALIZABLE_METADATA, SERIALIZE_FIELD, SERIALIZE_OPTIONS, SYNC_METADATA, SYSTEM_TYPE_NAME, Scene, SceneDataCollector, SceneManager, SceneSerializer, Serializable, SerializationContext, Serialize, SerializeArray, SerializeAsMap, SerializeAsSet, SerializeMap, SerializeSet, ServiceContainer, ServiceLifetime, SoAStorage, SparseSet, Stage, SyncOperation, SystemDataCollector, SystemDependencyGraph, SystemScheduler, TYPE_SIZES, Time, Timer, TimerManager, TypeSafeEventSystem, TypeUtils, TypedEntityBuilder, TypedQueryBuilder, TypedQueryResult, Uint16, Uint32, Uint8, Uint8Clamped, Updatable, ValueSerializer, VersionMigrationManager, WebSocketManager, WorkerEntitySystem, World, WorldManager, addAndConfigure, addEntityTag, buildEntity, clearChanges, createECSAPI, createEditorModeService, createInstance, createLogger, createQuery, createServiceToken, createStandaloneModeService, decodeComponent, decodeDespawn, decodeEntity, decodeSignedVarint, decodeSnapshot, decodeSpawn, decodeVarint, encodeComponentDelta, encodeComponentFull, encodeDespawn, encodeDespawnBatch, encodeEntity, encodeSignedVarint, encodeSnapshot, encodeSpawn, encodeVarint, genOf, generateGUID, getBasicWorkerConfig, getChangeTracker, getComponentDependencies, getComponentEditorOptions, getComponentInstanceEditorOptions, getComponentInstanceTypeName, getComponentTypeName, getComponents, getCurrentAdapter, getEntityRefMetadata, getEntityRefProperties, getFullPlatformConfig, getGlobalWithMiniGame, getOrAddComponent, getPerformanceWithMemory, getPropertyInjectMetadata, getPropertyMetadata, getSceneByEntityId, getSchedulingMetadata, getSerializationMetadata, getSyncMetadata, getSystemInstanceMetadata, getSystemInstanceTypeName, getSystemMetadata, getSystemTypeName, getUpdatableMetadata, handleEquals, handleToString, hasAdapter, hasAnyComponent, hasChanges, hasComponents, hasECSComponentDecorator, hasEntityRef, hasEntityTag, hasPropertyMetadata, hasSchedulingMetadata, hasSyncFields, indexOf, initChangeTracker, injectProperties, isComponentArray, isComponentHiddenInInspector, isComponentInstanceHiddenInInspector, isComponentType, isEntityRefProperty, isFolder, isHidden, isLocked, isSerializable, isUpdatable, isValidGUID, isValidHandle, makeHandle, processDespawn, queryFor, queryForAll, registerInjectable, registerPlatformAdapter, removeEntityTag, requireComponent, resetLoggerColors, setGlobalLogLevel, setLoggerColors, setLoggerFactory, supportsFeature, sync, tryGetComponent, updateComponent, varintSize, zigzagDecode, zigzagEncode };
|
|
17116
|
+
export type { AnyComponentConstructor, AutoProfilerConfig, BitMask64Data, CallGraphNode, ComponentChange, ComponentConstructor, ComponentDebugInfo, ComponentEditorOptions, ComponentInstance, ComponentMigrationFunction, ComponentOptions, ComponentType, ComponentTypeMap, ComponentTypeName, ComponentTypeNames, ComponentTypeWithMetadata, DataOnly, DecodeDespawnResult, DecodeEntityResult, DecodeSnapshotResult, DecodeSpawnResult, DeepPartial, DeepReadonly, DeferredCommand, DeserializationStrategy, ECSDebugStats, EntityChange, EntityDebugInfo, EntityHandle, EntityRefMetadata, EntityRefRecord, EntityTagValue, EntityWithComponents, EnumOption, EventListenerConfig, EventStats, ExtractComponents, FieldSerializeOptions, IAdvancedProfilerData, IAlipayMiniGameAPI, IBaiduMiniGameAPI, IByteDanceMiniGameAPI, IChromeMemoryInfo, IComponent, IComponentDebugData, IComponentEventData, IComponentRegistry, IComponentTypeMetadata, ICoreConfig, IECSDebugConfig, IECSDebugData, IEntityDebugData, IEntityEventData, IEntityHierarchyNode, IEventBus, IEventData, IEventListenerConfig, IEventStats, IGlobalThisWithMiniGame, ILogger, IMiniGamePlatformAPI, IPerformanceDebugData, IPerformanceEventData, IPerformanceWithMemory, IPlatformAdapter, IPlugin, IPluginMetadata, IPoolable, IRuntimeMode, IScene, ISceneConfig, ISceneDebugData, ISceneEventData, ISceneFactory, IService, ISystemBase, ISystemDebugData, ISystemEventData, ITimer, IUpdatable, IWeChatMiniGameAPI, IWorkerPoolStatus, IWorkerSystemConfig, IWorldConfig, IWorldManagerConfig, IncrementalSerializationFormat, IncrementalSerializationOptions, IncrementalSnapshot, InjectableMetadata, InstanceTypes, LoggerColorConfig, LoggerConfig, LongTaskInfo, MemorySnapshot, MigrationFunction, PartialComponent, PerformanceData, PerformanceStats, PerformanceThresholds, PerformanceWarning, PlatformConfig, PlatformDetectionResult, PlatformWorker, PoolStats, PrefabComponentTypeEntry, PrefabCreateOptions, PrefabData, PrefabInstantiateOptions, PrefabMetadata, ProcessingMode, ProfileCounter, ProfileFrame, ProfileReport, ProfileSample, ProfileSampleStats, ProfilerConfig, PropertyAction, PropertyAssetType, PropertyControl, PropertyOptions, PropertyType, QueryResult$1 as QueryResult, ReactiveQueryChange, ReactiveQueryConfig, ReactiveQueryListener, ReadonlyComponent, RuntimeModeConfig, SampleHandle, SceneDataChange, SceneDebugInfo, SceneDeserializationOptions, SceneMigrationFunction, SceneSerializationOptions, SerializableComponent, SerializableFields, SerializableOptions, SerializableValue, SerializationFormat, SerializationMetadata, SerializedComponent, SerializedEntity, SerializedEntityRef, SerializedPrefabEntity, SerializedScene, ServiceIdentifier, ServiceToken, ServiceType, SharedArrayBufferProcessFunction, SupportedTypedArray, SyncFieldMetadata, SyncMetadata, SyncType, SystemDebugInfo, SystemDependencyInfo, SystemEntityType, SystemLifecycleHooks, SystemMetadata, SystemSchedulingMetadata, SystemStage, TypeDef as TypeHandler, TypeSafeBuilder, TypedEventHandler, TypedQueryCondition, TypedValue, UpdatableMetadata, ValidComponent, ValidComponentArray, WorkerCreationOptions, WorkerProcessFunction, WorkerSystemConfig };
|