MCPcopy Create free account
hub / github.com/esengine/esengine / lateUpdate

Function lateUpdate

packages/core/src/ECS/Systems/EntitySystem.ts:826–853  ·  view source on GitHub ↗

* 后期更新系统 * * lateUpdate 复用 update 中 onCheckProcessing() 的结果, * 避免 IntervalSystem 等子类的副作用被重复执行。 * * lateUpdate reuses the onCheckProcessing() result from update, * preventing side effects in subclasses like IntervalSystem from executing repeatedly.

()

Source from the content-addressed store, hash-verified

824 * preventing side effects in subclasses like IntervalSystem from executing repeatedly.
825 */
826 public lateUpdate(): void {
827 // 复用 update() 中的检查结果,不再调用 onCheckProcessing()
828 // Reuse check result from update(), don't call onCheckProcessing() again
829 if (!this._shouldProcessThisFrame) {
830 return;
831 }
832
833 const monitor = this.getPerformanceMonitor();
834 const startTime = monitor.startMonitoring(`${this._systemName}_Late`);
835 let entityCount = 0;
836
837 try {
838 // 重新查询实体以获取最新列表
839 // 在 update 和 lateUpdate 之间可能有新组件被添加(事件驱动设计)
840 // Re-query entities to get the latest list
841 // New components may have been added between update and lateUpdate (event-driven design)
842 // ReactiveQuery.getEntities() 返回的是安全快照,只在实体变化时才创建新数组
843 const entities = this.queryEntities();
844 this._entityCache.setFrame(entities);
845 entityCount = entities.length;
846 this.lateProcess(entities);
847 this.onEnd();
848 } finally {
849 monitor.endMonitoring(`${this._systemName}_Late`, startTime, entityCount);
850 // 清理帧缓存
851 this._entityCache.clearFrame();
852 }
853 }
854
855 /**
856 * 执行命令缓冲区中的所有延迟命令

Callers

nothing calls this directly

Calls 7

startMonitoringMethod · 0.45
queryEntitiesMethod · 0.45
setFrameMethod · 0.45
lateProcessMethod · 0.45
onEndMethod · 0.45
endMonitoringMethod · 0.45
clearFrameMethod · 0.45

Tested by

no test coverage detected