bufix: paint unit sprites correctly on alternate view

This commit is contained in:
Evan
2025-04-15 20:46:59 -07:00
parent 5167f67b96
commit 8658fd0ff9
2 changed files with 25 additions and 2 deletions
+2 -1
View File
@@ -76,10 +76,11 @@ export const getColoredSprite = (
unit: UnitView,
theme: Theme,
customTerritoryColor?: Colord,
customBorderColor?: Colord,
): HTMLCanvasElement => {
const owner = unit.owner();
const territoryColor = customTerritoryColor ?? theme.territoryColor(owner);
const borderColor = theme.borderColor(owner);
const borderColor = customBorderColor ?? theme.borderColor(owner);
const spawnHighlightColor = theme.spawnHighlightColor();
const colorKey = customTerritoryColor
? customTerritoryColor.toRgbString()
+23 -1
View File
@@ -479,7 +479,29 @@ export class UnitLayer implements Layer {
const x = this.game.x(unit.tile());
const y = this.game.y(unit.tile());
const sprite = getColoredSprite(unit, this.theme, customTerritoryColor);
let alternateViewColor = null;
if (this.alternateView) {
const rel = this.relationship(unit);
switch (rel) {
case Relationship.Self:
alternateViewColor = this.theme.selfColor();
break;
case Relationship.Ally:
alternateViewColor = this.theme.allyColor();
break;
case Relationship.Enemy:
alternateViewColor = this.theme.enemyColor();
break;
}
}
const sprite = getColoredSprite(
unit,
this.theme,
alternateViewColor ?? customTerritoryColor,
alternateViewColor,
);
this.context.drawImage(
sprite,