Fix #410, update MP selector drawing #417
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.
Due to absence of any discussion around the issue and the approach for the solution, I've decided to just make a PR with one possible solution that I deemed the most straightforward.
The solution uses Vanilla
SelectionDrawer.DrawSelectionBracketFor
while providing the specific material, which will handle the color. The method was likely changed in 1.4 to support custom materials due to the need of custom colors for the selector due to storage groups.The materials are stored inside of
PlayerInfo
object. The materials are created usingMaterialPool.MatFrom
, so they should be cached by the game (and will be re-used if a player leaves and rejoins).MaterialPropertyBlock
could no longer be used here due to the Vanilla method not using it, as it instead opted into usingMaterial
to override the default one.As for performance, a slight hit is unavoidable due to the current handling not being fully complete, skipping couple of cases (mentioned in the referenced issue).
This is also compatible with Vehicle Framework, as its prefix to
SelectionDrawer.DrawSelectionBracketFor
will be actually used by MP to draw diagonal selection boxes around vehicles (instead of only rectangular ones, even if vehicle is driving diagonally).