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 { FaBug } from "react-icons/fa";
import { GlitchBadgeLayout, layerUsesHTML5 } from "../components/HTML5Badge";
import { getVisibleLayers } from "../components/useOutfitAppearance";
function OutfitKnownGlitchesBadge({ appearance }) {
const glitchMessages = [];
@ -10,31 +11,34 @@ function OutfitKnownGlitchesBadge({ appearance }) {
const { petAppearance, items } = appearance;
// Look for UC/Invisible/etc incompatibilities that we hid, that we should
// just mark Incompatible someday instead.
//
// 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,
]);
// just mark Incompatible someday instead; or with correctly partially-hidden
// art.
for (const item of items) {
const itemHasZoneRestrictedByPet = item.appearance.layers.some(
(layer) =>
layer.bodyId !== "0" &&
petOccupiedOrRestrictedZoneIds.has(layer.zone.id)
);
if (itemHasZoneRestrictedByPet) {
// HACK: We use `getVisibleLayers` with just this pet appearance and item
// appearance, to run the logic for which layers are compatible with
// this pet. But `getVisibleLayers` does other things too, so it's
// plausible that this could do not quite what we want in some cases!
const allItemLayers = item.appearance.layers;
const compatibleItemLayers = getVisibleLayers(petAppearance, [
item.appearance,
]).filter((l) => l.source === "item");
if (compatibleItemLayers.length === 0) {
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.
We're still showing the old behavior, which is to hide the item.
Fixing this is in our todo list, sorry for the confusing UI!
We're hiding the item art, which is outdated behavior, and we should
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>
);
}