-
-
Notifications
You must be signed in to change notification settings - Fork 207
EARLY MERGE: Update ConstructionSystem to support invisible layers that are between visible ones #3853
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| { | ||
| // Uses sequential indexing for ghost layers to handle cases where | ||
| // invisible layers are between visible ones in the source sprite | ||
| var visibleLayers = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The way I'm reading this is visibleLayers is meant to be an index for the list of layers so that it applies the shade, sprite etc for every valid layer. For this reason I'd suggest renaming it to something like visibleLayerIndex.
| if (!layer.Visible || !layer.RsiState.IsValid) | ||
| continue; | ||
|
|
||
| var rsi = layer.Rsi ?? source.BaseRSI; | ||
| if (rsi is null || !rsi.TryGetState(layer.RsiState, out var state) || state.StateId.Name is null) | ||
| continue; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will cause a desync of your index counter and the layer the loop is on, meaning it might apply to an incorrect layer.
Click here for an example if you don't get what I mean.
For example say we have an item with three layers.
Layer 1 - index 0 (tracked by visibleLayers) - valid
Layer 2 - index 1 - invalid
Layer 3 - index 2 - valid
What would happen in this case is since visibleLayers is incremented at the end of the foreach, which is skipped in both these checks, means that after Layer 2, the variable will be at 1, while the loop is looking at Layer 3. If that were to happen, then the rest of the function would try to apply everything to the invalid layer.
| if (!layer.Visible || !layer.RsiState.IsValid) | |
| continue; | |
| var rsi = layer.Rsi ?? source.BaseRSI; | |
| if (rsi is null || !rsi.TryGetState(layer.RsiState, out var state) || state.StateId.Name is null) | |
| continue; | |
| if (!layer.Visible || !layer.RsiState.IsValid) | |
| { | |
| visibleLayers++; | |
| continue; | |
| } | |
| var rsi = layer.Rsi ?? source.BaseRSI; | |
| if (rsi is null || !rsi.TryGetState(layer.RsiState, out var state) || state.StateId.Name is null) | |
| { | |
| visibleLayers++; | |
| continue; | |
| } |
|
closing per maints discussion |
About the PR
early merge of space-wizards#40668
imp comments added
Why / Balance
required to fix issues in #3721
Requirements