-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Replace obsolete EntityWhitelist IsValid usages #28465
Replace obsolete EntityWhitelist IsValid usages #28465
Conversation
common pattern that i know exists is nullable whitelists/blacklists that ignore each other so a helper that takes in a nullable whitelist and a nullable blacklist and performs common functions on them would be incredibly useful. |
where do we store helper functions in the codebase? I'd be up for it |
ok there you go, it is definitely easier to read that's for sure |
borg lock pr had this |
About the PR
EntityWhitelist?.IsValid() has a message saying that it's obsolete and to use EntityWhitelistSystem's method instead
So I changed every usage I could find with EntityWhitelistSystem.IsValid()
Why / Balance
Gets rid of some obsolete notifications... I guess?
Technical details
Kinda like how simple the code looked before I did this...
A rough summary of how I approached each case
== true
gets replaced withcomponent.Whitelist == null ? false : _whitelist.IsValid()
== false
gets replaced withcomponent.Whitelist == null ? false : !_whitelist.IsValid()
!= true
gets replaced withcomponent.Whitelist == null ? true : !_whitelist.IsValid()
!= false
gets replaced withcomponent.Whitelist == null ? true : _whitelist.IsValid()
Took me a while to figure out that the null propagating operator gets set to null in the checks which causes different scenarios based on whether it's == or !=, once I figured out that much I properly accounted for what happens when whitelist is null and now everything I tested works pretty much without issue
edit: EmoGarbage requested helper functions so now it's
2.
== true
gets replaced with_whitelist.IsWhitelistPass()
3.
== false
gets replaced with_whitelist.IsWhitelistFail()
4.
!= true
gets replaced with_whitelist.IsWhitelistFailOrNull()
5.
!= false
gets replaced with_whitelist.IsWhitelistPassOrNull()
along with similarly named Blacklist functions so you can write things like
_whitelist.IsWhitelistPass() && _whitelist.IsBlacklistFail()
Breaking changes
god I hope not
Changelog
nothing changed for the player experience