Allow disabling terrain height checks in Missile

This saves a good deal of performance for mods with no real height levels, including RA, TD and D2k.
This commit is contained in:
reaperrr
2017-07-13 02:19:52 +02:00
parent 86ab6e7ed3
commit 7e8f920bc1

View File

@@ -61,6 +61,9 @@ namespace OpenRA.Mods.Common.Projectiles
[Desc("Is the missile blocked by actors with BlocksProjectiles: trait.")]
public readonly bool Blockable = true;
[Desc("Is the missile aware of terrain height levels. Only needed for mods with real, non-visual height levels.")]
public readonly bool TerrainHeightAware = false;
[Desc("Width of projectile (used for finding blocking actors).")]
public readonly WDist Width = new WDist(1);
@@ -317,14 +320,19 @@ namespace OpenRA.Mods.Common.Projectiles
var tarDistVec = targetPosition + offset - pos;
var relTarHorDist = tarDistVec.HorizontalLength;
int predClfHgt, predClfDist, lastHtChg, lastHt;
InclineLookahead(world, relTarHorDist, out predClfHgt, out predClfDist, out lastHtChg, out lastHt);
int predClfHgt = 0;
int predClfDist = 0;
int lastHtChg = 0;
int lastHt = 0;
if (info.TerrainHeightAware)
InclineLookahead(world, relTarHorDist, out predClfHgt, out predClfDist, out lastHtChg, out lastHt);
// Height difference between the incline height and missile height
var diffClfMslHgt = predClfHgt - pos.Z;
// Incline coming up
if (diffClfMslHgt >= 0 && predClfDist > 0)
if (info.TerrainHeightAware && diffClfMslHgt >= 0 && predClfDist > 0)
DetermineLaunchSpeedAndAngleForIncline(predClfDist, diffClfMslHgt, relTarHorDist, out speed, out vFacing);
else if (lastHt != 0)
{
@@ -559,7 +567,7 @@ namespace OpenRA.Mods.Common.Projectiles
// the missile hasn't been fired near a cliff) is simply finding the smallest
// vertical facing that allows for a smooth climb to the new terrain's height
// and coming in at predClfDist at exactly zero vertical facing
if (diffClfMslHgt >= 0 && !allowPassBy)
if (info.TerrainHeightAware && diffClfMslHgt >= 0 && !allowPassBy)
desiredVFacing = IncreaseAltitude(predClfDist, diffClfMslHgt, relTarHorDist, vFacing);
else if (relTarHorDist <= 3 * loopRadius || state == States.Hitting)
{
@@ -645,7 +653,7 @@ namespace OpenRA.Mods.Common.Projectiles
else
{
// Avoid the cliff edge
if (edgeVector.Length > loopRadius && lastHt > targetPosition.Z)
if (info.TerrainHeightAware && edgeVector.Length > loopRadius && lastHt > targetPosition.Z)
{
int vFac;
for (vFac = vFacing + 1; vFac <= vFacing + info.VerticalRateOfTurn - 1; vFac++)
@@ -718,8 +726,13 @@ namespace OpenRA.Mods.Common.Projectiles
WVec HomingTick(World world, WVec tarDistVec, int relTarHorDist)
{
int predClfHgt, predClfDist, lastHtChg, lastHt;
InclineLookahead(world, relTarHorDist, out predClfHgt, out predClfDist, out lastHtChg, out lastHt);
int predClfHgt = 0;
int predClfDist = 0;
int lastHtChg = 0;
int lastHt = 0;
if (info.TerrainHeightAware)
InclineLookahead(world, relTarHorDist, out predClfHgt, out predClfDist, out lastHtChg, out lastHt);
// Height difference between the incline height and missile height
var diffClfMslHgt = predClfHgt - pos.Z;