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
UITacticalHUD_Enemies UpdateVisibleEnemies should use cached hit chances when sorting final targets array #1233
Comments
If I may suggest a modification -- in addition to the |
As a reminder for myself: The same optimization can be applied to "GatherAbilityTargets" of XComGameState_Ability and XComGameState_Ability_CH. |
Should be noted that the default implementation of |
UpdateVisibleEnemies of UITacticalHUD_Enemies sorts the array of visible enemies by hit chance using a comparer delegate.
This sorting delegate determines the hit change, by calling GetHitChanceForObjectRef on object A and B, which is relatively slow, and calls it multiple times for the same objects, until the array is fully sorted.
The hit chance for the same object reference cannot change during one sorting pass, so pre-calculating the hit chances for visible enemies first. Then using that in the sorting delegate would decrease the number of calls drastically.
Before:
After:
Note that I used the override of UITacticalHUD_Enemies from 'WOTC_DisplayHitChange' to do my test, which was easier for now than to build a custom CHL.
The profiling was done on the exact same save, same conditions, same move. Reduced the number of calls in that one frame, from 378 to 48.
Not sure if the above implementation is ideal, that's the best I could do with my limited UnrealScript knowledge.
Maybe it's also possible with a class variable, then using CachedHitChanges.Find('Object', ObjectA) (which is a hashtable lookup?) inside SortEnemies.
discord: https://discord.com/channels/165245941664710656/165245941664710656/1137333029837209630
The text was updated successfully, but these errors were encountered: