Replace MapGrid.CellCorners with a new CellRamp struct.

This commit is contained in:
Paul Chote
2020-04-28 00:52:40 +01:00
committed by atlimit8
parent 4614f6febe
commit 5af12440ba
3 changed files with 126 additions and 73 deletions

View File

@@ -63,24 +63,27 @@ namespace OpenRA.Mods.Common.Traits
continue;
var height = (int)map.Height[uv];
var corners = map.Grid.CellCorners[map.Ramp[uv]];
var r = map.Grid.Ramps[map.Ramp[uv]];
var pos = map.CenterOfCell(uv.ToCPos(map));
var width = uv == mouseCell ? 3 : 1;
// Colors change between points, so render separately
for (var i = 0; i < 4; i++)
foreach (var p in r.Polygons)
{
var j = (i + 1) % 4;
var start = pos + corners[i];
var end = pos + corners[j];
var startColor = colors[height + corners[i].Z / 512];
var endColor = colors[height + corners[j].Z / 512];
yield return new LineAnnotationRenderable(start, end, width, startColor, endColor);
for (var i = 0; i < p.Length; i++)
{
var j = (i + 1) % p.Length;
var start = pos + p[i];
var end = pos + p[j];
var startColor = colors[height + p[i].Z / 512];
var endColor = colors[height + p[j].Z / 512];
yield return new LineAnnotationRenderable(start, end, width, startColor, endColor);
}
}
}
// Projected cell coordinates for the current cell
var projectedCorners = map.Grid.CellCorners[0];
var projectedCorners = map.Grid.Ramps[0].Corners;
foreach (var puv in map.ProjectedCellsCovering(mouseCell))
{
var pos = map.CenterOfCell(((MPos)puv).ToCPos(map));