Optimize & clean up RadiationSystem #34459
Open
+189
−127
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
Over time some PRs have carelessly added some expensive checks to code in radiation system that could be a hot path. This PR removes that, while also just cleaning up parts of radiation system.
Why / Balance
Performance is good
Technical details
GetAdjustedRadiationIntensity
now avoids allocating a list and returns early. Also no more linq.GetAdjustedRadiationIntensity
is now only called once per source & receiver, instead of once per(source+1)*receiver
source*receiver
OnIrradiatedEvent
is now a struct eventRadiationRay
is now a struct, and various debug related collections are no longer allocated unless debugging is enabled.RadiationRay
now uses EntityUid instead of NetEntity. Debugging uses a separateDebugRadiationRay
struct that uses NetEntity.Media
AFAICT It still seems to work, through I didn't do any thorough testing.
Content.Client_MnqaoYSTyX.mp4
Requirements
Breaking changes
I guess the radiation ray changes are technically breaking, but Its pretty small and I doubt downstreams use the class directly, so probably fine W/O #codebase-changes.