- Rename Bits<T> to BitSet<T>.
- Implement set based helpers for BitSet<T>.
- When representing TargetTypes of ITargetable in various traits, use a BitSet<TargetableType> instead of HashSet<string> for better performance & reduced memory usage.
- Fix FieldLoader to trim input values when generating a BitSet<T>.
- Require T in BitSet<T> and BitSetAllocator<T> to be a class since it's just a marker value. This allows the JIT to instantiate generic code for these classes once, as they don't benefit from specialized code for T. (Typically JITs will generate shared code for all reference types, and unique code for every value type encountered).
penev discovered that the RulesetLoaded functions of projectiles were
never being called, meaning that their blocking calculations were not
properly accounting for actors with large hitboxes.
The best fix for this is to change FindActorsOnLine to always account
for the largest actor's hit radius, rather than forcing callers to pass
the largest radius. Per the comment in Util.cs, as a result, move this
computation to ActorMap. I decided to simplify by not making a separate
calculation for actors that block projectiles only; this may cause a
small performance degradation as the search space is a bit larger.
Similarly to this, I've removed the ability to specify a search radius
manually. Because this is only a search radius, setting a value smaller
than the largest eligible actor makes no sense; that would lead to
completely inconsistent blocking. Setting a larger value, on the other
hand, would make no difference.
CreateEffectWarhead was the only place in core code any of these search
radii were set, and that's because 0 was a mysterious magic value that
made the warhead incapable of hitting actors. I replaced it with a
boolean flag that more clearly indicates the actual behaviour.
Fixes#14151.
For all projectiles and warheads.
Not really a must for everything else, but for CreateEffectWarhead, the
ImpactTypes refactor (separate PR) makes it a bit harder to make the
warhead valid in every situation, so setting the victim scan to zero is the easiest way to disable scanning for actors completely.
Added a Damage class to pass damage value and damage(types) instead.
This removes a great amount of overhead and longterm opens possibilities to have damagetypes without warheads.
Originally, this was comparing distance beween pos and unit.CenterPosition with HitShape's OuterRadius. However, the OuterRadius can exceed the shape for Capsule and Rectangular shapes, so I tried to adress that a few months ago by using the DistanceFromEdge check instead. The approach was bogus, though. DistanceFromEdge just calculates the distance of a position to the edge, so by comparing it with the distance between pos and victim.CenterPosition in combination with using LengthSquared, it was entirely possible the explosion would be within the HitShape, but closer to the edge than the victim.CenterPosition and the check would return false.
Now we just check if DistanceFromEdge is 0 or negative, which means the impact is inside the HitShape.
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.
There aren't any actors in any shipping mod where a health radius larger
than 1c512 would be feasible, so no need to make the default larger than necessary.