Fix IDE0032

This commit is contained in:
RoosterDragon
2023-02-19 11:19:28 +00:00
committed by Pavel Penev
parent e64c0a35c5
commit 98c4eaca83
52 changed files with 460 additions and 567 deletions

View File

@@ -126,15 +126,12 @@ namespace OpenRA
// Current position, in map coordinates
int u, v;
// Current position, in cell coordinates
CPos current;
public CellRegionEnumerator(CellRegion region)
: this()
{
r = region;
Reset();
current = new MPos(u, v).ToCPos(r.gridType);
Current = new MPos(u, v).ToCPos(r.gridType);
}
public bool MoveNext()
@@ -152,7 +149,8 @@ namespace OpenRA
return false;
}
current = new MPos(u, v).ToCPos(r.gridType);
// Current position, in cell coordinates
Current = new MPos(u, v).ToCPos(r.gridType);
return true;
}
@@ -163,7 +161,7 @@ namespace OpenRA
v = r.mapTopLeft.V;
}
public CPos Current => current;
public CPos Current { get; private set; }
object IEnumerator.Current => Current;
public void Dispose() { }
}

View File

@@ -19,7 +19,6 @@ namespace OpenRA
public struct MapCoordsEnumerator : IEnumerator<MPos>
{
readonly MapCoordsRegion r;
MPos current;
public MapCoordsEnumerator(MapCoordsRegion region)
: this()
@@ -30,41 +29,38 @@ namespace OpenRA
public bool MoveNext()
{
var u = current.U + 1;
var v = current.V;
var u = Current.U + 1;
var v = Current.V;
// Check for column overflow
if (u > r.bottomRight.U)
if (u > r.BottomRight.U)
{
v += 1;
u = r.topLeft.U;
u = r.TopLeft.U;
// Check for row overflow
if (v > r.bottomRight.V)
if (v > r.BottomRight.V)
return false;
}
current = new MPos(u, v);
Current = new MPos(u, v);
return true;
}
public void Reset()
{
current = new MPos(r.topLeft.U - 1, r.topLeft.V);
Current = new MPos(r.TopLeft.U - 1, r.TopLeft.V);
}
public MPos Current => current;
public MPos Current { get; private set; }
object IEnumerator.Current => Current;
public void Dispose() { }
}
readonly MPos topLeft;
readonly MPos bottomRight;
public MapCoordsRegion(MPos mapTopLeft, MPos mapBottomRight)
{
topLeft = mapTopLeft;
bottomRight = mapBottomRight;
TopLeft = mapTopLeft;
BottomRight = mapBottomRight;
}
public override string ToString()
@@ -87,7 +83,7 @@ namespace OpenRA
return GetEnumerator();
}
public MPos TopLeft => topLeft;
public MPos BottomRight => bottomRight;
public MPos TopLeft { get; }
public MPos BottomRight { get; }
}
}

View File

@@ -83,14 +83,12 @@ namespace OpenRA
// Current position, in projected map coordinates
int u, v;
PPos current;
public ProjectedCellRegionEnumerator(ProjectedCellRegion region)
: this()
{
r = region;
Reset();
current = new PPos(u, v);
Current = new PPos(u, v);
}
public bool MoveNext()
@@ -108,7 +106,7 @@ namespace OpenRA
return false;
}
current = new PPos(u, v);
Current = new PPos(u, v);
return true;
}
@@ -119,7 +117,7 @@ namespace OpenRA
v = r.TopLeft.V;
}
public PPos Current => current;
public PPos Current { get; private set; }
object IEnumerator.Current => Current;
public void Dispose() { }
}