(entities: readonly Entity[])
| 105 | } |
| 106 | |
| 107 | protected override process(entities: readonly Entity[]): void { |
| 108 | // 处理延迟销毁 | Process delayed destruction |
| 109 | if (this._entitiesToDestroy.length > 0 && this.scene) { |
| 110 | this.scene.destroyEntities(this._entitiesToDestroy); |
| 111 | this._entitiesToDestroy = []; |
| 112 | } |
| 113 | |
| 114 | for (const entity of entities) { |
| 115 | const clickFx = entity.getComponent(ClickFxComponent); |
| 116 | if (!clickFx || !clickFx.fxEnabled) continue; |
| 117 | |
| 118 | // 清理过期的特效 | Clean up expired effects |
| 119 | this._cleanupExpiredEffects(clickFx); |
| 120 | |
| 121 | // 检查触发条件 | Check trigger conditions |
| 122 | const triggered = this._checkTrigger(clickFx); |
| 123 | if (!triggered) continue; |
| 124 | |
| 125 | // 检查是否可以添加新特效 | Check if can add new effect |
| 126 | if (!clickFx.canAddEffect()) continue; |
| 127 | |
| 128 | // 获取点击/触摸位置 | Get click/touch position |
| 129 | const screenPos = this._getInputPosition(clickFx); |
| 130 | if (!screenPos) continue; |
| 131 | |
| 132 | // 转换为 canvas 相对坐标 | Convert to canvas-relative coordinates |
| 133 | const canvasPos = this._windowToCanvas(screenPos.x, screenPos.y); |
| 134 | |
| 135 | // 应用偏移 | Apply offset |
| 136 | canvasPos.x += clickFx.positionOffset.x; |
| 137 | canvasPos.y += clickFx.positionOffset.y; |
| 138 | |
| 139 | // 创建粒子效果(使用屏幕空间坐标) |
| 140 | // Create particle effect (using screen space coordinates) |
| 141 | this._spawnEffect(clickFx, canvasPos.x, canvasPos.y); |
| 142 | } |
| 143 | } |
| 144 | |
| 145 | /** |
| 146 | * 窗口坐标转 canvas 相对坐标 |
nothing calls this directly
no test coverage detected