From 03229ffb5991501c42550701799e67882ca37928 Mon Sep 17 00:00:00 2001 From: yhh <359807859@qq.com> Date: Tue, 16 Dec 2025 11:11:48 +0800 Subject: [PATCH] =?UTF-8?q?refactor(engine-core):=20=E6=94=B9=E8=BF=9B?= =?UTF-8?q?=E6=8F=92=E4=BB=B6=E6=9C=8D=E5=8A=A1=E6=B3=A8=E5=86=8C=E6=9C=BA?= =?UTF-8?q?=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 更新 IComponentRegistry 类型引用 - 优化 PluginServiceRegistry 服务管理 --- packages/engine-core/src/EnginePlugin.ts | 6 +-- .../engine-core/src/PluginServiceRegistry.ts | 52 +++++++++++++++++++ 2 files changed, 55 insertions(+), 3 deletions(-) diff --git a/packages/engine-core/src/EnginePlugin.ts b/packages/engine-core/src/EnginePlugin.ts index 9e7e67cc..89aecdd2 100644 --- a/packages/engine-core/src/EnginePlugin.ts +++ b/packages/engine-core/src/EnginePlugin.ts @@ -11,7 +11,7 @@ * @see docs/architecture/plugin-system-design.md */ -import type { ComponentRegistry as ComponentRegistryType, IScene, ServiceContainer } from '@esengine/ecs-framework'; +import type { IComponentRegistry, IScene, ServiceContainer } from '@esengine/ecs-framework'; import { PluginServiceRegistry } from '@esengine/ecs-framework'; import { TransformComponent } from './TransformComponent'; import type { ModuleManifest } from './ModuleManifest'; @@ -105,7 +105,7 @@ export interface IRuntimeModule { * 注册组件到 ComponentRegistry * Register components to ComponentRegistry */ - registerComponents?(registry: typeof ComponentRegistryType): void; + registerComponents?(registry: IComponentRegistry): void; /** * 注册服务到 ServiceContainer @@ -192,7 +192,7 @@ export type IPlugin = IRuntimePlugin; // ============================================================================ class EngineRuntimeModule implements IRuntimeModule { - registerComponents(registry: typeof ComponentRegistryType): void { + registerComponents(registry: IComponentRegistry): void { registry.register(TransformComponent); } } diff --git a/packages/engine-core/src/PluginServiceRegistry.ts b/packages/engine-core/src/PluginServiceRegistry.ts index 38be3310..c1423378 100644 --- a/packages/engine-core/src/PluginServiceRegistry.ts +++ b/packages/engine-core/src/PluginServiceRegistry.ts @@ -65,6 +65,58 @@ export interface IEngineBridge { * Set clear color */ setClearColor(r: number, g: number, b: number, a: number): void; + + // ===== Texture State API (Optional) ===== + // ===== 纹理状态 API(可选)===== + + /** + * 获取纹理加载状态 + * Get texture loading state + * + * @param id 纹理 ID | Texture ID + * @returns 状态字符串: 'loading', 'ready', 或 'failed:reason' + * State string: 'loading', 'ready', or 'failed:reason' + */ + getTextureState?(id: number): string; + + /** + * 检查纹理是否就绪 + * Check if texture is ready for rendering + * + * @param id 纹理 ID | Texture ID + * @returns 纹理数据已加载则返回 true | true if texture data is loaded + */ + isTextureReady?(id: number): boolean; + + /** + * 获取正在加载的纹理数量 + * Get count of textures currently loading + * + * @returns 处于加载状态的纹理数量 | Number of textures in loading state + */ + getTextureLoadingCount?(): number; + + /** + * 异步加载纹理(等待完成) + * Load texture asynchronously (wait for completion) + * + * 与 loadTexture 不同,此方法会等待纹理实际加载完成。 + * Unlike loadTexture, this method waits until texture is actually loaded. + * + * @param id 纹理 ID | Texture ID + * @param url 图片 URL | Image URL + * @returns 纹理就绪时解析的 Promise | Promise that resolves when texture is ready + */ + loadTextureAsync?(id: number, url: string): Promise; + + /** + * 等待所有加载中的纹理完成 + * Wait for all loading textures to complete + * + * @param timeout 最大等待时间(毫秒,默认30000)| Max wait time in ms (default 30000) + * @returns 所有纹理加载完成时解析 | Resolves when all textures are loaded + */ + waitForAllTextures?(timeout?: number): Promise; } /**