Skip to content

Commit

Permalink
Add ramp support to DistanceAboveTerrain and Move.
Browse files Browse the repository at this point in the history
  • Loading branch information
pchote committed May 2, 2020
1 parent 73665a4 commit 739f3c4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
9 changes: 8 additions & 1 deletion OpenRA.Game/Map/Map.cs
Expand Up @@ -821,7 +821,14 @@ public WDist DistanceAboveTerrain(WPos pos)
{
var cell = CellContaining(pos);
var delta = pos - CenterOfCell(cell);
return new WDist(delta.Z);

// No correction is needed for flat ground
var ti = Rules.TileSet.GetTileInfo(Tiles[cell]);
if (ti == null || ti.RampType == 0)
return new WDist(delta.Z);

// Apply ramp offset
return Grid.Ramps[ti.RampType].DistanceAboveTerrain(delta);
}

public WVec Offset(CVec delta, int dz)
Expand Down
1 change: 1 addition & 0 deletions OpenRA.Mods.Common/Activities/Move/Move.cs
Expand Up @@ -464,6 +464,7 @@ void UpdateCenterLocation(Actor self, Mobile mobile)
else
pos = WPos.Lerp(From, To, moveFraction, MoveFractionTotal);

pos -= new WVec(WDist.Zero, WDist.Zero, self.World.Map.DistanceAboveTerrain(pos));
mobile.SetVisualPosition(self, pos);
}
else
Expand Down

0 comments on commit 739f3c4

Please sign in to comment.