mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-07-16 16:52:34 +00:00
The render/ tree was the only place in the client still using kebab-case filenames. Brings ~80 files in line with the rest of src/client/ (BuildPreviewController, TransformHandler, etc.). Directories kept as they were (name-pass/, fx-pass/, passes/, utils/, debug/) since the codebase already mixes those. Two collisions surfaced and got resolved: render/types/ is a directory, not a file, so its imports kept the lowercase form; and the sed pass incidentally normalized core/pathfinding imports, which had to be reverted since that file is actually lowercase on disk despite some imports having referenced it as ./Types under macOS case-insensitive resolution.
45 lines
1.6 KiB
TypeScript
45 lines
1.6 KiB
TypeScript
/**
|
|
* HoverHighlightController — pushes the cursor's tile-owner to the WebGL
|
|
* view so the territory + border passes can highlight the hovered player.
|
|
*
|
|
* Replaces the hover path inside the renderer's MapInteraction class (which
|
|
* was bound to the WebGL canvas; that canvas has pointer-events: none in the
|
|
* current input architecture so its listeners never fired). All input flows
|
|
* through InputHandler → MouseMoveEvent on the EventBus, so we just listen.
|
|
*/
|
|
|
|
import { EventBus } from "../../core/EventBus";
|
|
import { GameView } from "../../core/game/GameView";
|
|
import { Controller } from "../Controller";
|
|
import { MouseMoveEvent } from "../InputHandler";
|
|
import { GameView as WebGLGameView } from "../render/gl";
|
|
import { OWNER_MASK } from "../render/gl/utils/TileCodec";
|
|
import { TransformHandler } from "../TransformHandler";
|
|
|
|
export class HoverHighlightController implements Controller {
|
|
private lastOwnerID = 0;
|
|
|
|
constructor(
|
|
private game: GameView,
|
|
private eventBus: EventBus,
|
|
private transformHandler: TransformHandler,
|
|
private view: WebGLGameView,
|
|
) {}
|
|
|
|
init() {
|
|
this.eventBus.on(MouseMoveEvent, (e) => this.onMouseMove(e));
|
|
}
|
|
|
|
private onMouseMove(e: MouseMoveEvent): void {
|
|
const cell = this.transformHandler.screenToWorldCoordinates(e.x, e.y);
|
|
let ownerID = 0;
|
|
if (this.game.isValidCoord(cell.x, cell.y)) {
|
|
const ref = this.game.ref(cell.x, cell.y);
|
|
ownerID = this.game.tileState(ref) & OWNER_MASK;
|
|
}
|
|
if (ownerID === this.lastOwnerID) return;
|
|
this.lastOwnerID = ownerID;
|
|
this.view.setHighlightOwner(ownerID);
|
|
}
|
|
}
|