修复动态require导致的跨平台错误
新增emitter的dispose方法用于清理事件 启用composite增量编译
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { IComponentDebugData } from '../../Types';
|
||||
import { Core } from '../../Core';
|
||||
import { ComponentPoolManager } from '../../ECS/Core/ComponentPool';
|
||||
|
||||
/**
|
||||
* 组件数据收集器
|
||||
@@ -49,7 +50,6 @@ export class ComponentDataCollector {
|
||||
let poolSizes = new Map<string, number>();
|
||||
|
||||
try {
|
||||
const { ComponentPoolManager } = require('../../ECS/Core/ComponentPool');
|
||||
const poolManager = ComponentPoolManager.getInstance();
|
||||
const poolStats = poolManager.getPoolStats();
|
||||
const utilizations = poolManager.getPoolUtilization();
|
||||
|
||||
@@ -7,6 +7,8 @@ import { SceneDataCollector } from './SceneDataCollector';
|
||||
import { WebSocketManager } from './WebSocketManager';
|
||||
import { Core } from '../../Core';
|
||||
import { Component } from '../../ECS/Component';
|
||||
import { ComponentPoolManager } from '../../ECS/Core/ComponentPool';
|
||||
import { Pool } from '../../Utils/Pool';
|
||||
|
||||
/**
|
||||
* 调试管理器
|
||||
@@ -639,7 +641,6 @@ export class DebugManager {
|
||||
|
||||
try {
|
||||
// 尝试获取组件池统计
|
||||
const { ComponentPoolManager } = require('../../ECS/Core/ComponentPool');
|
||||
const poolManager = ComponentPoolManager.getInstance();
|
||||
const poolStats = poolManager.getPoolStats();
|
||||
|
||||
@@ -662,8 +663,7 @@ export class DebugManager {
|
||||
|
||||
try {
|
||||
// 尝试获取通用对象池统计
|
||||
const { Pool } = require('../../Utils/Pool');
|
||||
const poolStats = Pool.getStats();
|
||||
const poolStats = Pool.getAllPoolStats();
|
||||
|
||||
for (const [typeName, stats] of Object.entries(poolStats)) {
|
||||
const poolData = stats as {
|
||||
|
||||
@@ -2,6 +2,7 @@ import { IEntityDebugData } from '../../Types';
|
||||
import { Core } from '../../Core';
|
||||
import { Entity } from '../../ECS/Entity';
|
||||
import { Component } from '../../ECS/Component';
|
||||
import { ComponentTypeManager } from '../../ECS/Utils/ComponentTypeManager';
|
||||
|
||||
/**
|
||||
* 实体数据收集器
|
||||
@@ -712,7 +713,6 @@ export class EntityDataCollector {
|
||||
|
||||
if (!typeName || typeName === 'Object' || typeName === 'Function') {
|
||||
try {
|
||||
const { ComponentTypeManager } = require('../../ECS/Utils/ComponentTypeManager');
|
||||
const typeManager = ComponentTypeManager.instance;
|
||||
const componentType = component.constructor as any;
|
||||
const typeId = typeManager.getTypeId(componentType);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { IPerformanceDebugData } from '../../Types';
|
||||
import { Time } from '../Time';
|
||||
import { Core } from '../../Core';
|
||||
|
||||
/**
|
||||
* 性能数据收集器
|
||||
@@ -64,7 +65,6 @@ export class PerformanceDataCollector {
|
||||
if (!performanceMonitor) {
|
||||
// 尝试从Core实例获取性能监视器
|
||||
try {
|
||||
const { Core } = require('../../Core');
|
||||
const coreInstance = Core.Instance;
|
||||
if (coreInstance && (coreInstance as any)._performanceMonitor) {
|
||||
performanceMonitor = (coreInstance as any)._performanceMonitor;
|
||||
|
||||
@@ -78,4 +78,39 @@ export class Emitter<T, TContext = unknown> {
|
||||
let list = this._messageTable.get(eventType);
|
||||
return list ? list.some(observer => observer.func === handler) : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 移除指定事件类型的所有监听器
|
||||
* @param eventType 事件类型
|
||||
*/
|
||||
public removeAllObservers(eventType?: T): void {
|
||||
if (eventType !== undefined) {
|
||||
this._messageTable.delete(eventType);
|
||||
} else {
|
||||
this._messageTable.clear();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 释放所有资源,清理所有监听器
|
||||
*/
|
||||
public dispose(): void {
|
||||
this._messageTable.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取事件类型数量
|
||||
*/
|
||||
public getEventTypeCount(): number {
|
||||
return this._messageTable.size;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取指定事件类型的监听器数量
|
||||
* @param eventType 事件类型
|
||||
*/
|
||||
public getObserverCount(eventType: T): number {
|
||||
const list = this._messageTable.get(eventType);
|
||||
return list ? list.length : 0;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user