fix foldable clothes not working while worn #39257
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
About the PR
Fixes a bug where foldable clothing cannot be toggled when worn by a player.
Technical details
Previous changes to this code introduced a strange regression. The UnfoldedHideLayers and FoldedHideLayers were made nullable so that the default null value could be used to check for nothing being there and certain buggy interactions could be blocked.
The issue, however, is that the component's default value is an empty hashset, which is not null. Despite this not causing the buggy behavior being guarded against, it was still getting blocked, preventing any foldable clothing from being folded while worn.
To fix this, we simply make the hashset non-nullable and use the empty list to check rather than a null value.
Media
Requirements
Breaking changes
FoldableClothingComponent.UnfoldedHideLayers
andFoldableClothingComponent.FoldedHideLayers
no longer support null values. Use empty sets instead.Changelog
🆑