Disambiguate some UC conflict glitch message cases

This commit is contained in:
Emi Matchu 2021-04-29 12:59:33 -07:00
parent cb104954af
commit e735b9b0f6

View file

@ -3,6 +3,7 @@ import { Box, VStack } from "@chakra-ui/react";
import { WarningTwoIcon } from "@chakra-ui/icons"; import { WarningTwoIcon } from "@chakra-ui/icons";
import { FaBug } from "react-icons/fa"; import { FaBug } from "react-icons/fa";
import { GlitchBadgeLayout, layerUsesHTML5 } from "../components/HTML5Badge"; import { GlitchBadgeLayout, layerUsesHTML5 } from "../components/HTML5Badge";
import { getVisibleLayers } from "../components/useOutfitAppearance";
function OutfitKnownGlitchesBadge({ appearance }) { function OutfitKnownGlitchesBadge({ appearance }) {
const glitchMessages = []; const glitchMessages = [];
@ -10,31 +11,34 @@ function OutfitKnownGlitchesBadge({ appearance }) {
const { petAppearance, items } = appearance; const { petAppearance, items } = appearance;
// Look for UC/Invisible/etc incompatibilities that we hid, that we should // Look for UC/Invisible/etc incompatibilities that we hid, that we should
// just mark Incompatible someday instead. // just mark Incompatible someday instead; or with correctly partially-hidden
// // art.
// HACK: Most of this logic is copy-pasted from `useOutfitAppearance`.
const petOccupiedZoneIds = new Set(
petAppearance?.layers.map((l) => l.zone.id)
);
const petRestrictedZoneIds = new Set(
petAppearance?.restrictedZones.map((z) => z.id)
);
const petOccupiedOrRestrictedZoneIds = new Set([
...petOccupiedZoneIds,
...petRestrictedZoneIds,
]);
for (const item of items) { for (const item of items) {
const itemHasZoneRestrictedByPet = item.appearance.layers.some( // HACK: We use `getVisibleLayers` with just this pet appearance and item
(layer) => // appearance, to run the logic for which layers are compatible with
layer.bodyId !== "0" && // this pet. But `getVisibleLayers` does other things too, so it's
petOccupiedOrRestrictedZoneIds.has(layer.zone.id) // plausible that this could do not quite what we want in some cases!
); const allItemLayers = item.appearance.layers;
if (itemHasZoneRestrictedByPet) { const compatibleItemLayers = getVisibleLayers(petAppearance, [
item.appearance,
]).filter((l) => l.source === "item");
if (compatibleItemLayers.length === 0) {
glitchMessages.push( glitchMessages.push(
<Box key={`uc-conflict-for-item-${item.id}`}> <Box key={`total-uc-conflict-for-item-${item.id}`}>
<i>{item.name}</i> isn't actually compatible with this special pet. <i>{item.name}</i> isn't actually compatible with this special pet.
We're still showing the old behavior, which is to hide the item. We're hiding the item art, which is outdated behavior, and we should
Fixing this is in our todo list, sorry for the confusing UI! instead be treating it as entirely incompatible. Fixing this is in our
todo list, sorry for the confusing UI!
</Box>
);
} else if (compatibleItemLayers.length < allItemLayers.length) {
glitchMessages.push(
<Box key={`partial-uc-conflict-for-item-${item.id}`}>
<i>{item.name}</i>'s compatibility with this pet is complicated, but
we believe this is how it looks: some zones are visible, and some
zones are hidden. If this isn't quite right, please email me at
matchu@openneo.net and let me know!
</Box> </Box>
); );
} }