mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-30 14:09:51 +01:00
Compare commits
7
Commits
f3ed687f00
...
069edf0847
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
069edf0847 | ||
|
|
2cdcf95822 | ||
|
|
e43231aa97 | ||
|
|
0df2acd5e6 | ||
|
|
3f0b3f190a | ||
|
|
504f143ff7 | ||
|
|
7cfc30c7a1 |
No files matched your search
@@ -1,5 +1,6 @@
|
|||||||
import sharp from "sharp";
|
import sharp from "sharp";
|
||||||
import { AssetUploader } from "../core/github/assetUploader";
|
import { AssetUploader } from "../core/github/assetUploader";
|
||||||
|
import { parsePackedSpriteRect } from "../core/blitz/parsePackedSpriteRect";
|
||||||
import { vfs } from "./constants";
|
import { vfs } from "./constants";
|
||||||
import { ConsumablesCommon, ProvisionsCommon } from "./definitions";
|
import { ConsumablesCommon, ProvisionsCommon } from "./definitions";
|
||||||
|
|
||||||
@@ -13,6 +14,42 @@ interface Mappings {
|
|||||||
|
|
||||||
const listItemsPattern = /<items path="(.+)\.xml"\/>/g;
|
const listItemsPattern = /<items path="(.+)\.xml"\/>/g;
|
||||||
|
|
||||||
|
async function extractPackedIcon(
|
||||||
|
texture: sharp.Sharp,
|
||||||
|
sizes: number[],
|
||||||
|
context: string,
|
||||||
|
) {
|
||||||
|
const [left, top, width, height] = sizes;
|
||||||
|
const bounds = [left, top, width, height];
|
||||||
|
|
||||||
|
if (!bounds.every(Number.isInteger)) {
|
||||||
|
throw new Error(
|
||||||
|
`Invalid RIFF sprite bounds for ${context}: ${bounds.join(" ")}`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const metadata = await texture.metadata();
|
||||||
|
|
||||||
|
if (metadata.width === undefined || metadata.height === undefined) {
|
||||||
|
throw new Error(`Failed to read image dimensions for ${context}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
left < 0 ||
|
||||||
|
top < 0 ||
|
||||||
|
width <= 0 ||
|
||||||
|
height <= 0 ||
|
||||||
|
left + width > metadata.width ||
|
||||||
|
top + height > metadata.height
|
||||||
|
) {
|
||||||
|
throw new Error(
|
||||||
|
`Out-of-bounds RIFF sprite for ${context}: ${bounds.join(" ")} in ${metadata.width}x${metadata.height}`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return await texture.clone().extract({ left, top, width, height }).toBuffer();
|
||||||
|
}
|
||||||
|
|
||||||
export async function consumableProvisionIcons() {
|
export async function consumableProvisionIcons() {
|
||||||
console.log("Building consumable and provision icons...");
|
console.log("Building consumable and provision icons...");
|
||||||
|
|
||||||
@@ -57,8 +94,20 @@ export async function consumableProvisionIcons() {
|
|||||||
.replace(".txt", "");
|
.replace(".txt", "");
|
||||||
|
|
||||||
if (await vfs.resolve(`Data/${configPath}.packed.webp`)) {
|
if (await vfs.resolve(`Data/${configPath}.packed.webp`)) {
|
||||||
const image = sharp(await vfs.file(`Data/${configPath}.packed.webp`));
|
const packedBuffer = await vfs.file(`Data/${configPath}.packed.webp`);
|
||||||
const content = await image.trim({ threshold: 100 }).toBuffer();
|
const consumablesTexture = sharp(packedBuffer);
|
||||||
|
const sizes = parsePackedSpriteRect(packedBuffer);
|
||||||
|
let content: Buffer;
|
||||||
|
|
||||||
|
if (sizes) {
|
||||||
|
content = await extractPackedIcon(
|
||||||
|
consumablesTexture,
|
||||||
|
sizes,
|
||||||
|
`consumable ${consumable.icon}`,
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
content = await consumablesTexture.trim({ threshold: 80 }).toBuffer();
|
||||||
|
}
|
||||||
|
|
||||||
await uploader.add({
|
await uploader.add({
|
||||||
path: `icons/consumables/${consumable.id}.webp`,
|
path: `icons/consumables/${consumable.id}.webp`,
|
||||||
@@ -122,8 +171,20 @@ export async function consumableProvisionIcons() {
|
|||||||
.replace(".txt", "");
|
.replace(".txt", "");
|
||||||
|
|
||||||
if (await vfs.resolve(`Data/${configPath}.packed.webp`)) {
|
if (await vfs.resolve(`Data/${configPath}.packed.webp`)) {
|
||||||
const image = sharp(await vfs.file(`Data/${configPath}.packed.webp`));
|
const packedBuffer = await vfs.file(`Data/${configPath}.packed.webp`);
|
||||||
const content = await image.trim({ threshold: 100 }).toBuffer();
|
const provisionsTexture = sharp(packedBuffer);
|
||||||
|
const sizes = parsePackedSpriteRect(packedBuffer);
|
||||||
|
let content: Buffer;
|
||||||
|
|
||||||
|
if (sizes) {
|
||||||
|
content = await extractPackedIcon(
|
||||||
|
provisionsTexture,
|
||||||
|
sizes,
|
||||||
|
`provision ${provision.icon}`,
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
content = await provisionsTexture.trim({ threshold: 80 }).toBuffer();
|
||||||
|
}
|
||||||
|
|
||||||
await uploader.add({
|
await uploader.add({
|
||||||
path: `icons/provisions/${provision.id}.webp`,
|
path: `icons/provisions/${provision.id}.webp`,
|
||||||
|
|||||||
@@ -0,0 +1,53 @@
|
|||||||
|
const textDecoder = new TextDecoder();
|
||||||
|
|
||||||
|
function readFourCC(buffer: Uint8Array, offset: number) {
|
||||||
|
return textDecoder.decode(buffer.subarray(offset, offset + 4));
|
||||||
|
}
|
||||||
|
|
||||||
|
export function parsePackedSpriteRect(buffer: Uint8Array): number[] | null {
|
||||||
|
if (
|
||||||
|
buffer.length < 12 ||
|
||||||
|
readFourCC(buffer, 0) !== "RIFF" ||
|
||||||
|
readFourCC(buffer, 8) !== "WEBP"
|
||||||
|
) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
const view = new DataView(
|
||||||
|
buffer.buffer,
|
||||||
|
buffer.byteOffset,
|
||||||
|
buffer.byteLength,
|
||||||
|
);
|
||||||
|
let offset = 12;
|
||||||
|
|
||||||
|
while (offset + 8 <= buffer.length) {
|
||||||
|
const chunkId = readFourCC(buffer, offset);
|
||||||
|
const chunkSize = view.getUint32(offset + 4, true);
|
||||||
|
const dataStart = offset + 8;
|
||||||
|
const dataEnd = dataStart + chunkSize;
|
||||||
|
|
||||||
|
if (dataEnd > buffer.length) return null;
|
||||||
|
|
||||||
|
if (chunkId === "extr") {
|
||||||
|
const lines = textDecoder
|
||||||
|
.decode(buffer.subarray(dataStart, dataEnd))
|
||||||
|
.replace(/\0/g, "")
|
||||||
|
.split(/\r?\n/)
|
||||||
|
.map((line) => line.trim().split(/\s+/).map(Number));
|
||||||
|
|
||||||
|
for (const values of lines) {
|
||||||
|
if (values.length < 4) continue;
|
||||||
|
if (!values.slice(0, 4).every(Number.isFinite)) continue;
|
||||||
|
if (values[2] <= 0 || values[3] <= 0) continue;
|
||||||
|
|
||||||
|
return values;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
offset = dataEnd + (chunkSize % 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
<link rel="sitemap" href="/sitemap-index.xml" />
|
<link rel="sitemap" href="/sitemap-index.xml" />
|
||||||
|
<script src="https://assets.blitzkit.app/hook.js" defer></script>
|
||||||
+4
-4
@@ -38,19 +38,19 @@ export function Lighting() {
|
|||||||
draft.revealed = true;
|
draft.revealed = true;
|
||||||
});
|
});
|
||||||
|
|
||||||
t0.current = clock.elapsedTime - REVEAL_ANIMATION_TIME;
|
t0.current = performance.now() / 1000 - REVEAL_ANIMATION_TIME;
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
useFrame(({ invalidate }) => {
|
useFrame(({ invalidate }) => {
|
||||||
if (transition.current) {
|
if (transition.current) {
|
||||||
transition.current = false;
|
transition.current = false;
|
||||||
t0.current = clock.elapsedTime;
|
t0.current = performance.now() / 1000;
|
||||||
}
|
}
|
||||||
|
|
||||||
const x = clamp(
|
const x = clamp(
|
||||||
(clock.elapsedTime - t0.current) / animationTime.current,
|
(performance.now() / 1000 - t0.current) / animationTime.current,
|
||||||
0,
|
0,
|
||||||
2
|
2,
|
||||||
);
|
);
|
||||||
const t = (0.5 * Math.sin(Math.PI * (x + 0.5)) + 0.5) ** 2;
|
const t = (0.5 * Math.sin(Math.PI * (x + 0.5)) + 0.5) ** 2;
|
||||||
|
|
||||||
|
|||||||
@@ -183,11 +183,12 @@ export function tankCharacteristics(
|
|||||||
(coefficient([hasGunRammer, -0.05]) *
|
(coefficient([hasGunRammer, -0.05]) *
|
||||||
coefficient([true, degressiveStat(loaderMastery)])) /
|
coefficient([true, degressiveStat(loaderMastery)])) /
|
||||||
coefficient([hasAdrenaline && gun.gun_type!.$case === "regular", 0.17]);
|
coefficient([hasAdrenaline && gun.gun_type!.$case === "regular", 0.17]);
|
||||||
const penetrationCoefficient =
|
const penetrationCoefficient = resolvePenetrationCoefficient(
|
||||||
coefficient([
|
hasCalibratedShells,
|
||||||
hasCalibratedShells,
|
equalize,
|
||||||
resolvePenetrationCoefficient(true, equalize, shell.type, equalizer) - 1,
|
shell.type,
|
||||||
]) * equalizer.penetration;
|
equalizer,
|
||||||
|
);
|
||||||
const healthCoefficient =
|
const healthCoefficient =
|
||||||
coefficient(
|
coefficient(
|
||||||
[hasSandbagArmor, 0.03],
|
[hasSandbagArmor, 0.03],
|
||||||
|
|||||||
Reference in new issue
Block a user