fix(sync): use GlobalComponentRegistry for network sync decoding (#392)
- Decoder.ts now uses GlobalComponentRegistry.getComponentType() instead of local registry - @sync decorator uses getComponentTypeName() to get @ECSComponent decorator name - @ECSComponent decorator updates SYNC_METADATA.typeId when defined - Removed deprecated registerSyncComponent/autoRegisterSyncComponent functions - Updated ComponentSync.ts in network package to use GlobalComponentRegistry - Updated tests to use correct @ECSComponent type names This ensures that components decorated with @ECSComponent are automatically available for network sync decoding without any manual registration.
This commit is contained in:
@@ -23,7 +23,7 @@ import {
|
||||
decodeSnapshot,
|
||||
decodeSpawn,
|
||||
processDespawn,
|
||||
registerSyncComponent,
|
||||
GlobalComponentRegistry,
|
||||
type DecodeSnapshotResult,
|
||||
type DecodeSpawnResult,
|
||||
} from '@esengine/ecs-framework';
|
||||
@@ -166,10 +166,7 @@ export class ComponentSyncSystem extends EntitySystem {
|
||||
* @en Client needs to call this to register all component types to be synced
|
||||
*/
|
||||
public registerComponent<T extends new () => any>(componentClass: T): void {
|
||||
const metadata: SyncMetadata | undefined = (componentClass as any)[SYNC_METADATA];
|
||||
if (metadata) {
|
||||
registerSyncComponent(metadata.typeId, componentClass as any);
|
||||
}
|
||||
GlobalComponentRegistry.register(componentClass as any);
|
||||
}
|
||||
|
||||
// =========================================================================
|
||||
|
||||
Reference in New Issue
Block a user