Kill Map.XOffset / Map.YOffset.
This commit is contained in:
@@ -505,8 +505,8 @@ namespace OpenRA.Editor
|
|||||||
}
|
}
|
||||||
|
|
||||||
e.Graphics.DrawRectangle(CordonPen,
|
e.Graphics.DrawRectangle(CordonPen,
|
||||||
Map.XOffset * TileSet.TileSize * Zoom + Offset.X,
|
Map.TopLeft.X * TileSet.TileSize * Zoom + Offset.X,
|
||||||
Map.YOffset * TileSet.TileSize * Zoom + Offset.Y,
|
Map.TopLeft.Y * TileSet.TileSize * Zoom + Offset.Y,
|
||||||
Map.Width * TileSet.TileSize * Zoom,
|
Map.Width * TileSet.TileSize * Zoom,
|
||||||
Map.Height * TileSet.TileSize * Zoom);
|
Map.Height * TileSet.TileSize * Zoom);
|
||||||
|
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ namespace OpenRA.Graphics
|
|||||||
|
|
||||||
int visibleRows = (int)(viewport.Height * 1f / Game.CellSize + 2);
|
int visibleRows = (int)(viewport.Height * 1f / Game.CellSize + 2);
|
||||||
|
|
||||||
int firstRow = (int)(viewport.Location.Y * 1f / Game.CellSize - map.YOffset);
|
int firstRow = (int)(viewport.Location.Y * 1f / Game.CellSize - map.TopLeft.Y);
|
||||||
int lastRow = firstRow + visibleRows;
|
int lastRow = firstRow + visibleRows;
|
||||||
|
|
||||||
if (lastRow < 0 || firstRow > map.Height)
|
if (lastRow < 0 || firstRow > map.Height)
|
||||||
@@ -81,11 +81,11 @@ namespace OpenRA.Graphics
|
|||||||
if (world.LocalPlayer != null && !world.LocalPlayer.Shroud.Disabled && world.LocalPlayer.Shroud.Bounds.HasValue)
|
if (world.LocalPlayer != null && !world.LocalPlayer.Shroud.Disabled && world.LocalPlayer.Shroud.Bounds.HasValue)
|
||||||
{
|
{
|
||||||
var r = world.LocalPlayer.Shroud.Bounds.Value;
|
var r = world.LocalPlayer.Shroud.Bounds.Value;
|
||||||
if (firstRow < r.Top - map.YOffset)
|
if (firstRow < r.Top - map.TopLeft.Y)
|
||||||
firstRow = r.Top - map.YOffset;
|
firstRow = r.Top - map.TopLeft.Y;
|
||||||
|
|
||||||
if (firstRow > r.Bottom - map.YOffset)
|
if (firstRow > r.Bottom - map.TopLeft.Y)
|
||||||
firstRow = r.Bottom - map.YOffset;
|
firstRow = r.Bottom - map.TopLeft.Y;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( lastRow < firstRow ) lastRow = firstRow;
|
if( lastRow < firstRow ) lastRow = firstRow;
|
||||||
|
|||||||
@@ -50,8 +50,6 @@ namespace OpenRA
|
|||||||
public string [,] CustomTerrain;
|
public string [,] CustomTerrain;
|
||||||
|
|
||||||
// Temporary compat hacks
|
// Temporary compat hacks
|
||||||
public int XOffset { get { return TopLeft.X; } }
|
|
||||||
public int YOffset { get { return TopLeft.Y; } }
|
|
||||||
public Rectangle Bounds { get { return Rectangle.FromLTRB(TopLeft.X, TopLeft.Y, BottomRight.X, BottomRight.Y); } }
|
public Rectangle Bounds { get { return Rectangle.FromLTRB(TopLeft.X, TopLeft.Y, BottomRight.X, BottomRight.Y); } }
|
||||||
|
|
||||||
public Map()
|
public Map()
|
||||||
|
|||||||
@@ -67,8 +67,8 @@ namespace OpenRA.Traits
|
|||||||
|
|
||||||
var map = w.Map;
|
var map = w.Map;
|
||||||
|
|
||||||
for (int x = map.XOffset; x < map.XOffset + map.Width; x++)
|
for (int x = map.TopLeft.X; x < map.BottomRight.X; x++)
|
||||||
for (int y = map.YOffset; y < map.YOffset + map.Height; y++)
|
for (int y = map.TopLeft.Y; y < map.BottomRight.Y; y++)
|
||||||
{
|
{
|
||||||
// Todo: Valid terrain should be specified in the resource
|
// Todo: Valid terrain should be specified in the resource
|
||||||
if (!AllowResourceAt(new int2(x,y)))
|
if (!AllowResourceAt(new int2(x,y)))
|
||||||
@@ -80,8 +80,8 @@ namespace OpenRA.Traits
|
|||||||
content[x, y].image = ChooseContent(content[x, y].type);
|
content[x, y].image = ChooseContent(content[x, y].type);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int x = map.XOffset; x < map.XOffset + map.Width; x++)
|
for (int x = map.TopLeft.X; x < map.BottomRight.X; x++)
|
||||||
for (int y = map.YOffset; y < map.YOffset + map.Height; y++)
|
for (int y = map.TopLeft.Y; y < map.BottomRight.Y; y++)
|
||||||
if (content[x, y].type != null)
|
if (content[x, y].type != null)
|
||||||
{
|
{
|
||||||
content[x, y].density = GetIdealDensity(x, y);
|
content[x, y].density = GetIdealDensity(x, y);
|
||||||
|
|||||||
@@ -48,10 +48,10 @@ namespace OpenRA.Traits
|
|||||||
{
|
{
|
||||||
var min = a - new int2(r, r);
|
var min = a - new int2(r, r);
|
||||||
var max = a + new int2(r, r);
|
var max = a + new int2(r, r);
|
||||||
if (min.X < world.Map.XOffset - 1) min.X = world.Map.XOffset - 1;
|
if (min.X < world.Map.TopLeft.X - 1) min.X = world.Map.TopLeft.X - 1;
|
||||||
if (min.Y < world.Map.YOffset - 1) min.Y = world.Map.YOffset - 1;
|
if (min.Y < world.Map.TopLeft.Y - 1) min.Y = world.Map.TopLeft.Y - 1;
|
||||||
if (max.X > world.Map.XOffset + world.Map.Width) max.X = world.Map.XOffset + world.Map.Width;
|
if (max.X > world.Map.BottomRight.X) max.X = world.Map.BottomRight.X;
|
||||||
if (max.Y > world.Map.YOffset + world.Map.Height) max.Y = world.Map.YOffset + world.Map.Height;
|
if (max.Y > world.Map.BottomRight.Y) max.Y = world.Map.BottomRight.Y;
|
||||||
|
|
||||||
for (var j = min.Y; j <= max.Y; j++)
|
for (var j = min.Y; j <= max.Y; j++)
|
||||||
for (var i = min.X; i <= max.X; i++)
|
for (var i = min.X; i <= max.X; i++)
|
||||||
|
|||||||
@@ -49,10 +49,10 @@ namespace OpenRA.Traits
|
|||||||
{
|
{
|
||||||
var bounds = a.Actor.GetBounds(true);
|
var bounds = a.Actor.GetBounds(true);
|
||||||
|
|
||||||
if (bounds.Right <= Game.CellSize * self.World.Map.XOffset) continue;
|
if (bounds.Right <= Game.CellSize * self.World.Map.TopLeft.X) continue;
|
||||||
if (bounds.Bottom <= Game.CellSize * self.World.Map.YOffset) continue;
|
if (bounds.Bottom <= Game.CellSize * self.World.Map.TopLeft.Y) continue;
|
||||||
if (bounds.Left >= Game.CellSize * (self.World.Map.XOffset + self.World.Map.Width)) continue;
|
if (bounds.Left >= Game.CellSize * self.World.Map.BottomRight.X) continue;
|
||||||
if (bounds.Top >= Game.CellSize * (self.World.Map.YOffset + self.World.Map.Height)) continue;
|
if (bounds.Top >= Game.CellSize * self.World.Map.BottomRight.Y) continue;
|
||||||
|
|
||||||
var i1 = Math.Max(0, (int)bounds.Left / scale);
|
var i1 = Math.Max(0, (int)bounds.Left / scale);
|
||||||
var i2 = Math.Min(bins.GetUpperBound(0), (int)bounds.Right / scale);
|
var i2 = Math.Min(bins.GetUpperBound(0), (int)bounds.Right / scale);
|
||||||
|
|||||||
@@ -54,10 +54,10 @@ namespace OpenRA
|
|||||||
{
|
{
|
||||||
var min = a - new int2(r, r);
|
var min = a - new int2(r, r);
|
||||||
var max = a + new int2(r, r);
|
var max = a + new int2(r, r);
|
||||||
if (min.X < world.Map.XOffset) min.X = world.Map.XOffset;
|
if (min.X < world.Map.TopLeft.X) min.X = world.Map.TopLeft.X;
|
||||||
if (min.Y < world.Map.YOffset) min.Y = world.Map.YOffset;
|
if (min.Y < world.Map.TopLeft.Y) min.Y = world.Map.TopLeft.Y;
|
||||||
if (max.X > world.Map.XOffset + world.Map.Width - 1) max.X = world.Map.XOffset + world.Map.Width - 1;
|
if (max.X > world.Map.BottomRight.X - 1) max.X = world.Map.BottomRight.X - 1;
|
||||||
if (max.Y > world.Map.YOffset + world.Map.Height - 1) max.Y = world.Map.YOffset + world.Map.Height - 1;
|
if (max.Y > world.Map.BottomRight.Y - 1) max.Y = world.Map.BottomRight.Y - 1;
|
||||||
|
|
||||||
for (var j = min.Y; j <= max.Y; j++)
|
for (var j = min.Y; j <= max.Y; j++)
|
||||||
for (var i = min.X; i <= max.X; i++)
|
for (var i = min.X; i <= max.X; i++)
|
||||||
@@ -103,17 +103,17 @@ namespace OpenRA
|
|||||||
var edge = w.SharedRandom.Next(2) == 0;
|
var edge = w.SharedRandom.Next(2) == 0;
|
||||||
|
|
||||||
return new int2(
|
return new int2(
|
||||||
isX ? w.SharedRandom.Next(w.Map.XOffset, w.Map.XOffset + w.Map.Width)
|
isX ? w.SharedRandom.Next(w.Map.TopLeft.X, w.Map.BottomRight.X)
|
||||||
: (edge ? w.Map.XOffset : w.Map.XOffset + w.Map.Width),
|
: (edge ? w.Map.TopLeft.X : w.Map.BottomRight.X),
|
||||||
!isX ? w.SharedRandom.Next(w.Map.YOffset, w.Map.YOffset + w.Map.Height)
|
!isX ? w.SharedRandom.Next(w.Map.TopLeft.Y, w.Map.BottomRight.Y)
|
||||||
: (edge ? w.Map.YOffset : w.Map.YOffset + w.Map.Height));
|
: (edge ? w.Map.TopLeft.Y : w.Map.BottomRight.Y));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int2 ChooseRandomCell(this World w, Thirdparty.Random r)
|
public static int2 ChooseRandomCell(this World w, Thirdparty.Random r)
|
||||||
{
|
{
|
||||||
return new int2(
|
return new int2(
|
||||||
r.Next(w.Map.XOffset, w.Map.XOffset + w.Map.Width),
|
r.Next(w.Map.TopLeft.X, w.Map.BottomRight.X),
|
||||||
r.Next(w.Map.YOffset, w.Map.YOffset + w.Map.Height));
|
r.Next(w.Map.TopLeft.Y, w.Map.BottomRight.Y));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IEnumerable<CountryInfo> GetCountries(this World w)
|
public static IEnumerable<CountryInfo> GetCountries(this World w)
|
||||||
|
|||||||
@@ -33,8 +33,8 @@ namespace OpenRA.Mods.Cnc
|
|||||||
var owner = self.Owner;
|
var owner = self.Owner;
|
||||||
|
|
||||||
// Start and end beyond the edge of the map, to give a finite delay, and ability to land when AFLD is on map edge
|
// Start and end beyond the edge of the map, to give a finite delay, and ability to land when AFLD is on map edge
|
||||||
var startPos = new int2(owner.World.Map.XOffset + owner.World.Map.Width+5, self.Location.Y);
|
var startPos = new int2(owner.World.Map.BottomRight.X + 5, self.Location.Y);
|
||||||
var endPos = new int2(owner.World.Map.XOffset-5, self.Location.Y);
|
var endPos = new int2(owner.World.Map.TopLeft.X - 5, self.Location.Y);
|
||||||
|
|
||||||
// Assume a single exit point for simplicity
|
// Assume a single exit point for simplicity
|
||||||
var exit = self.Info.Traits.WithInterface<ExitInfo>().First();
|
var exit = self.Info.Traits.WithInterface<ExitInfo>().First();
|
||||||
|
|||||||
Reference in New Issue
Block a user