mirror of
https://github.com/exogen/t2-mapper.git
synced 2026-01-19 20:25:01 +00:00
use actual registered datablocks, remove hardcoded mappings
This commit is contained in:
parent
d320fbd694
commit
8b86c2f05d
|
|
@ -6,50 +6,7 @@ import { DebugPlaceholder, ShapeModel, ShapePlaceholder } from "./GenericShape";
|
|||
import { ShapeInfoProvider } from "./ShapeInfoProvider";
|
||||
import { useSimGroup } from "./SimGroup";
|
||||
import { FloatingLabel } from "./FloatingLabel";
|
||||
|
||||
const dataBlockToShapeName = {
|
||||
AmmoPack: "pack_upgrade_ammo.dts",
|
||||
Beacon: "beacon.dts",
|
||||
Chaingun: "weapon_chaingun.dts",
|
||||
ChaingunAmmo: "ammo_chaingun.dts",
|
||||
CloakingPack: "pack_upgrade_cloaking.dts",
|
||||
ConcussionGrenade: "grenade.dts",
|
||||
DiscAmmo: "ammo_disc.dts",
|
||||
ELFGun: "weapon_elf.dts",
|
||||
EnergyPack: "pack_upgrade_energy.dts",
|
||||
Flag: "flag.dts",
|
||||
FlareGrenade: "grenade.dts",
|
||||
Grenade: "grenade.dts",
|
||||
GrenadeLauncher: "weapon_grenade_launcher.dts",
|
||||
GrenadeLauncherAmmo: "ammo_grenade.dts",
|
||||
InventoryDeployable: "pack_deploy_inventory.dts",
|
||||
Mine: "ammo_mine.dts",
|
||||
MotionSensorDeployable: "pack_deploy_sensor_motion.dts",
|
||||
Plasma: "weapon_plasma.dts",
|
||||
PlasmaAmmo: "ammo_plasma.dts",
|
||||
PulseSensorDeployable: "pack_deploy_sensor_pulse.dts",
|
||||
RepairKit: "repair_kit.dts",
|
||||
RepairPack: "pack_upgrade_repair.dts",
|
||||
RepairPatch: "repair_patch.dts",
|
||||
SatchelCharge: "pack_upgrade_satchel.dts",
|
||||
SensorJammerPack: "pack_upgrade_sensorjammer.dts",
|
||||
ShieldPack: "pack_upgrade_shield.dts",
|
||||
ShockLance: "weapon_shocklance.dts",
|
||||
SniperRifle: "weapon_sniper.dts",
|
||||
};
|
||||
|
||||
let _caseInsensitiveLookup: Record<string, string>;
|
||||
|
||||
function getDataBlockShape(dataBlock: string) {
|
||||
if (!_caseInsensitiveLookup) {
|
||||
_caseInsensitiveLookup = Object.fromEntries(
|
||||
Object.entries(dataBlockToShapeName).map(([key, value]) => {
|
||||
return [key.toLowerCase(), value];
|
||||
}),
|
||||
);
|
||||
}
|
||||
return _caseInsensitiveLookup[dataBlock.toLowerCase()];
|
||||
}
|
||||
import { useDatablock } from "./useDatablock";
|
||||
|
||||
const TEAM_NAMES = {
|
||||
1: "Storm",
|
||||
|
|
@ -58,19 +15,20 @@ const TEAM_NAMES = {
|
|||
|
||||
export function Item({ object }: { object: TorqueObject }) {
|
||||
const simGroup = useSimGroup();
|
||||
const dataBlock = getProperty(object, "dataBlock") ?? "";
|
||||
const datablockName = getProperty(object, "dataBlock") ?? "";
|
||||
const datablock = useDatablock(datablockName);
|
||||
|
||||
const position = useMemo(() => getPosition(object), [object]);
|
||||
const scale = useMemo(() => getScale(object), [object]);
|
||||
const q = useMemo(() => getRotation(object), [object]);
|
||||
|
||||
const shapeName = getDataBlockShape(dataBlock);
|
||||
const shapeName = getProperty(datablock, "shapeFile");
|
||||
|
||||
if (!shapeName) {
|
||||
console.error(`<Item> missing shape for dataBlock: ${dataBlock}`);
|
||||
console.error(`<Item> missing shape for datablock: ${datablockName}`);
|
||||
}
|
||||
|
||||
const isFlag = dataBlock?.toLowerCase() === "flag";
|
||||
const isFlag = datablockName?.toLowerCase() === "flag";
|
||||
const team = simGroup?.team ?? null;
|
||||
const teamName = team > 0 ? TEAM_NAMES[team] : null;
|
||||
const label = isFlag && teamName ? `${teamName} Flag` : null;
|
||||
|
|
|
|||
|
|
@ -91,10 +91,28 @@ function useExecutedMission(
|
|||
progress: progressTracker,
|
||||
ignoreScripts: [
|
||||
"scripts/admin.cs",
|
||||
// `ignoreScripts` supports globs, but out of an abundance of caution
|
||||
// we don't want to do `ai*.cs` in case there's some non-AI related
|
||||
// word like "air" in a script name.
|
||||
"scripts/ai.cs",
|
||||
"scripts/aiBotProfiles.cs",
|
||||
"scripts/aiBountyGame.cs",
|
||||
"scripts/aiChat.cs",
|
||||
"scripts/aiCnH.cs",
|
||||
"scripts/aiCTF.cs",
|
||||
"scripts/aiTDM.cs",
|
||||
"scripts/aiDeathMatch.cs",
|
||||
"scripts/aiDebug.cs",
|
||||
"scripts/aiDefaultTasks.cs",
|
||||
"scripts/aiDnD.cs",
|
||||
"scripts/aiHumanTasks.cs",
|
||||
"scripts/aiHunters.cs",
|
||||
"scripts/aiInventory.cs",
|
||||
"scripts/aiObjectiveBuilder.cs",
|
||||
"scripts/aiObjectives.cs",
|
||||
"scripts/aiRabbit.cs",
|
||||
"scripts/aiSiege.cs",
|
||||
"scripts/aiTDM.cs",
|
||||
"scripts/aiTeamHunters.cs",
|
||||
"scripts/deathMessages.cs",
|
||||
"scripts/graphBuild.cs",
|
||||
"scripts/navGraph.cs",
|
||||
|
|
|
|||
|
|
@ -4,54 +4,22 @@ import type { TorqueObject } from "../torqueScript";
|
|||
import { getPosition, getProperty, getRotation, getScale } from "../mission";
|
||||
import { DebugPlaceholder, ShapeModel, ShapePlaceholder } from "./GenericShape";
|
||||
import { ShapeInfoProvider } from "./ShapeInfoProvider";
|
||||
|
||||
const dataBlockToShapeName = {
|
||||
Banner_Honor: "banner_honor.dts",
|
||||
Banner_Strength: "banner_strength.dts",
|
||||
Banner_Unity: "banner_unity.dts",
|
||||
CreativityPad: "station_teleport.dts",
|
||||
ExteriorFlagStand: "ext_flagstand.dts",
|
||||
FlipFlop: "switch.dts",
|
||||
GeneratorLarge: "station_generator_large.dts",
|
||||
InteriorFlagStand: "int_flagstand.dts",
|
||||
LightMaleHuman_Dead: "light_male_dead.dts",
|
||||
MediumMaleHuman_Dead: "medium_male_dead.dts",
|
||||
HeavyMaleHuman_Dead: "heavy_male_dead.dts",
|
||||
LogoProjector: "teamlogo_projector.dts",
|
||||
SensorLargePulse: "sensor_pulse_large.dts",
|
||||
SensorMediumPulse: "sensor_pulse_medium.dts",
|
||||
SolarPanel: "solarpanel.dts",
|
||||
StaticShape: "switch.dts",
|
||||
StationInventory: "station_inv_human.dts",
|
||||
StationVehicle: "vehicle_pad_station.dts",
|
||||
StationVehiclePad: "vehicle_pad.dts",
|
||||
Teleporter: "nexusbase.dts",
|
||||
};
|
||||
|
||||
let _caseInsensitiveLookup: Record<string, string>;
|
||||
|
||||
function getDataBlockShape(dataBlock: string) {
|
||||
if (!_caseInsensitiveLookup) {
|
||||
_caseInsensitiveLookup = Object.fromEntries(
|
||||
Object.entries(dataBlockToShapeName).map(([key, value]) => {
|
||||
return [key.toLowerCase(), value];
|
||||
}),
|
||||
);
|
||||
}
|
||||
return _caseInsensitiveLookup[dataBlock.toLowerCase()];
|
||||
}
|
||||
import { useDatablock } from "./useDatablock";
|
||||
|
||||
export function StaticShape({ object }: { object: TorqueObject }) {
|
||||
const dataBlock = getProperty(object, "dataBlock") ?? "";
|
||||
const datablockName = getProperty(object, "dataBlock") ?? "";
|
||||
const datablock = useDatablock(datablockName);
|
||||
|
||||
const position = useMemo(() => getPosition(object), [object]);
|
||||
const q = useMemo(() => getRotation(object), [object]);
|
||||
const scale = useMemo(() => getScale(object), [object]);
|
||||
|
||||
const shapeName = getDataBlockShape(dataBlock);
|
||||
const shapeName = getProperty(datablock, "shapeFile");
|
||||
|
||||
if (!shapeName) {
|
||||
console.error(`<StaticShape> missing shape for dataBlock: ${dataBlock}`);
|
||||
console.error(
|
||||
`<StaticShape> missing shape for datablock: ${datablockName}`,
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
|
|
|
|||
|
|
@ -4,52 +4,29 @@ import type { TorqueObject } from "../torqueScript";
|
|||
import { getPosition, getProperty, getRotation, getScale } from "../mission";
|
||||
import { DebugPlaceholder, ShapeModel, ShapePlaceholder } from "./GenericShape";
|
||||
import { ShapeInfoProvider } from "./ShapeInfoProvider";
|
||||
|
||||
const dataBlockToShapeName = {
|
||||
AABarrelLarge: "turret_aa_large.dts",
|
||||
ELFBarrelLarge: "turret_elf_large.dts",
|
||||
MissileBarrelLarge: "turret_missile_large.dts",
|
||||
MortarBarrelLarge: "turret_mortar_large.dts",
|
||||
PlasmaBarrelLarge: "turret_fusion_large.dts",
|
||||
SentryTurret: "turret_sentry.dts",
|
||||
TurretBaseLarge: "turret_base_large.dts",
|
||||
SentryTurretBarrel: "turret_muzzlepoint.dts",
|
||||
};
|
||||
|
||||
let _caseInsensitiveLookup: Record<string, string>;
|
||||
|
||||
function getDataBlockShape(dataBlock: string) {
|
||||
if (!_caseInsensitiveLookup) {
|
||||
_caseInsensitiveLookup = Object.fromEntries(
|
||||
Object.entries(dataBlockToShapeName).map(([key, value]) => {
|
||||
return [key.toLowerCase(), value];
|
||||
}),
|
||||
);
|
||||
}
|
||||
return _caseInsensitiveLookup[dataBlock.toLowerCase()];
|
||||
}
|
||||
import { useDatablock } from "./useDatablock";
|
||||
|
||||
export function Turret({ object }: { object: TorqueObject }) {
|
||||
const dataBlock = getProperty(object, "dataBlock") ?? "";
|
||||
const initialBarrel = getProperty(object, "initialBarrel");
|
||||
const datablockName = getProperty(object, "dataBlock") ?? "";
|
||||
const barrelDatablockName = getProperty(object, "initialBarrel");
|
||||
const datablock = useDatablock(datablockName);
|
||||
const barrelDatablock = useDatablock(barrelDatablockName);
|
||||
|
||||
const position = useMemo(() => getPosition(object), [object]);
|
||||
const q = useMemo(() => getRotation(object), [object]);
|
||||
const scale = useMemo(() => getScale(object), [object]);
|
||||
|
||||
const shapeName = getDataBlockShape(dataBlock);
|
||||
|
||||
const barrelShapeName =
|
||||
typeof initialBarrel === "string"
|
||||
? getDataBlockShape(initialBarrel)
|
||||
: undefined;
|
||||
const shapeName = getProperty(datablock, "shapeFile");
|
||||
const barrelShapeName = getProperty(barrelDatablock, "shapeFile");
|
||||
|
||||
if (!shapeName) {
|
||||
console.error(`<Turret> missing shape for dataBlock: ${dataBlock}`);
|
||||
console.error(`<Turret> missing shape for datablock: ${datablockName}`);
|
||||
}
|
||||
if (!barrelShapeName) {
|
||||
// `initialBarrel` is optional - turrets can exist without a barrel mounted.
|
||||
// But if we do have one, it needs a shape name.
|
||||
if (barrelDatablockName && !barrelShapeName) {
|
||||
console.error(
|
||||
`<Turret> missing shape for initialBarrel dataBlock: ${initialBarrel}`,
|
||||
`<Turret> missing shape for barrel datablock: ${barrelDatablockName}`,
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -67,9 +44,9 @@ export function Turret({ object }: { object: TorqueObject }) {
|
|||
) : (
|
||||
<DebugPlaceholder color="orange" />
|
||||
)}
|
||||
<ShapeInfoProvider shapeName={barrelShapeName} type="Turret">
|
||||
<group position={[0, 1.5, 0]}>
|
||||
{barrelShapeName ? (
|
||||
{barrelShapeName ? (
|
||||
<ShapeInfoProvider shapeName={barrelShapeName} type="Turret">
|
||||
<group position={[0, 1.5, 0]}>
|
||||
<ErrorBoundary
|
||||
fallback={
|
||||
<DebugPlaceholder color="red" label={barrelShapeName} />
|
||||
|
|
@ -79,11 +56,9 @@ export function Turret({ object }: { object: TorqueObject }) {
|
|||
<ShapeModel />
|
||||
</Suspense>
|
||||
</ErrorBoundary>
|
||||
) : (
|
||||
<DebugPlaceholder color="orange" />
|
||||
)}
|
||||
</group>
|
||||
</ShapeInfoProvider>
|
||||
</group>
|
||||
</ShapeInfoProvider>
|
||||
) : null}
|
||||
</group>
|
||||
</ShapeInfoProvider>
|
||||
);
|
||||
|
|
|
|||
Loading…
Reference in a new issue