mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-11-14 21:26:08 +01:00
fix: proper pitch limits
This commit is contained in:
1 parent
23751fbdf3
commit
9a30af3818
4 files changed
+48
-27
No files matched your search
@@ -1,5 +1,7 @@
|
||||
import type { TankCatalogComponent } from "@protos/blitz_static_tank_component";
|
||||
import {
|
||||
ShellUpgrageSingleChange_AttributeName,
|
||||
StageParameters,
|
||||
TankAttributeChange_AttributeName,
|
||||
} from "@protos/blitz_static_tank_upgrade_single_stage";
|
||||
import type { TankState } from "./tankState";
|
||||
@@ -13,6 +15,8 @@ type Characteristic = (helpers: {
|
||||
shell: (name: ShellUpgrageSingleChange_AttributeName) => number;
|
||||
shellSafe: (name: ShellUpgrageSingleChange_AttributeName) => number | null;
|
||||
state: TankState;
|
||||
tank: TankCatalogComponent;
|
||||
parameters: StageParameters;
|
||||
}) => CharacteristicOutput;
|
||||
|
||||
export type CharacteristicName = keyof typeof characteristics;
|
||||
@@ -208,20 +212,24 @@ export const characteristics = {
|
||||
);
|
||||
},
|
||||
|
||||
gun_depression({ attributeSafe }) {
|
||||
return (
|
||||
attributeSafe(
|
||||
TankAttributeChange_AttributeName.ATTRIBUTE_NAME_PITCH_LIMIT_DOWN
|
||||
) ?? -Infinity
|
||||
gun_depression({ parameters }) {
|
||||
const pitchLimit = parameters.pitch_limits_down.find(
|
||||
(pitchLimit) => pitchLimit.angle === 0
|
||||
);
|
||||
|
||||
if (!pitchLimit) throw new Error("No angle 0 depression pitch limit found");
|
||||
|
||||
return pitchLimit.limit;
|
||||
},
|
||||
|
||||
gun_elevation({ attributeSafe }) {
|
||||
return (
|
||||
attributeSafe(
|
||||
TankAttributeChange_AttributeName.ATTRIBUTE_NAME_PITCH_LIMIT_UP
|
||||
) ?? -Infinity
|
||||
gun_elevation({ parameters }) {
|
||||
const pitchLimit = parameters.pitch_limits_up.find(
|
||||
(pitchLimit) => pitchLimit.angle === 0
|
||||
);
|
||||
|
||||
if (!pitchLimit) throw new Error("No angle 0 elevation pitch limit found");
|
||||
|
||||
return pitchLimit.limit;
|
||||
},
|
||||
|
||||
engine_power({ attribute }) {
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import type { TankCatalogComponent } from "@protos/blitz_static_tank_component";
|
||||
import {
|
||||
ShellUpgrageSingleChange_AttributeName,
|
||||
TankAttributeChange_AttributeName,
|
||||
type StageParameters,
|
||||
} from "@protos/blitz_static_tank_upgrade_single_stage";
|
||||
import { aggregateStageParameters } from "./aggregateStageParameters";
|
||||
import {
|
||||
characteristics,
|
||||
type CharacteristicName,
|
||||
@@ -11,9 +12,14 @@ import {
|
||||
import type { TankState } from "./tankState";
|
||||
|
||||
export function computeCharacteristics(
|
||||
parameters: StageParameters,
|
||||
tank: TankCatalogComponent,
|
||||
state: TankState
|
||||
) {
|
||||
const parameters = aggregateStageParameters(
|
||||
tank.base_stats!,
|
||||
tank.upgrade_stages.slice(0, state.stage)
|
||||
);
|
||||
|
||||
const computed: Partial<Record<CharacteristicName, CharacteristicOutput>> =
|
||||
{};
|
||||
|
||||
@@ -81,9 +87,17 @@ export function computeCharacteristics(
|
||||
shell,
|
||||
shellSafe,
|
||||
state,
|
||||
tank,
|
||||
parameters,
|
||||
});
|
||||
computed[name] = value;
|
||||
}
|
||||
|
||||
return computed as Record<CharacteristicName, CharacteristicOutput>;
|
||||
return {
|
||||
characteristics: computed as Record<
|
||||
CharacteristicName,
|
||||
CharacteristicOutput
|
||||
>,
|
||||
parameters,
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user