Refactor handling of hit radii in projectiles.
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.
This commit is contained in:
@@ -26,7 +26,7 @@ namespace OpenRA.Mods.Common
|
||||
/// <param name="lineEnd">The position the line should end at</param>
|
||||
/// <param name="lineWidth">How close an actor's health radius needs to be to the line to be considered 'intersected' by the line</param>
|
||||
/// <returns>A list of all the actors intersected by the line</returns>
|
||||
public static IEnumerable<Actor> FindActorsOnLine(this World world, WPos lineStart, WPos lineEnd, WDist lineWidth, WDist targetExtraSearchRadius)
|
||||
public static IEnumerable<Actor> FindActorsOnLine(this World world, WPos lineStart, WPos lineEnd, WDist lineWidth)
|
||||
{
|
||||
// This line intersection check is done by first just finding all actors within a square that starts at the source, and ends at the target.
|
||||
// Then we iterate over this list, and find all actors for which their health radius is at least within lineWidth of the line.
|
||||
@@ -39,7 +39,7 @@ namespace OpenRA.Mods.Common
|
||||
var yDir = yDiff < 0 ? -1 : 1;
|
||||
|
||||
var dir = new WVec(xDir, yDir, 0);
|
||||
var overselect = dir * (1024 + lineWidth.Length + targetExtraSearchRadius.Length);
|
||||
var overselect = dir * (1024 + lineWidth.Length + world.ActorMap.LargestActorRadius.Length);
|
||||
var finalTarget = lineEnd + overselect;
|
||||
var finalSource = lineStart - overselect;
|
||||
|
||||
@@ -64,6 +64,14 @@ namespace OpenRA.Mods.Common
|
||||
return intersectedActors;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Finds all the actors of which their health radius is intersected by a specified circle.
|
||||
/// </summary>
|
||||
public static IEnumerable<Actor> FindActorsOnCircle(this World world, WPos origin, WDist r)
|
||||
{
|
||||
return world.FindActorsInCircle(origin, r + world.ActorMap.LargestActorRadius);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Find the point (D) on a line (A-B) that is closest to the target point (C).
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user