mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-31 22:49:52 +01:00
feat: pitch limits and modules
This commit is contained in:
1 parent
95ad6bade7
commit
2184c1c703
2 files changed
+72
-18
No files matched your search
@@ -2,6 +2,8 @@ import type { TankCatalogComponent } from "@blitzkit/closed/protos/game/proto/le
|
|||||||
import { StandardSinglePrice } from "@protos/game/proto/legacy/blitz_static_standard_single_price";
|
import { StandardSinglePrice } from "@protos/game/proto/legacy/blitz_static_standard_single_price";
|
||||||
import { PenetrationGroup } from "@protos/game/proto/legacy/blitz_static_tank_penetration_group";
|
import { PenetrationGroup } from "@protos/game/proto/legacy/blitz_static_tank_penetration_group";
|
||||||
import {
|
import {
|
||||||
|
ModuleUpgrade,
|
||||||
|
ModuleUpgrade_Modifier,
|
||||||
PenetrationGroupUpgrade,
|
PenetrationGroupUpgrade,
|
||||||
PitchLimit,
|
PitchLimit,
|
||||||
ShellUpgrade,
|
ShellUpgrade,
|
||||||
@@ -108,8 +110,63 @@ function patch(stage0: StageParameters, stage1: StageParameters) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stage1.modules_upgrades.length > 0) {
|
for (const upgrade1 of stage1.modules_upgrades) {
|
||||||
throw new Error("Modules upgrades not implemented");
|
let value1: number;
|
||||||
|
|
||||||
|
switch (upgrade1.modifier) {
|
||||||
|
case ModuleUpgrade_Modifier.MODIFIER_OVERRIDE:
|
||||||
|
value1 = upgrade1.value!;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ModuleUpgrade_Modifier.MODIFIER_MULTIPLY:
|
||||||
|
case ModuleUpgrade_Modifier.MODIFIER_ADD:
|
||||||
|
const upgrade0 = stage0.modules_upgrades.find(
|
||||||
|
(base) =>
|
||||||
|
base.module === upgrade1.module &&
|
||||||
|
base.attribute_name === upgrade1.attribute_name,
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!upgrade0) {
|
||||||
|
throw new Error(
|
||||||
|
`Missing module upgrade ${upgrade1.module} ${upgrade1.attribute_name} to modify`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
case ModuleUpgrade_Modifier.MODIFIER_MULTIPLY: {
|
||||||
|
value1 = upgrade0!.value! * upgrade1.value!;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case ModuleUpgrade_Modifier.MODIFIER_ADD: {
|
||||||
|
value1 = upgrade0!.value! + upgrade1.value!;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
throw new Error(
|
||||||
|
`Unhandled module upgrade modifier ${
|
||||||
|
ModuleUpgrade_Modifier[upgrade1.modifier]
|
||||||
|
}`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const upgrade0 = ModuleUpgrade.create({
|
||||||
|
module: upgrade1.module,
|
||||||
|
attribute_name: upgrade1.attribute_name,
|
||||||
|
modifier: ModuleUpgrade_Modifier.MODIFIER_OVERRIDE,
|
||||||
|
value: value1,
|
||||||
|
});
|
||||||
|
const index0 = stage0.modules_upgrades.findIndex(
|
||||||
|
(upgrade) =>
|
||||||
|
upgrade.module === upgrade1.module &&
|
||||||
|
upgrade.attribute_name === upgrade1.attribute_name,
|
||||||
|
);
|
||||||
|
|
||||||
|
if (index0 === -1) {
|
||||||
|
stage0.modules_upgrades.push(upgrade0);
|
||||||
|
} else {
|
||||||
|
stage0.modules_upgrades[index0] = upgrade0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const shellUpgrades1 of stage1.shells_upgrades) {
|
for (const shellUpgrades1 of stage1.shells_upgrades) {
|
||||||
@@ -149,23 +206,20 @@ function patch(stage0: StageParameters, stage1: StageParameters) {
|
|||||||
stage0.pump_reload_times = [...stage1.pump_reload_times];
|
stage0.pump_reload_times = [...stage1.pump_reload_times];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stage1.pitch_limits_up.length > 0 && stage0.pitch_limits_up.length > 0) {
|
if (stage1.pitch_limits_up.length > 0) {
|
||||||
throw new Error("Pitch limits not implemented");
|
stage0.pitch_limits_up = [];
|
||||||
|
|
||||||
|
for (const pitchLimitUp1 of stage1.pitch_limits_up) {
|
||||||
|
stage0.pitch_limits_up.push(PitchLimit.create(pitchLimitUp1));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const pitchLimitUp1 of stage1.pitch_limits_up) {
|
if (stage1.pitch_limits_down.length > 0) {
|
||||||
stage0.pitch_limits_up.push(PitchLimit.create(pitchLimitUp1));
|
stage0.pitch_limits_down = [];
|
||||||
}
|
|
||||||
|
|
||||||
if (
|
for (const pitchLimitDown1 of stage1.pitch_limits_down) {
|
||||||
stage1.pitch_limits_down.length > 0 &&
|
stage0.pitch_limits_down.push(PitchLimit.create(pitchLimitDown1));
|
||||||
stage0.pitch_limits_down.length > 0
|
}
|
||||||
) {
|
|
||||||
throw new Error("Pitch limits not implemented");
|
|
||||||
}
|
|
||||||
|
|
||||||
for (const pitchLimitDown1 of stage1.pitch_limits_down) {
|
|
||||||
stage0.pitch_limits_down.push(PitchLimit.create(pitchLimitDown1));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const visualChange1 of stage1.visual_changes) {
|
for (const visualChange1 of stage1.visual_changes) {
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
import { normalizeAngleDeg } from "@blitzkit/core";
|
import { normalizeAngleDeg } from "@blitzkit/core";
|
||||||
import type { PitchLimit } from "@protos/blitz_static_tank_upgrade_single_stage";
|
import type { PitchLimit } from "@protos/game/proto/legacy/blitz_static_tank_upgrade_single_stage";
|
||||||
import { clamp, degToRad, lerp, radToDeg } from "three/src/math/MathUtils.js";
|
import { clamp, degToRad, lerp, radToDeg } from "three/src/math/MathUtils.js";
|
||||||
|
|
||||||
export function applyPitchYawLimits(
|
export function applyPitchYawLimits(
|
||||||
givenPitch: number,
|
givenPitch: number,
|
||||||
givenYaw: number,
|
givenYaw: number,
|
||||||
pitchLimitsUp: PitchLimit[],
|
pitchLimitsUp: PitchLimit[],
|
||||||
pitchLimitsDown: PitchLimit[]
|
pitchLimitsDown: PitchLimit[],
|
||||||
) {
|
) {
|
||||||
const givenYawDeg = normalizeAngleDeg(radToDeg(givenYaw));
|
const givenYawDeg = normalizeAngleDeg(radToDeg(givenYaw));
|
||||||
const givenPitchDeg = normalizeAngleDeg(radToDeg(givenPitch));
|
const givenPitchDeg = normalizeAngleDeg(radToDeg(givenPitch));
|
||||||
|
|||||||
Reference in new issue
Block a user