Improve explosion determination.

This commit is contained in:
abc013
2020-10-30 16:12:33 +01:00
committed by Matthias Mailänder
parent f2797c711c
commit bb71b59e18

View File

@@ -205,12 +205,17 @@ namespace OpenRA.Mods.Common.Projectiles
lastPos = pos; lastPos = pos;
pos = WPos.LerpQuadratic(source, target, angle, ticks, length); pos = WPos.LerpQuadratic(source, target, angle, ticks, length);
if (ShouldExplode(world))
Explode(world);
}
bool ShouldExplode(World world)
{
// Check for walls or other blocking obstacles // Check for walls or other blocking obstacles
var shouldExplode = false;
if (info.Blockable && BlocksProjectiles.AnyBlockingActorsBetween(world, lastPos, pos, info.Width, out var blockedPos)) if (info.Blockable && BlocksProjectiles.AnyBlockingActorsBetween(world, lastPos, pos, info.Width, out var blockedPos))
{ {
pos = blockedPos; pos = blockedPos;
shouldExplode = true; return true;
} }
if (!string.IsNullOrEmpty(info.TrailImage) && --smokeTicks < 0) if (!string.IsNullOrEmpty(info.TrailImage) && --smokeTicks < 0)
@@ -231,9 +236,11 @@ namespace OpenRA.Mods.Common.Projectiles
if (flightLengthReached && shouldBounce) if (flightLengthReached && shouldBounce)
{ {
var terrainPos = world.Map.CellContaining(pos); var terrainPos = world.Map.CellContaining(pos);
shouldExplode |= info.InvalidBounceTerrain.Contains(world.Map.GetTerrainInfo(terrainPos).Type); if (info.InvalidBounceTerrain.Contains(world.Map.GetTerrainInfo(terrainPos).Type))
return true;
shouldExplode |= AnyValidTargetsInRadius(world, pos, info.Width, args.SourceActor, true); if (AnyValidTargetsInRadius(world, pos, info.Width, args.SourceActor, true))
return true;
target += (pos - source) * info.BounceRangeModifier / 100; target += (pos - source) * info.BounceRangeModifier / 100;
var dat = world.Map.DistanceAboveTerrain(target); var dat = world.Map.DistanceAboveTerrain(target);
@@ -247,17 +254,18 @@ namespace OpenRA.Mods.Common.Projectiles
} }
// Flight length reached / exceeded // Flight length reached / exceeded
shouldExplode |= flightLengthReached && !shouldBounce; if (flightLengthReached && !shouldBounce)
return true;
// Driving into cell with higher height level // Driving into cell with higher height level
shouldExplode |= world.Map.DistanceAboveTerrain(pos).Length < 0; if (world.Map.DistanceAboveTerrain(pos).Length < 0)
return true;
// After first bounce, check for targets each tick // After first bounce, check for targets each tick
if (remainingBounces < info.BounceCount) if (remainingBounces < info.BounceCount && AnyValidTargetsInRadius(world, pos, info.Width, args.SourceActor, true))
shouldExplode |= AnyValidTargetsInRadius(world, pos, info.Width, args.SourceActor, true); return true;
if (shouldExplode) return false;
Explode(world);
} }
public IEnumerable<IRenderable> Render(WorldRenderer wr) public IEnumerable<IRenderable> Render(WorldRenderer wr)