controllers push to the WebGL view directly, drop ClientGameRunner relays

BuildPreviewController and WarshipSelectionController now take the WebGL
view in their constructor and call view.updateGhostPreview /
view.setSelectedUnits themselves instead of emitting bus events that
ClientGameRunner forwarded. Splits the old mountWebGLDebugRenderer in
two — createWebGLView builds the view up front so the renderer can wire
controllers to it, mountWebGLDebugRenderer does the per-frame plumbing
after the transformHandler exists. GhostPreviewUpdatedEvent had no
remaining consumers and is removed.
This commit is contained in:
evanpelle
2026-05-16 22:58:31 -07:00
parent a708a8c984
commit 7b1557b886
6 changed files with 81 additions and 65 deletions
@@ -16,6 +16,7 @@ import {
WarshipSelectionBoxCompleteEvent,
WarshipSelectionBoxUpdateEvent,
} from "../InputHandler";
import { GameView as WebGLGameView } from "../render/gl";
import { MoveWarshipIntentEvent } from "../Transport";
const WARSHIP_SELECTION_RADIUS = 10;
@@ -47,6 +48,7 @@ export class WarshipSelectionController implements Controller {
private game: GameView,
private eventBus: EventBus,
private transformHandler: TransformHandler,
private view: WebGLGameView,
) {}
tick() {
@@ -295,17 +297,20 @@ export class WarshipSelectionController implements Controller {
* When event.isSelected is false it clears all selection state.
*/
private onUnitSelection(event: UnitSelectionEvent) {
// Selection box visuals are drawn by the WebGL SelectionBoxPass; this
// method just tracks selection state for the click-handler logic.
this.multiSelectedWarships = [];
this.selectedUnit = null;
if (!event.isSelected) return;
if (!event.isSelected) {
this.view.setSelectedUnits([]);
return;
}
if ((event.units ?? []).length > 0) {
this.multiSelectedWarships = event.units;
this.view.setSelectedUnits(event.units.map((u) => u.id()));
} else {
this.selectedUnit = event.unit;
this.view.setSelectedUnits(event.unit ? [event.unit.id()] : []);
}
}
}