From dabeab8612d8279daf78c863cb147bf58cb4f0ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tr=C3=A8sAbhi?= <43380238+tresabhi@users.noreply.github.com> Date: Tue, 12 Dec 2023 14:14:26 -0600 Subject: [PATCH] feat: gun defs --- scripts/buildAssets.ts | 40 ++++++++++++++++++++++++---------------- 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/scripts/buildAssets.ts b/scripts/buildAssets.ts index a9c8fa8ec..1fe8ea164 100644 --- a/scripts/buildAssets.ts +++ b/scripts/buildAssets.ts @@ -52,6 +52,8 @@ interface GunDefinitionsList { tags: string; level: number; pitchLimits: string; + burst?: { count: number; rate: number }; + clip?: { count: number; rate: number }; }; }; } @@ -149,9 +151,27 @@ if (allTargets || targets?.includes('definitions')) { (turretKey) => { const turret = tankDefinition.root.turrets0[turretKey]; const turretId = toUniqueId(nation, turretList.root.ids[turretKey]); - const turretGuns = Object.keys(turret.guns).map((gunKey) => - toUniqueId(nation, gunList.root.ids[gunKey]), - ); + const turretGuns = Object.keys(turret.guns).map((gunKey) => { + const turretGunEntry = turret.guns[gunKey]; + const gunId = toUniqueId(nation, gunList.root.ids[gunKey]); + const gun = gunList.root.shared[gunKey]; + const pitchLimitsRaw = + turretGunEntry.pitchLimits ?? gun.pitchLimits; + + gunDefinitions[gunId] = { + id: gunId, + pitch: (typeof pitchLimitsRaw === 'string' + ? pitchLimitsRaw + : pitchLimitsRaw.at(-1)! + ) + .split(' ') + .map(Number) as [number, number], + name: strings[gun.userString] ?? gunKey.replaceAll('_', ' '), + tier: gun.level, + }; + + return gunId; + }); turretDefinitions[turretId] = { id: turretId, @@ -163,7 +183,7 @@ if (allTargets || targets?.includes('definitions')) { tier: turret.level, yaw: (typeof turret.yawLimits === 'string' ? turret.yawLimits - : turret.yawLimits[0] + : turret.yawLimits.at(-1)! ) .split(' ') .map(Number) as [number, number], @@ -194,18 +214,6 @@ if (allTargets || targets?.includes('definitions')) { turrets: tankTurrets, }; } - - Object.keys(gunList.root.ids).forEach((gunKey) => { - const gun = gunList.root.shared[gunKey]; - const gunId = toUniqueId(nation, gunList.root.ids[gunKey]); - - gunDefinitions[gunId] = { - id: gunId, - name: strings[gun.userString] ?? gunKey.replaceAll('_', ' '), - tier: gun.level, - pitch: gun.pitchLimits.split(' ').map(Number) as [number, number], - }; - }); }), );