mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-23 19:49:50 +02:00
useProtagonist
This commit is contained in:
1 parent
7592381b12
commit
99965118b3
4 files changed
+35
-20
No files matched your search
@@ -1,3 +1,4 @@
|
|||||||
|
import { useProtagonist } from "../../hooks/useProtagonist";
|
||||||
import type { ComputedCharacteristics } from "../../types/characteristics";
|
import type { ComputedCharacteristics } from "../../types/characteristics";
|
||||||
|
|
||||||
interface TankopediaLoadoutProps {
|
interface TankopediaLoadoutProps {
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
import { api } from "../blitzkit/api";
|
||||||
|
import { Tankopedia } from "../stores/tankopedia";
|
||||||
|
import { useAwait } from "./useAwait";
|
||||||
|
|
||||||
|
export function useProtagonist() {
|
||||||
|
const id = Tankopedia.use((state) => state.protagonist.tank);
|
||||||
|
const tank = useAwait(() => api.tank(id), `tank-${id}`);
|
||||||
|
|
||||||
|
return tank;
|
||||||
|
}
|
||||||
@@ -1,11 +1,7 @@
|
|||||||
import {
|
import {
|
||||||
createDefaultSkills,
|
createDefaultSkills,
|
||||||
EngineDefinition,
|
|
||||||
GunDefinition,
|
|
||||||
ShellDefinition,
|
ShellDefinition,
|
||||||
TankDefinition,
|
TankDefinition,
|
||||||
TrackDefinition,
|
|
||||||
TurretDefinition,
|
|
||||||
type ModelDefinition,
|
type ModelDefinition,
|
||||||
} from "@blitzkit/core";
|
} from "@blitzkit/core";
|
||||||
import type { Vector3 } from "three";
|
import type { Vector3 } from "three";
|
||||||
@@ -14,8 +10,10 @@ import { api } from "../blitzkit/api";
|
|||||||
import type { ArmorType } from "../components/Armor/components/SpacedArmorScene";
|
import type { ArmorType } from "../components/Armor/components/SpacedArmorScene";
|
||||||
import type { ExternalModuleVariant } from "../components/Armor/components/SpacedArmorSceneComponent";
|
import type { ExternalModuleVariant } from "../components/Armor/components/SpacedArmorSceneComponent";
|
||||||
import type { XP_MULTIPLIERS } from "../components/Tankopedia/TechTreeSection";
|
import type { XP_MULTIPLIERS } from "../components/Tankopedia/TechTreeSection";
|
||||||
import { createTankState } from "../tankopedia/createTankState";
|
import {
|
||||||
import type { EquipmentMatrix } from "./duel";
|
createTankState,
|
||||||
|
type EquipmentMatrix,
|
||||||
|
} from "../tankopedia/createTankState";
|
||||||
import { TankopediaDisplay } from "./tankopediaPersistent/constants";
|
import { TankopediaDisplay } from "./tankopediaPersistent/constants";
|
||||||
|
|
||||||
export interface ShotLayerBase {
|
export interface ShotLayerBase {
|
||||||
@@ -84,14 +82,15 @@ export enum TankopediaRelativeAgainst {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface TankState {
|
export interface TankState {
|
||||||
tank: TankDefinition;
|
tank: number;
|
||||||
model: ModelDefinition;
|
|
||||||
|
|
||||||
engine: EngineDefinition;
|
engine: number;
|
||||||
turret: TurretDefinition;
|
turret: number;
|
||||||
gun: GunDefinition;
|
gun: number;
|
||||||
shell: ShellDefinition;
|
shell: number;
|
||||||
track: TrackDefinition;
|
track: number;
|
||||||
|
|
||||||
|
model: ModelDefinition;
|
||||||
|
|
||||||
equipment_matrix: EquipmentMatrix;
|
equipment_matrix: EquipmentMatrix;
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,13 @@
|
|||||||
import { createDefaultProvisions, type TankDefinition } from "@blitzkit/core";
|
import { createDefaultProvisions, type TankDefinition } from "@blitzkit/core";
|
||||||
import { api } from "../blitzkit/api";
|
import { api } from "../blitzkit/api";
|
||||||
import type { EquipmentMatrix } from "../stores/duel";
|
|
||||||
import type { TankState } from "../stores/tankopedia";
|
import type { TankState } from "../stores/tankopedia";
|
||||||
|
|
||||||
|
export type EquipmentMatrix = [
|
||||||
|
[number, number, number],
|
||||||
|
[number, number, number],
|
||||||
|
[number, number, number],
|
||||||
|
];
|
||||||
|
|
||||||
const models = await api.models();
|
const models = await api.models();
|
||||||
const provisions = await api.provisions();
|
const provisions = await api.provisions();
|
||||||
const scripts = await api.scripts();
|
const scripts = await api.scripts();
|
||||||
@@ -18,14 +23,14 @@ export function createTankState(tank: TankDefinition) {
|
|||||||
const gun = turret.guns.at(-1)!;
|
const gun = turret.guns.at(-1)!;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
tank,
|
tank: tank.id,
|
||||||
model: models.models[turret.id],
|
model: models.models[turret.id],
|
||||||
|
|
||||||
engine: tank.engines.at(-1)!,
|
engine: tank.engines.at(-1)!.id,
|
||||||
turret,
|
turret: turret.id,
|
||||||
gun,
|
gun: gun.id,
|
||||||
shell: gun.shells[0],
|
shell: gun.shells[0].id,
|
||||||
track: tank.tracks.at(-1)!,
|
track: tank.tracks.at(-1)!.id,
|
||||||
|
|
||||||
equipment_matrix: genericDefaultEquipmentMatrix,
|
equipment_matrix: genericDefaultEquipmentMatrix,
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user