Skip to content

Commit f1b6710

Browse files
authored
Merge branch 'main' into lobby-chat-panel
2 parents 17647d4 + ab53ee6 commit f1b6710

32 files changed

+551
-292
lines changed

β€Žsrc/client/graphics/PlayerIcons.tsβ€Ž

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ export function createAllianceProgressIcon(
169169
wrapper.style.width = `${size}px`;
170170
wrapper.style.height = `${size}px`;
171171
wrapper.style.display = "inline-block";
172+
wrapper.style.flexShrink = "0";
172173

173174
// Base faded icon (full)
174175
const base = document.createElement("img");

β€Žsrc/client/graphics/layers/NameLayer.tsβ€Ž

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,7 @@ export class NameLayer implements Layer {
439439
// Update existing alliance icon
440440
allianceWrapper.style.width = `${iconSize}px`;
441441
allianceWrapper.style.height = `${iconSize}px`;
442+
allianceWrapper.style.flexShrink = "0";
442443

443444
const overlay = allianceWrapper.querySelector(
444445
".alliance-progress-overlay",

β€Žsrc/client/graphics/layers/RadialMenuElements.tsβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ export const deleteUnitElement: MenuElement = {
452452
.units()
453453
.filter(
454454
(unit) =>
455-
unit.constructionType() === undefined &&
455+
!unit.isUnderConstruction() &&
456456
unit.markedForDeletion() === false &&
457457
params.game.manhattanDist(unit.tile(), params.tile) <=
458458
DELETE_SELECTION_RADIUS,

β€Žsrc/client/graphics/layers/StructureDrawingUtils.tsβ€Ž

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -143,19 +143,12 @@ export class SpriteFactory {
143143
const screenPos = this.transformHandler.worldToScreenCoordinates(worldPos);
144144

145145
const isMarkedForDeletion = unit.markedForDeletion() !== false;
146-
const isConstruction = unit.type() === UnitType.Construction;
147-
const constructionType = unit.constructionType();
148-
const structureType = isConstruction ? constructionType! : unit.type();
146+
const isConstruction = unit.isUnderConstruction();
147+
const structureType = unit.type();
149148
const { type, stage } = options;
150149
const { scale } = this.transformHandler;
151150

152151
if (type === "icon" || type === "dot") {
153-
if (isConstruction && constructionType === undefined) {
154-
console.warn(
155-
`Unit ${unit.id()} is a construction but has no construction type.`,
156-
);
157-
return parentContainer;
158-
}
159152
const texture = this.createTexture(
160153
structureType,
161154
unit.owner(),

β€Žsrc/client/graphics/layers/StructureIconsLayer.tsβ€Ž

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -469,10 +469,7 @@ export class StructureIconsLayer implements Layer {
469469
this.checkForOwnershipChange(render, unitView);
470470
this.checkForLevelChange(render, unitView);
471471
}
472-
} else if (
473-
this.structures.has(unitView.type()) ||
474-
unitView.type() === UnitType.Construction
475-
) {
472+
} else if (this.structures.has(unitView.type())) {
476473
this.addNewStructure(unitView);
477474
}
478475
}
@@ -485,10 +482,7 @@ export class StructureIconsLayer implements Layer {
485482
}
486483

487484
private modifyVisibility(render: StructureRenderInfo) {
488-
const structureType =
489-
render.unit.type() === UnitType.Construction
490-
? render.unit.constructionType()!
491-
: render.unit.type();
485+
const structureType = render.unit.type();
492486
const structureInfos = this.structures.get(structureType);
493487

494488
let focusStructure = false;
@@ -529,10 +523,7 @@ export class StructureIconsLayer implements Layer {
529523
render: StructureRenderInfo,
530524
unit: UnitView,
531525
) {
532-
if (
533-
render.underConstruction &&
534-
render.unit.type() !== UnitType.Construction
535-
) {
526+
if (render.underConstruction && !unit.isUnderConstruction()) {
536527
render.underConstruction = false;
537528
render.iconContainer?.destroy();
538529
render.dotContainer?.destroy();
@@ -580,10 +571,7 @@ export class StructureIconsLayer implements Layer {
580571
: screenPos.y,
581572
);
582573

583-
const type =
584-
render.unit.type() === UnitType.Construction
585-
? render.unit.constructionType()
586-
: render.unit.type();
574+
const type = render.unit.type();
587575
const margin =
588576
type !== undefined && STRUCTURE_SHAPES[type] !== undefined
589577
? ICON_SIZE[STRUCTURE_SHAPES[type]]
@@ -637,7 +625,7 @@ export class StructureIconsLayer implements Layer {
637625
this.createLevelSprite(unitView),
638626
this.createDotSprite(unitView),
639627
unitView.level(),
640-
unitView.type() === UnitType.Construction,
628+
unitView.isUnderConstruction(),
641629
);
642630
this.renders.push(render);
643631
this.computeNewLocation(render);

β€Žsrc/client/graphics/layers/StructureLayer.tsβ€Ž

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ export class StructureLayer implements Layer {
190190
)) {
191191
this.paintCell(
192192
new Cell(this.game.x(tile), this.game.y(tile)),
193-
unit.type() === UnitType.Construction
193+
unit.isUnderConstruction()
194194
? underConstructionColor
195195
: unit.owner().territoryColor(),
196196
130,
@@ -199,7 +199,7 @@ export class StructureLayer implements Layer {
199199
}
200200

201201
private handleUnitRendering(unit: UnitView) {
202-
const unitType = unit.constructionType() ?? unit.type();
202+
const unitType = unit.type();
203203
const iconType = unitType;
204204
if (!this.isUnitTypeSupported(unitType)) return;
205205

@@ -208,7 +208,7 @@ export class StructureLayer implements Layer {
208208
let borderColor = unit.owner().borderColor();
209209

210210
// Handle cooldown states and special icons
211-
if (unit.type() === UnitType.Construction) {
211+
if (unit.isUnderConstruction()) {
212212
icon = this.unitIcons.get(iconType);
213213
borderColor = underConstructionColor;
214214
} else {
@@ -247,7 +247,7 @@ export class StructureLayer implements Layer {
247247
unit: UnitView,
248248
) {
249249
let color = unit.owner().borderColor();
250-
if (unit.type() === UnitType.Construction) {
250+
if (unit.isUnderConstruction()) {
251251
// eslint-disable-next-line @typescript-eslint/no-unused-vars
252252
color = underConstructionColor;
253253
}

β€Žsrc/client/graphics/layers/TerritoryLayer.tsβ€Ž

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,11 @@ export class TerritoryLayer implements Layer {
9090
const unitUpdates = updates !== null ? updates[GameUpdateType.Unit] : [];
9191
unitUpdates.forEach((update) => {
9292
if (update.unitType === UnitType.DefensePost) {
93+
// Only update borders if the defense post is not under construction
94+
if (update.underConstruction) {
95+
return; // Skip barrier creation while under construction
96+
}
97+
9398
const tile = update.pos;
9499
this.game
95100
.bfs(tile, euclDistFN(tile, this.game.config().defensePostRange()))

β€Žsrc/client/graphics/layers/UILayer.tsβ€Ž

Lines changed: 18 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -103,16 +103,12 @@ export class UILayer implements Layer {
103103
}
104104

105105
onUnitEvent(unit: UnitView) {
106+
const underConst = unit.isUnderConstruction();
107+
if (underConst) {
108+
this.createLoadingBar(unit);
109+
return;
110+
}
106111
switch (unit.type()) {
107-
case UnitType.Construction: {
108-
const constructionType = unit.constructionType();
109-
if (constructionType === undefined) {
110-
// Skip units without construction type
111-
return;
112-
}
113-
this.createLoadingBar(unit);
114-
break;
115-
}
116112
case UnitType.Warship: {
117113
this.drawHealthBar(unit);
118114
break;
@@ -318,22 +314,20 @@ export class UILayer implements Layer {
318314
if (!unit.isActive()) {
319315
return 1;
320316
}
321-
switch (unit.type()) {
322-
case UnitType.Construction: {
323-
const constructionType = unit.constructionType();
324-
if (constructionType === undefined) {
325-
return 1;
326-
}
327-
const constDuration =
328-
this.game.unitInfo(constructionType).constructionDuration;
329-
if (constDuration === undefined) {
330-
throw new Error("unit does not have constructionTime");
331-
}
332-
return (
333-
(this.game.ticks() - unit.createdAt()) /
334-
(constDuration === 0 ? 1 : constDuration)
335-
);
317+
const underConst = unit.isUnderConstruction();
318+
if (underConst) {
319+
const constDuration = this.game.unitInfo(
320+
unit.type(),
321+
).constructionDuration;
322+
if (constDuration === undefined) {
323+
throw new Error("unit does not have constructionTime");
336324
}
325+
return (
326+
(this.game.ticks() - unit.createdAt()) /
327+
(constDuration === 0 ? 1 : constDuration)
328+
);
329+
}
330+
switch (unit.type()) {
337331
case UnitType.MissileSilo:
338332
case UnitType.SAMLauncher:
339333
return !unit.markedForDeletion()

β€Žsrc/core/Util.tsβ€Ž

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -307,15 +307,16 @@ export function createRandomName(
307307
export const emojiTable = [
308308
["πŸ˜€", "😊", "πŸ₯°", "πŸ˜‡", "😎"],
309309
["😞", "πŸ₯Ί", "😭", "😱", "😑"],
310-
["😈", "🀑", "πŸ–•", "πŸ₯±", "πŸ€¦β€β™‚οΈ"],
311-
["πŸ‘‹", "πŸ‘", "🀌", "πŸ’ͺ", "🫑"],
312-
["πŸ‘", "πŸ‘Ž", "❓", "πŸ”", "πŸ€"],
310+
["😈", "🀑", "πŸ₯±", "🫑", "πŸ–•"],
311+
["πŸ‘‹", "πŸ‘", "βœ‹", "πŸ™", "πŸ’ͺ"],
312+
["πŸ‘", "πŸ‘Ž", "🫴", "🀌", "πŸ€¦β€β™‚οΈ"],
313313
["🀝", "πŸ†˜", "πŸ•ŠοΈ", "🏳️", "⏳"],
314314
["πŸ”₯", "πŸ’₯", "πŸ’€", "☒️", "⚠️"],
315315
["↖️", "⬆️", "↗️", "πŸ‘‘", "πŸ₯‡"],
316316
["⬅️", "🎯", "➑️", "πŸ₯ˆ", "πŸ₯‰"],
317317
["↙️", "⬇️", "β†˜οΈ", "❀️", "πŸ’”"],
318318
["πŸ’°", "βš“", "β›΅", "🏑", "πŸ›‘οΈ"],
319+
["🏭", "πŸš‚", "❓", "πŸ”", "πŸ€"],
319320
] as const;
320321
// 2d to 1d array
321322
export const flattenedEmojiTable = emojiTable.flat();

β€Žsrc/core/configuration/DefaultConfig.tsβ€Ž

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -545,11 +545,6 @@ export class DefaultConfig implements Config {
545545
experimental: true,
546546
upgradable: true,
547547
};
548-
case UnitType.Construction:
549-
return {
550-
cost: () => 0n,
551-
territoryBound: true,
552-
};
553548
case UnitType.Train:
554549
return {
555550
cost: () => 0n,

0 commit comments

Comments
Β (0)