Remove duplicate code
This commit is contained in:
@@ -137,6 +137,26 @@ export class ModGraphics implements Graphics {
|
||||
);
|
||||
}
|
||||
|
||||
progress(
|
||||
empty: string,
|
||||
full: string,
|
||||
x: number,
|
||||
y: number,
|
||||
w: number,
|
||||
h: number,
|
||||
filled: number,
|
||||
direction: "right" | "up" = "right",
|
||||
) {
|
||||
// nothing filled for NaN too, like progress / max before there's a max
|
||||
const done = filled > 0 ? Math.min(1, filled) : 0;
|
||||
this.texture(empty, x, y, w, h);
|
||||
if (direction === "right") {
|
||||
this.texture(full, x, y, w * done, h, [0, 0, done, 1]);
|
||||
} else {
|
||||
this.texture(full, x, y + h * (1 - done), w, h * done, [0, 1 - done, 1, done]);
|
||||
}
|
||||
}
|
||||
|
||||
item(id: string, x: number, y: number, count = 1) {
|
||||
if (!EverythingRegistry.get<ItemRegistry>("items", id)) throw new Error(`unknown item ${id}`);
|
||||
const stack = new ItemStack(id, count);
|
||||
|
||||
Reference in New Issue
Block a user