Skip to content
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

Fix #410, update MP selector drawing #417

Merged
merged 1 commit into from
Feb 3, 2024

Conversation

SokyranTheDragon
Copy link
Member

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 using MaterialPool.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 using Material 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).

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 using `MaterialPool.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 using `Material` 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).
@SokyranTheDragon SokyranTheDragon added the 1.4 Fixes or bugs relating to 1.4 (Not Biotech). label Jan 10, 2024
@Zetrith Zetrith merged commit 601f3cf into rwmt:master Feb 3, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1.4 Fixes or bugs relating to 1.4 (Not Biotech).
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants