From e735b9b0f68b22afd6f9b640a72c0b96c5b086b0 Mon Sep 17 00:00:00 2001 From: Matchu Date: Thu, 29 Apr 2021 12:59:33 -0700 Subject: [PATCH] Disambiguate some UC conflict glitch message cases --- .../WardrobePage/OutfitKnownGlitchesBadge.js | 48 ++++++++++--------- 1 file changed, 26 insertions(+), 22 deletions(-) diff --git a/src/app/WardrobePage/OutfitKnownGlitchesBadge.js b/src/app/WardrobePage/OutfitKnownGlitchesBadge.js index a05ff4b..da30873 100644 --- a/src/app/WardrobePage/OutfitKnownGlitchesBadge.js +++ b/src/app/WardrobePage/OutfitKnownGlitchesBadge.js @@ -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( - + {item.name} 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! + + ); + } else if (compatibleItemLayers.length < allItemLayers.length) { + glitchMessages.push( + + {item.name}'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! ); }