Implement height-aware map.ChooseRandomCell().

This commit is contained in:
Paul Chote
2015-07-26 19:30:57 +01:00
parent c2cbf7c79d
commit e337710221

View File

@@ -999,11 +999,16 @@ namespace OpenRA
public CPos ChooseRandomCell(MersenneTwister rand) public CPos ChooseRandomCell(MersenneTwister rand)
{ {
// TODO: Account for terrain height MPos[] cells;
var x = rand.Next(Bounds.Left, Bounds.Right); do
var y = rand.Next(Bounds.Top, Bounds.Bottom); {
var u = rand.Next(Bounds.Left, Bounds.Right);
var v = rand.Next(Bounds.Top, Bounds.Bottom);
return new MPos(x, y).ToCPos(this); cells = Unproject(new PPos(u, v));
} while (!cells.Any());
return cells.Random(rand).ToCPos(TileShape);
} }
public CPos ChooseClosestEdgeCell(CPos pos) public CPos ChooseClosestEdgeCell(CPos pos)