mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-11-29 04:44:23 +01:00
fix module swapping
This commit is contained in:
3 files changed
+42
-32
No files matched your search
@@ -73,7 +73,7 @@ export function PrimaryArmorSceneComponent({
|
|||||||
spacedArmorBuffer: { value: null },
|
spacedArmorBuffer: { value: null },
|
||||||
spacedArmorDepth: { value: null },
|
spacedArmorDepth: { value: null },
|
||||||
|
|
||||||
opacity: { value: 0 },
|
opacity: { value: transitionEvent.last! },
|
||||||
},
|
},
|
||||||
]),
|
]),
|
||||||
}),
|
}),
|
||||||
@@ -125,7 +125,7 @@ export function PrimaryArmorSceneComponent({
|
|||||||
equipment,
|
equipment,
|
||||||
);
|
);
|
||||||
const equalizer =
|
const equalizer =
|
||||||
(Tankopedia.state.equalize
|
(Tankopedia.state.environment.equalize
|
||||||
? protagonist.equalizer?.armor
|
? protagonist.equalizer?.armor
|
||||||
: undefined) ?? 1;
|
: undefined) ?? 1;
|
||||||
|
|
||||||
@@ -152,7 +152,7 @@ export function PrimaryArmorSceneComponent({
|
|||||||
penetration *
|
penetration *
|
||||||
resolvePenetrationCoefficient(
|
resolvePenetrationCoefficient(
|
||||||
hasCalibratedShells,
|
hasCalibratedShells,
|
||||||
Tankopedia.state.equalize,
|
Tankopedia.state.environment.equalize,
|
||||||
shell.type,
|
shell.type,
|
||||||
antagonist.equalizer,
|
antagonist.equalizer,
|
||||||
);
|
);
|
||||||
@@ -197,7 +197,7 @@ export function PrimaryArmorSceneComponent({
|
|||||||
() => handleAntagonistEquipmentChange(),
|
() => handleAntagonistEquipmentChange(),
|
||||||
),
|
),
|
||||||
Tankopedia.on(
|
Tankopedia.on(
|
||||||
(state) => state.equalize,
|
(state) => state.environment.equalize,
|
||||||
() => {
|
() => {
|
||||||
handleProtagonistEquipmentChange();
|
handleProtagonistEquipmentChange();
|
||||||
handleAntagonistEquipmentChange();
|
handleAntagonistEquipmentChange();
|
||||||
|
|||||||
@@ -149,8 +149,8 @@ export function StaticArmorSceneComponent({
|
|||||||
color: color
|
color: color
|
||||||
.clone()
|
.clone()
|
||||||
.multiplyScalar(props.type === ArmorType.Spaced ? 2 ** 2 : 2 ** -1),
|
.multiplyScalar(props.type === ArmorType.Spaced ? 2 ** 2 : 2 ** -1),
|
||||||
opacity: 0,
|
opacity: transitionEvent.last!,
|
||||||
transparent: true,
|
transparent: transitionEvent.last! < 1,
|
||||||
}),
|
}),
|
||||||
[hasEnhancedArmor, equalize],
|
[hasEnhancedArmor, equalize],
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -719,13 +719,41 @@ export function FlexibilityToy() {
|
|||||||
const [maxPitch, setMaxPitch] = useState(defaultMax);
|
const [maxPitch, setMaxPitch] = useState(defaultMax);
|
||||||
const container = useRef<HTMLDivElement>(null);
|
const container = useRef<HTMLDivElement>(null);
|
||||||
|
|
||||||
// reset when the gun or turret changes
|
const pitchRange = useCallback(
|
||||||
|
(yaw: number) => {
|
||||||
|
const min = applyPitchYawLimits(
|
||||||
|
-Math.PI,
|
||||||
|
yaw,
|
||||||
|
p,
|
||||||
|
y,
|
||||||
|
hasImprovedVerticalStabilizer,
|
||||||
|
hasDownImprovedVerticalStabilizer,
|
||||||
|
);
|
||||||
|
const max = applyPitchYawLimits(
|
||||||
|
Math.PI,
|
||||||
|
yaw,
|
||||||
|
p,
|
||||||
|
y,
|
||||||
|
hasImprovedVerticalStabilizer,
|
||||||
|
hasDownImprovedVerticalStabilizer,
|
||||||
|
);
|
||||||
|
|
||||||
|
return [min, max] as const;
|
||||||
|
},
|
||||||
|
[p, y, hasImprovedVerticalStabilizer, hasDownImprovedVerticalStabilizer],
|
||||||
|
);
|
||||||
|
|
||||||
|
// keep the current aim within the new limits when the gun or turret changes
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setYaw(0);
|
const [min, max] = pitchRange(modelTransformEvent.last!.yaw);
|
||||||
setPitch(0);
|
const nextYaw = min[1];
|
||||||
setMinPitch(defaultMin);
|
const nextPitch = clamp(modelTransformEvent.last!.pitch, min[0], max[0]);
|
||||||
setMaxPitch(defaultMax);
|
|
||||||
modelTransformEvent.dispatch({ pitch: 0, yaw: 0 });
|
setPitch(nextPitch);
|
||||||
|
setYaw(nextYaw);
|
||||||
|
setMinPitch(min[0] - initialTurretPitch);
|
||||||
|
setMaxPitch(max[0] - initialTurretPitch);
|
||||||
|
modelTransformEvent.dispatch({ pitch: nextPitch, yaw: nextYaw });
|
||||||
}, [protagonist.tank.id, protagonist.turret.id, protagonist.gun.id]);
|
}, [protagonist.tank.id, protagonist.turret.id, protagonist.gun.id]);
|
||||||
|
|
||||||
function outline(limit: "max" | "min") {
|
function outline(limit: "max" | "min") {
|
||||||
@@ -786,26 +814,8 @@ export function FlexibilityToy() {
|
|||||||
const size = Math.min(rect.width, rect.height);
|
const size = Math.min(rect.width, rect.height);
|
||||||
const u = event.clientX - rect.left - rect.width / 2;
|
const u = event.clientX - rect.left - rect.width / 2;
|
||||||
const v = event.clientY - rect.top - rect.height / 2;
|
const v = event.clientY - rect.top - rect.height / 2;
|
||||||
let nextYaw = Math.atan2(u, -v);
|
const [min, max] = pitchRange(Math.atan2(u, -v));
|
||||||
|
const nextYaw = min[1];
|
||||||
const min = applyPitchYawLimits(
|
|
||||||
-Math.PI,
|
|
||||||
nextYaw,
|
|
||||||
p,
|
|
||||||
y,
|
|
||||||
hasImprovedVerticalStabilizer,
|
|
||||||
hasDownImprovedVerticalStabilizer,
|
|
||||||
);
|
|
||||||
const max = applyPitchYawLimits(
|
|
||||||
Math.PI,
|
|
||||||
nextYaw,
|
|
||||||
p,
|
|
||||||
y,
|
|
||||||
hasImprovedVerticalStabilizer,
|
|
||||||
hasDownImprovedVerticalStabilizer,
|
|
||||||
);
|
|
||||||
|
|
||||||
nextYaw = min[1];
|
|
||||||
const distance = clamp(
|
const distance = clamp(
|
||||||
2 * Math.sqrt((u / size) ** 2 + (v / size) ** 2),
|
2 * Math.sqrt((u / size) ** 2 + (v / size) ** 2),
|
||||||
0,
|
0,
|
||||||
|
|||||||
Reference in new issue
Block a user