Feature/physics and tilemap enhancement (#247)
* feat(behavior-tree,tilemap): 修复编辑器连线缩放问题并增强插件系统 * feat(node-editor,blueprint): 新增通用节点编辑器和蓝图可视化脚本系统 * feat(editor,tilemap): 优化编辑器UI样式和Tilemap编辑器功能 * fix: 修复CodeQL安全警告和CI类型检查错误 * fix: 修复CodeQL安全警告和CI类型检查错误 * fix: 修复CodeQL安全警告和CI类型检查错误
This commit is contained in:
@@ -47,6 +47,13 @@ export interface IRuntimeModuleLoader {
|
||||
*/
|
||||
createSystems?(scene: IScene, context: SystemContext): void;
|
||||
|
||||
/**
|
||||
* 所有系统创建完成后调用
|
||||
* 用于处理跨插件的系统依赖关系
|
||||
* Called after all systems are created, used for cross-plugin system dependencies
|
||||
*/
|
||||
onSystemsCreated?(scene: IScene, context: SystemContext): void;
|
||||
|
||||
/**
|
||||
* 模块初始化完成回调
|
||||
* Module initialization complete callback
|
||||
@@ -338,6 +345,9 @@ export interface IPluginLoader {
|
||||
/**
|
||||
* 文件创建模板
|
||||
* File creation template
|
||||
*
|
||||
* 插件通过 getContent 提供文件内容,编辑器负责写入文件。
|
||||
* 这样可以避免插件直接访问文件系统带来的权限问题。
|
||||
*/
|
||||
export interface FileCreationTemplate {
|
||||
/** 模板ID | Template ID */
|
||||
@@ -350,6 +360,10 @@ export interface FileCreationTemplate {
|
||||
icon?: string;
|
||||
/** 分类 | Category */
|
||||
category?: string;
|
||||
/** 创建函数 | Create function */
|
||||
create: (filePath: string) => Promise<void>;
|
||||
/**
|
||||
* 获取文件内容 | Get file content
|
||||
* @param fileName 文件名(不含路径,含扩展名)
|
||||
* @returns 文件内容字符串
|
||||
*/
|
||||
getContent: (fileName: string) => string | Promise<string>;
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ export type PluginCategory =
|
||||
| 'audio' // 音频系统 | Audio
|
||||
| 'networking' // 网络功能 | Networking
|
||||
| 'tools' // 工具/编辑器扩展 | Tools/Editor extensions
|
||||
| 'scripting' // 脚本/蓝图 | Scripting/Blueprint
|
||||
| 'content'; // 内容/资源 | Content/Assets
|
||||
|
||||
/**
|
||||
|
||||
@@ -331,16 +331,22 @@ export class PluginManager implements IService {
|
||||
*/
|
||||
createSystemsForScene(scene: IScene, context: SystemContext): void {
|
||||
logger.info('Creating systems for scene...');
|
||||
console.log('[PluginManager] createSystemsForScene called, context.assetManager:', context.assetManager ? 'exists' : 'null');
|
||||
|
||||
const sortedPlugins = this.sortByLoadingPhase('runtime');
|
||||
console.log('[PluginManager] Sorted plugins for runtime:', sortedPlugins);
|
||||
|
||||
// 第一阶段:创建所有系统
|
||||
// Phase 1: Create all systems
|
||||
for (const pluginId of sortedPlugins) {
|
||||
const plugin = this.plugins.get(pluginId);
|
||||
console.log(`[PluginManager] Plugin ${pluginId}: enabled=${plugin?.enabled}, state=${plugin?.state}, hasRuntimeModule=${!!plugin?.loader.runtimeModule}`);
|
||||
if (!plugin?.enabled || plugin.state === 'error') continue;
|
||||
|
||||
const runtimeModule = plugin.loader.runtimeModule;
|
||||
if (runtimeModule?.createSystems) {
|
||||
try {
|
||||
console.log(`[PluginManager] Calling createSystems for: ${pluginId}`);
|
||||
runtimeModule.createSystems(scene, context);
|
||||
logger.debug(`Systems created for: ${pluginId}`);
|
||||
} catch (e) {
|
||||
@@ -349,6 +355,23 @@ export class PluginManager implements IService {
|
||||
}
|
||||
}
|
||||
|
||||
// 第二阶段:系统创建完成后的回调(用于跨插件依赖连接)
|
||||
// Phase 2: Post-creation callbacks (for cross-plugin dependency wiring)
|
||||
for (const pluginId of sortedPlugins) {
|
||||
const plugin = this.plugins.get(pluginId);
|
||||
if (!plugin?.enabled || plugin.state === 'error') continue;
|
||||
|
||||
const runtimeModule = plugin.loader.runtimeModule;
|
||||
if (runtimeModule?.onSystemsCreated) {
|
||||
try {
|
||||
runtimeModule.onSystemsCreated(scene, context);
|
||||
logger.debug(`Systems wired for: ${pluginId}`);
|
||||
} catch (e) {
|
||||
logger.error(`Failed to wire systems for ${pluginId}:`, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
logger.info('Systems created for scene');
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user