There are still lagspikes when having many organic NonGaia entities around when wolves are spawned.
Doing some time measuring shows that the GetNonGaiaEntities call only consumes about 3 milliseconds,
but the sorting of entities by distance and sending of commands consumes about half a second.
Tested using ExecQueryAroundPos from the RangeManager (which is also used by the Damage component) as discussed in IRC a couple of days ago in IRC
but that only ended up in 30 second freeze per wave!
Instead found two other optimizations:
- We only need to compare the 2D coordinates, as the height is entirely irrelevant on this flat map.
- We can more than reasonably assume that all wolves spawned on the same spawn point have the same position.
The optimization initially proposed in D184 to reduce targetCount from 3 to 2 didn't have any measurable performance impact at all!