fix(render): show exact remaining ammunition

Reference: lolink’s numeric ammunition display in https://github.com/Yilegendoflink/garrison-protocol/commit/071ed14aa27d5ebf54e57447c958f2681737403c. This implementation uses the existing PIXI HUD and exact snapshot counts; no fork code is copied.
This commit is contained in:
IceCodeNew committed 2026-10-12 09:55:51 +00:00
1 parent bc50cac01f
commit 02fd42abe5
4 files changed
+57 -1

No files matched your search

+19 -1
View File
@@ -760,6 +760,7 @@ export class UnitView {
this.blockIcon.visible = false;
this.ctx.layers.groundFx.addChild(this.blockIcon);
this.countText = null;
this.ammoText = null;
this.itemPips = [];
}
@@ -1413,7 +1414,8 @@ export class UnitView {
}
// 狼影 pips under the bars (b.snap `wolves`), then the element gauge row under them (b.snap `elem`); redeploy ring above a
// knocked-down operator (b.snap `down`)
const rowsTop = cy + bh / 2 + (showSp ? spH + 1.5 : 0);
let rowsTop = cy + bh / 2 + (showSp ? spH + 1.5 : 0);
rowsTop += this._updateAmmoText(showSp && !!ammo, x0 + bw / 2, rowsTop, s);
const wolfH = this._updateWolfPips(showBars && !this.isEnemy && !!this.wolves, x0, rowsTop, s);
const coinH = this._updateCoins(showBars && !this.isEnemy && !!this.coins, x0, rowsTop + wolfH, s);
this._updateElementBar(showBars && !!this.el, x0, bw, rowsTop + wolfH + coinH + 1, spH, s, t);
@@ -1441,6 +1443,22 @@ export class UnitView {
}
}
/** Exact snapshot counts, including extra rounds and refills; readable even when the cells are too narrow. */
_updateAmmoText(show, x, top, s) {
let text = this.ammoText;
if (!show) { if (text) text.visible = false; return 0; }
if (!text) {
text = this.ammoText = new this.P.Text('', { fontFamily: 'Bender, Oxanium, sans-serif', fontSize: 16, fontWeight: '700', fill: COLORS.ammo, stroke: '#0b0f0e', strokeThickness: 3 });
text.anchor.set(0.5, 0);
this.hud.addChild(text);
}
text.text = `${this.ammo[0]}/${this.ammo[1]}`;
text.scale.set(clamp(s * 0.2, 10, 16) / 16);
text.position.set(x, top + 3);
text.visible = true;
return text.height + 6;
}
/**
* The thin dark separators between the ammo bar's cells (see _updateHud): one at every round boundary of the `n`-round
* magazine across the bar `x0` … `x0 + bw` at height `y`, `h` tall; none while a cell would be under AMMO_BAR.minCell px