Logic & comment updates to #30

Tested this out and compared to Dice's other work in Neobot and I think the condition should be the other way around, as it is here? (I found myself starting to write the explanatory comment, and realizing it wasn't making sense, then going heyyy wait a minute lol)
This commit is contained in:
Emi Matchu 2022-12-22 18:58:49 -08:00
parent 60d2f9a014
commit f2832a3bde

View file

@ -22,14 +22,9 @@ function getVisibleLayers(petAppearance, itemAppearances) {
.flat() .flat()
.map((z) => z.id) .map((z) => z.id)
); );
const petOccupiedZoneIds = new Set(petLayers.map((l) => l.zone.id));
const petRestrictedZoneIds = new Set( const petRestrictedZoneIds = new Set(
petAppearance.restrictedZones.map((z) => z.id) petAppearance.restrictedZones.map((z) => z.id)
); );
const petOccupiedOrRestrictedZoneIds = new Set([
...petOccupiedZoneIds,
...petRestrictedZoneIds,
]);
const visibleLayers = allLayers.filter((layer) => { const visibleLayers = allLayers.filter((layer) => {
// When an item restricts a zone, it hides pet layers of the same zone. // When an item restricts a zone, it hides pet layers of the same zone.
@ -42,11 +37,11 @@ function getVisibleLayers(petAppearance, itemAppearances) {
return false; return false;
} }
// When a pet appearance restricts or occupies a zone, or when the pet is // When a pet appearance restricts a zone, or when the pet is Unconverted,
// Unconverted, it makes body-specific items incompatible. We use this to // it makes body-specific items incompatible. We use this to disallow UCs
// disallow UCs from wearing certain body-specific Biology Effects, // from wearing certain body-specific Biology Effects, Statics, etc, while
// Statics, etc, while still allowing non-body-specific items in those // still allowing non-body-specific items in those zones! (I think this
// zones! (I think this happens for some Invisible pet stuff, too?) // happens for some Invisible pet stuff, too?)
// //
// TODO: We shouldn't be *hiding* these zones, like we do with items; we // TODO: We shouldn't be *hiding* these zones, like we do with items; we
// should be doing this way earlier, to prevent the item from even // should be doing this way earlier, to prevent the item from even
@ -59,6 +54,13 @@ function getVisibleLayers(petAppearance, itemAppearances) {
// stability, and *then* rely on the UI to respect that ordering when // stability, and *then* rely on the UI to respect that ordering when
// rendering them by depth. Not great! 😅) // rendering them by depth. Not great! 😅)
// //
// NOTE: We used to also include the pet appearance's *occupied* zones in
// this condition, not just the restricted zones, as a sensible
// defensive default, even though we weren't aware of any relevant
// items. But now we know that actually the "Bruce Brucey B Mouth"
// occupies the real Mouth zone, and still should be visible and
// above pet layers! So, we now only check *restricted* zones.
//
// NOTE: UCs used to implement their restrictions by listing specific // NOTE: UCs used to implement their restrictions by listing specific
// zones, but it seems that the logic has changed to just be about // zones, but it seems that the logic has changed to just be about
// UC-ness and body-specific-ness, and not necessarily involve the // UC-ness and body-specific-ness, and not necessarily involve the
@ -74,7 +76,7 @@ function getVisibleLayers(petAppearance, itemAppearances) {
layer.source === "item" && layer.source === "item" &&
layer.bodyId !== "0" && layer.bodyId !== "0" &&
(petAppearance.pose === "UNCONVERTED" || (petAppearance.pose === "UNCONVERTED" ||
petOccupiedZoneIds.has(layer.zone.id)) petRestrictedZoneIds.has(layer.zone.id))
) { ) {
return false; return false;
} }