This custom collection allows other classes to implement a Player to value mapping, but also stores the values in an array for faster lookup by the player index in the world. For some code, this improved lookup time is important for performance.
Move self.IsDisabled right after IsInWorld and IsTraitDisabled checks.
This should skip/avoid a lot of the following checks when actors are disabled by low power, EMP or similar, potentially saving some performance when there are many disabled actors with attack trait.
Move IsValidFor before HasAnyValidWeapons because the latter is more
expensive.
This fixes the issue where AttackMove (and possibly other order modes) would not work properly when people were clicking their mouse buttons at the same time. A move order (the default order mode) would be issued instead.
Avoid using LINQ for filtering, grouping and dictionary building. Instead, we do these ourselves to reduce overhead.
Actors are checked for AutoTargetIgnoreInfo (rather than the trait) since info checks are marginally faster. This check can now be done immediately to allow us to skip such actors right away.
The ClosestTo calculation is now only run on the group on actors for the selected armament, rather than all potential armaments.
Remove the unused onlyEnabled parameter to avoid it needlessly being captured in the closure, and simplify the logic.
Evaluate RequiresForceFire and Weapon.IsValidAgainst last in their respective logic chains as these are the most expensive operations and benefit from short-circuiting being able to skip their evaluation.
This can be used to avoid several lookups for these traits, as well as allow Actor to provide specialised methods to deal with target types efficiently. This also reduces some code duplication.
The previous lazy rendering means the snapshot of the render state might be more up to date then when the frozen actor actually did become visible. Now, we take this snapshot as soon as needed. We still retain the performance of only doing this rendering when needed by avoiding extra rendering until the visibility cycles again.