feat: remove assertion

This commit is contained in:
TrèsAbhi committed 2024-07-10 13:11:09 -05:00
1 parent b0b68f3fd3
commit 74d4b8edf4
26 files changed
+172 -188

No files matched your search

@@ -10,8 +10,8 @@ import { TankSandbox } from './TankSandbox';
import { Options } from './components/Options';
export function HeroSection() {
const protagonist = Duel.use((state) => state.protagonist!.tank);
const antagonist = Duel.use((state) => state.antagonist!.tank);
const protagonist = Duel.use((state) => state.protagonist.tank);
const antagonist = Duel.use((state) => state.antagonist.tank);
const compareTanks =
protagonist.id === antagonist.id
? [protagonist.id]
@@ -20,7 +20,7 @@ export function TankSandbox() {
const canvas = useRef<HTMLCanvasElement>(null);
const hasImprovedVerticalStabilizer = useEquipment(122);
const awaitedModelDefinitions = use(modelDefinitions);
const protagonist = Duel.use((state) => state.protagonist!);
const protagonist = Duel.use((state) => state.protagonist);
const mutateDuel = Duel.useMutation();
const tankModelDefinition = awaitedModelDefinitions[protagonist.tank.id];
const turretModelDefinition =
@@ -55,8 +55,8 @@ export function TankSandbox() {
);
modelTransformEvent.emit({ pitch, yaw });
draft.protagonist!.pitch = pitch;
draft.protagonist!.yaw = yaw;
draft.protagonist.pitch = pitch;
draft.protagonist.yaw = yaw;
});
break;
@@ -73,8 +73,8 @@ export function TankSandbox() {
);
modelTransformEvent.emit({ pitch, yaw });
draft.protagonist!.pitch = pitch;
draft.protagonist!.yaw = yaw;
draft.protagonist.pitch = pitch;
draft.protagonist.yaw = yaw;
});
break;
@@ -91,8 +91,8 @@ export function TankSandbox() {
);
modelTransformEvent.emit({ pitch, yaw });
draft.protagonist!.pitch = pitch;
draft.protagonist!.yaw = yaw;
draft.protagonist.pitch = pitch;
draft.protagonist.yaw = yaw;
});
break;
@@ -108,9 +108,9 @@ export function TankSandbox() {
useEffect(() => {
mutateDuel((draft) => {
[draft.protagonist!.pitch, draft.protagonist!.yaw] = applyPitchYawLimits(
draft.protagonist!.pitch,
draft.protagonist!.yaw,
[draft.protagonist.pitch, draft.protagonist.yaw] = applyPitchYawLimits(
draft.protagonist.pitch,
draft.protagonist.yaw,
gunModelDefinition.pitch,
turretModelDefinition.yaw,
hasImprovedVerticalStabilizer,
@@ -51,7 +51,7 @@ export function TreeArrow({
export function TechTreeSection() {
const awaitedTankDefinitions = use(tankDefinitions);
const tank = Duel.use((state) => state.protagonist!.tank);
const tank = Duel.use((state) => state.protagonist.tank);
if (tank.treeType !== 'researchable') return null;
@@ -66,11 +66,11 @@ export function Options() {
(state) => state.model.visual.environment,
);
const developerMode = App.use((state) => state.developerMode);
const antagonistGun = Duel.use((state) => state.antagonist!.gun);
const antagonistShell = Duel.use((state) => state.antagonist!.shell);
const antagonistGun = Duel.use((state) => state.antagonist.gun);
const antagonistShell = Duel.use((state) => state.antagonist.shell);
const [antagonistSelectorOpen, setAntagonistSelectorOpen] = useState(false);
const antagonistTank = Duel.use((state) => state.antagonist!.tank);
const antagonistTurret = Duel.use((state) => state.antagonist!.turret);
const antagonistTank = Duel.use((state) => state.antagonist.tank);
const antagonistTurret = Duel.use((state) => state.antagonist.turret);
const hasCalibratedShells = useEquipment(103, true);
const [tab, setTab] = useState('search');
const mutateDuel = Duel.useMutation();
@@ -151,7 +151,7 @@ export function Options() {
}}
onClick={() => {
mutateDuel((draft) => {
draft.antagonist!.shell = thisShell;
draft.antagonist.shell = thisShell;
});
mutateTankopediaEphemeral((draft) => {
draft.shot = undefined;
@@ -183,7 +183,7 @@ export function Options() {
}}
onClick={() => {
mutateDuel((draft) => {
draft.antagonist!.equipmentMatrix[0][0] = hasCalibratedShells
draft.antagonist.equipmentMatrix[0][0] = hasCalibratedShells
? 0
: 1;
});
@@ -215,7 +215,7 @@ export function Options() {
}}
onClick={() => {
mutateDuel((draft) => {
draft.protagonist!.equipmentMatrix[1][1] = hasEnhancedArmor
draft.protagonist.equipmentMatrix[1][1] = hasEnhancedArmor
? 0
: -1;
});
@@ -298,14 +298,14 @@ export function Options() {
compact
onSelect={(tank) => {
mutateDuel((draft) => {
draft.antagonist!.tank = tank;
draft.antagonist!.engine = tank.engines.at(-1)!;
draft.antagonist!.track = tank.tracks.at(-1)!;
draft.antagonist!.turret = tank.turrets.at(-1)!;
draft.antagonist!.gun =
draft.antagonist!.turret.guns.at(-1)!;
draft.antagonist!.shell =
draft.antagonist!.gun.shells[0];
draft.antagonist.tank = tank;
draft.antagonist.engine = tank.engines.at(-1)!;
draft.antagonist.track = tank.tracks.at(-1)!;
draft.antagonist.turret = tank.turrets.at(-1)!;
draft.antagonist.gun =
draft.antagonist.turret.guns.at(-1)!;
draft.antagonist.shell =
draft.antagonist.gun.shells[0];
});
setAntagonistSelectorOpen(false);
}}
@@ -332,11 +332,11 @@ export function Options() {
key={turret.id}
onClick={() => {
mutateDuel((draft) => {
draft.antagonist!.turret = turret;
draft.antagonist!.gun =
draft.antagonist.turret = turret;
draft.antagonist.gun =
turret.guns.at(-1)!;
draft.antagonist!.shell =
draft.antagonist!.gun.shells[0];
draft.antagonist.shell =
draft.antagonist.gun.shells[0];
});
mutateTankopediaEphemeral((draft) => {
draft.shot = undefined;
@@ -361,8 +361,8 @@ export function Options() {
}
onClick={() => {
mutateDuel((draft) => {
draft.antagonist!.gun = gun;
draft.antagonist!.shell = gun.shells[0];
draft.antagonist.gun = gun;
draft.antagonist.shell = gun.shells[0];
});
}}
selected={antagonistGun.id === gun.id}
@@ -28,7 +28,7 @@ export const TankModel = memo(() => {
const mutateDuel = Duel.useMutation();
const duelStore = Duel.useStore();
const awaitedModelDefinitions = useAwait(modelDefinitions);
const protagonist = Duel.use((draft) => draft.protagonist!);
const protagonist = Duel.use((draft) => draft.protagonist);
const canvas = useThree((state) => state.gl.domElement);
const hullContainer = useRef<Group>(null);
const turretContainer = useRef<Group>(null);
@@ -221,8 +221,8 @@ export const TankModel = memo(() => {
const duel = duelStore.getState();
const hasImprovedVerticalStabilizer = await hasEquipment(
122,
duel.protagonist!.tank.equipment,
duel.protagonist!.equipmentMatrix,
duel.protagonist.tank.equipment,
duel.protagonist.equipmentMatrix,
);
const boundingRect = canvas.getBoundingClientRect();
@@ -240,8 +240,8 @@ export const TankModel = memo(() => {
}
function handlePointerUp() {
mutateDuel((draft) => {
draft.protagonist!.pitch = normalizeAngleRad(pitch);
draft.protagonist!.yaw = normalizeAngleRad(yaw);
draft.protagonist.pitch = normalizeAngleRad(pitch);
draft.protagonist.yaw = normalizeAngleRad(yaw);
});
mutateTankopediaTemporary((draft) => {
draft.controlsEnabled = true;
@@ -301,8 +301,8 @@ export const TankModel = memo(() => {
const duel = duelStore.getState();
const hasImprovedVerticalStabilizer = await hasEquipment(
122,
duel.protagonist!.tank.equipment,
duel.protagonist!.equipmentMatrix,
duel.protagonist.tank.equipment,
duel.protagonist.equipmentMatrix,
);
const boundingRect = canvas.getBoundingClientRect();
delta.set(event.clientX, event.clientY).sub(position);
@@ -322,8 +322,8 @@ export const TankModel = memo(() => {
draft.controlsEnabled = true;
});
mutateDuel((draft) => {
draft.protagonist!.pitch = normalizeAngleRad(pitch);
draft.protagonist!.yaw = normalizeAngleRad(yaw);
draft.protagonist.pitch = normalizeAngleRad(pitch);
draft.protagonist.yaw = normalizeAngleRad(yaw);
});
window.removeEventListener('pointermove', handlePointerMove);
window.removeEventListener('pointerup', handlePointerUp);