Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
46e713b
v1-dev
scamiv Jan 9, 2026
5ffb90d
Enhance TerritoryLayer with palette signature management
scamiv Jan 9, 2026
62345fc
Implement tile transition effects in TerritoryLayer
scamiv Jan 9, 2026
ddd42fe
Removed the CanvasTerritoryRenderer and related logic
scamiv Jan 9, 2026
fda0b99
Refactor TerritoryLayer and TerritoryWebGLRenderer for enhanced trans…
scamiv Jan 9, 2026
48c369d
Remove redundant handling
scamiv Jan 9, 2026
0dfb903
Reused the quick‑info hover logic so territory highlighting now follo…
scamiv Jan 9, 2026
12be751
Refactor TerritoryLayer and TerritoryWebGLRenderer for contest manage…
scamiv Jan 10, 2026
4504c7b
Update contest duration
scamiv Jan 10, 2026
96efe97
Implemented full‑res JFA smoothing for territory ownership changes an…
scamiv Jan 10, 2026
cc189f7
Refactor TerritoryLayer and TerritoryWebGLRenderer for improved smoot…
scamiv Jan 10, 2026
6369e70
double-jfa distance smoothing
scamiv Jan 10, 2026
f31850f
minor cleanup
scamiv Jan 10, 2026
3c1d313
Enhance TerritoryLayer and theme configuration with player highlight …
scamiv Jan 10, 2026
6d2a0ad
Refactor contest duration management in TerritoryLayer and TerritoryW…
scamiv Jan 10, 2026
19451fc
Refactor TerritoryWebGLRenderer to simplify contest handling
scamiv Jan 10, 2026
7831f09
needs cleanup.
scamiv Jan 11, 2026
0a3a771
accept delay, use triplebuffer,
scamiv Jan 11, 2026
25d1805
Implement change mask functionality in TerritoryWebGLRenderer
scamiv Jan 11, 2026
fc0a335
Removed contest speed tracking and related properties from Territory…
scamiv Jan 11, 2026
938e36f
refactor: remove contested territory smoke effects and add tile count…
scamiv Jan 11, 2026
9710bf3
Enhance contest management in TerritoryLayer and TerritoryWebGLRenderer
scamiv Jan 11, 2026
957a4ff
Remove TerrainLayer and integrate terrain handling into TerritoryWebG…
scamiv Jan 12, 2026
3f7b25b
Refactor TerritoryWebGLRenderer to improve seed handling logic
scamiv Jan 12, 2026
723a2c3
Refactor smooth animation logic in TerritoryWebGLRenderer
scamiv Jan 12, 2026
c12f2d6
refine alternative view rendering
scamiv Jan 12, 2026
9ba3976
Enhance hover highlight functionality in TerritoryWebGLRenderer
scamiv Jan 12, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions src/client/graphics/GameRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ import { SpawnTimer } from "./layers/SpawnTimer";
import { StructureIconsLayer } from "./layers/StructureIconsLayer";
import { StructureLayer } from "./layers/StructureLayer";
import { TeamStats } from "./layers/TeamStats";
import { TerrainLayer } from "./layers/TerrainLayer";
import { TerritoryLayer } from "./layers/TerritoryLayer";
import { UILayer } from "./layers/UILayer";
import { UnitDisplay } from "./layers/UnitDisplay";
Expand Down Expand Up @@ -248,7 +247,6 @@ export function createRenderer(
// Try to group layers by the return value of shouldTransform.
// Not grouping the layers may cause excessive calls to context.save() and context.restore().
const layers: Layer[] = [
new TerrainLayer(game, transformHandler),
new TerritoryLayer(game, eventBus, transformHandler, userSettings),
new RailroadLayer(game, eventBus, transformHandler),
structureLayer,
Expand Down
73 changes: 73 additions & 0 deletions src/client/graphics/HoverInfo.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import { UnitType } from "../../core/game/Game";
import { TileRef } from "../../core/game/GameMap";
import { GameView, PlayerView, UnitView } from "../../core/game/GameView";

export type HoverInfo = {
player: PlayerView | null;
unit: UnitView | null;
isWilderness: boolean;
isIrradiatedWilderness: boolean;
};

function euclideanDistWorld(
coord: { x: number; y: number },
tileRef: TileRef,
game: GameView,
): number {
const x = game.x(tileRef);
const y = game.y(tileRef);
const dx = coord.x - x;
const dy = coord.y - y;
return Math.sqrt(dx * dx + dy * dy);
}

function distSortUnitWorld(coord: { x: number; y: number }, game: GameView) {
return (a: UnitView, b: UnitView) => {
const distA = euclideanDistWorld(coord, a.tile(), game);
const distB = euclideanDistWorld(coord, b.tile(), game);
return distA - distB;
};
}

export function getHoverInfo(
game: GameView,
worldCoord: { x: number; y: number },
): HoverInfo {
const info: HoverInfo = {
player: null,
unit: null,
isWilderness: false,
isIrradiatedWilderness: false,
};

if (!game.isValidCoord(worldCoord.x, worldCoord.y)) {
return info;
}

const tile = game.ref(worldCoord.x, worldCoord.y);
const owner = game.owner(tile);

if (owner && owner.isPlayer()) {
info.player = owner as PlayerView;
return info;
}

if (owner && !owner.isPlayer() && game.isLand(tile)) {
info.isIrradiatedWilderness = game.hasFallout(tile);
info.isWilderness = !info.isIrradiatedWilderness;
return info;
}

if (!game.isLand(tile)) {
const units = game
.units(UnitType.Warship, UnitType.TradeShip, UnitType.TransportShip)
.filter((u) => euclideanDistWorld(worldCoord, u.tile(), game) < 50)
.sort(distSortUnitWorld(worldCoord, game));

if (units.length > 0) {
info.unit = units[0];
}
}

return info;
}
4 changes: 4 additions & 0 deletions src/client/graphics/TransformHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ export class TransformHandler {
return this._boundingRect;
}

viewOffset(): { x: number; y: number } {
return { x: this.offsetX, y: this.offsetY };
}

width(): number {
return this.boundingRect().width;
}
Expand Down
58 changes: 10 additions & 48 deletions src/client/graphics/layers/PlayerInfoOverlay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@ import {
PlayerProfile,
PlayerType,
Relation,
Unit,
UnitType,
} from "../../../core/game/Game";
import { TileRef } from "../../../core/game/GameMap";
import { AllianceView } from "../../../core/game/GameUpdates";
import { GameView, PlayerView, UnitView } from "../../../core/game/GameView";
import { ContextMenuEvent, MouseMoveEvent } from "../../InputHandler";
Expand All @@ -20,6 +18,7 @@ import {
renderTroops,
translateText,
} from "../../Utils";
import { getHoverInfo } from "../HoverInfo";
import { getFirstPlacePlayer, getPlayerIcons } from "../PlayerIcons";
import { TransformHandler } from "../TransformHandler";
import { Layer } from "./Layer";
Expand All @@ -33,26 +32,6 @@ import missileSiloIcon from "/images/MissileSiloIconWhite.svg?url";
import portIcon from "/images/PortIcon.svg?url";
import samLauncherIcon from "/images/SamLauncherIconWhite.svg?url";

function euclideanDistWorld(
coord: { x: number; y: number },
tileRef: TileRef,
game: GameView,
): number {
const x = game.x(tileRef);
const y = game.y(tileRef);
const dx = coord.x - x;
const dy = coord.y - y;
return Math.sqrt(dx * dx + dy * dy);
}

function distSortUnitWorld(coord: { x: number; y: number }, game: GameView) {
return (a: Unit | UnitView, b: Unit | UnitView) => {
const distA = euclideanDistWorld(coord, a.tile(), game);
const distB = euclideanDistWorld(coord, b.tile(), game);
return distA - distB;
};
}

@customElement("player-info-overlay")
export class PlayerInfoOverlay extends LitElement implements Layer {
@property({ type: Object })
Expand Down Expand Up @@ -119,38 +98,21 @@ export class PlayerInfoOverlay extends LitElement implements Layer {
public maybeShow(x: number, y: number) {
this.hide();
const worldCoord = this.transform.screenToWorldCoordinates(x, y);
if (!this.game.isValidCoord(worldCoord.x, worldCoord.y)) {
return;
}
const info = getHoverInfo(this.game, worldCoord);

const tile = this.game.ref(worldCoord.x, worldCoord.y);
if (!tile) return;

const owner = this.game.owner(tile);

if (owner && owner.isPlayer()) {
this.player = owner as PlayerView;
if (info.player) {
this.player = info.player;
this.player.profile().then((p) => {
this.playerProfile = p;
});
this.setVisible(true);
} else if (owner && !owner.isPlayer() && this.game.isLand(tile)) {
if (this.game.hasFallout(tile)) {
this.isIrradiatedWilderness = true;
} else {
this.isWilderness = true;
}
} else if (info.isWilderness || info.isIrradiatedWilderness) {
this.isWilderness = info.isWilderness;
this.isIrradiatedWilderness = info.isIrradiatedWilderness;
this.setVisible(true);
} else if (info.unit) {
this.unit = info.unit;
this.setVisible(true);
} else if (!this.game.isLand(tile)) {
const units = this.game
.units(UnitType.Warship, UnitType.TradeShip, UnitType.TransportShip)
.filter((u) => euclideanDistWorld(worldCoord, u.tile(), this.game) < 50)
.sort(distSortUnitWorld(worldCoord, this.game));

if (units.length > 0) {
this.unit = units[0];
this.setVisible(true);
}
}
}

Expand Down
77 changes: 0 additions & 77 deletions src/client/graphics/layers/TerrainLayer.ts

This file was deleted.

Loading
Loading