Move ChooseRandomEdgeCell from WorldUtils to Map

This commit is contained in:
Pavlos Touboulidis
2014-06-13 14:31:01 +03:00
parent 060d5326ed
commit 86febed0ce
7 changed files with 19 additions and 21 deletions

View File

@@ -558,11 +558,21 @@ namespace OpenRA
return xy.Clamp(new Rectangle(r.X, r.Y, r.Width - 1, r.Height - 1));
}
public CPos ChooseRandomCell(MersenneTwister r)
public CPos ChooseRandomCell(MersenneTwister rand)
{
return new CPos(
r.Next(Bounds.Left, Bounds.Right),
r.Next(Bounds.Top, Bounds.Bottom));
rand.Next(Bounds.Left, Bounds.Right),
rand.Next(Bounds.Top, Bounds.Bottom));
}
public CPos ChooseRandomEdgeCell(MersenneTwister rand)
{
var isX = rand.Next(2) == 0;
var edge = rand.Next(2) == 0;
return new CPos(
isX ? rand.Next(Bounds.Left, Bounds.Right) : (edge ? Bounds.Left : Bounds.Right),
!isX ? rand.Next(Bounds.Top, Bounds.Bottom) : (edge ? Bounds.Top : Bounds.Bottom));
}
public WRange DistanceToEdge(WPos pos, WVec dir)