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
@@ -5,6 +5,7 @@ describe("WarshipSelectionController", () => {
let game: any;
let eventBus: any;
let transformHandler: any;
let view: any;
beforeEach(() => {
game = {
@@ -26,11 +27,18 @@ describe("WarshipSelectionController", () => {
};
eventBus = { on: vi.fn() };
transformHandler = {};
view = { setSelectedUnits: vi.fn() };
});
it("tracks the selected unit on single-unit selection (rendering is WebGL)", () => {
const ui = new WarshipSelectionController(game, eventBus, transformHandler);
const ui = new WarshipSelectionController(
game,
eventBus,
transformHandler,
view,
);
const unit = {
id: () => 1,
type: () => "Warship",
isActive: () => true,
tile: () => ({}),
@@ -45,8 +53,14 @@ describe("WarshipSelectionController", () => {
});
it("clears selection on deselect", () => {
const ui = new WarshipSelectionController(game, eventBus, transformHandler);
const ui = new WarshipSelectionController(
game,
eventBus,
transformHandler,
view,
);
const unit = {
id: () => 1,
type: () => "Warship",
isActive: () => true,
tile: () => ({}),
@@ -61,7 +75,12 @@ describe("WarshipSelectionController", () => {
});
it("tracks multi-selection list", () => {
const ui = new WarshipSelectionController(game, eventBus, transformHandler);
const ui = new WarshipSelectionController(
game,
eventBus,
transformHandler,
view,
);
const units = [
{ id: () => 1, isActive: () => true },
{ id: () => 2, isActive: () => true },