mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-07-11 00:04:14 +00:00
move single-unit warship selection box to WebGL SelectionBoxPass
UnitSelectionEvent now forwards to view.setSelectedUnit(unit.id()) in mountWebGLDebugRenderer; the renderer's SelectionBoxPass draws the animated stippled outline on the GPU. UILayer still tracks selectedUnit for game-logic readers (the click handlers) but no longer paints to canvas2D for it. Drops drawSelectionBox + lastSelectionBoxCenter (~50 LOC) plus the per-tick single-unit redraw in tick(). Multi-selection stays on canvas2D — SelectionBoxPass is single-unit only. Test update: replaces the now-dead drawSelectionBox spy with a selectedUnit state assertion + a deselect case.
This commit is contained in:
@@ -43,6 +43,7 @@ import {
|
||||
MouseMoveEvent,
|
||||
MouseUpEvent,
|
||||
TickMetricsEvent,
|
||||
UnitSelectionEvent,
|
||||
} from "./InputHandler";
|
||||
import { endGame, startGame, startTime } from "./LocalPersistantStats";
|
||||
import { terrainMapFileLoader } from "./TerrainMapFileLoader";
|
||||
@@ -345,6 +346,23 @@ function mountWebGLDebugRenderer(
|
||||
view.showMoveIndicator(tx, ty, firstUnit.owner().smallID());
|
||||
});
|
||||
|
||||
// Single-unit warship selection box: forward UnitSelectionEvent to the
|
||||
// renderer's SelectionBoxPass. Multi-selection (event.units.length > 0)
|
||||
// stays canvas2D for now — SelectionBoxPass only supports one unit.
|
||||
eventBus.on(UnitSelectionEvent, (e) => {
|
||||
if (!e.isSelected) {
|
||||
view.setSelectedUnit(null);
|
||||
return;
|
||||
}
|
||||
if ((e.units ?? []).length > 0) {
|
||||
// Multi-selection: drop any prior single highlight; canvas2D draws
|
||||
// the multi outlines in UILayer.
|
||||
view.setSelectedUnit(null);
|
||||
return;
|
||||
}
|
||||
view.setSelectedUnit(e.unit?.id() ?? null);
|
||||
});
|
||||
|
||||
return { builder: new WebGLFrameBuilder(view), syncCamera };
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user