Refactor classes to structs

This commit is contained in:
teinarss
2020-07-06 20:27:24 +02:00
committed by abcdefg30
parent 544ac6cb33
commit d52e4793fe
4 changed files with 29 additions and 12 deletions

View File

@@ -117,7 +117,7 @@ namespace OpenRA
return GetEnumerator();
}
public sealed class CellRegionEnumerator : IEnumerator<CPos>
public struct CellRegionEnumerator : IEnumerator<CPos>
{
readonly CellRegion r;
@@ -128,9 +128,11 @@ namespace OpenRA
CPos current;
public CellRegionEnumerator(CellRegion region)
: this()
{
r = region;
Reset();
current = new MPos(u, v).ToCPos(r.gridType);
}
public bool MoveNext()

View File

@@ -76,7 +76,7 @@ namespace OpenRA
return GetEnumerator();
}
public sealed class ProjectedCellRegionEnumerator : IEnumerator<PPos>
public struct ProjectedCellRegionEnumerator : IEnumerator<PPos>
{
readonly ProjectedCellRegion r;
@@ -86,9 +86,11 @@ namespace OpenRA
PPos current;
public ProjectedCellRegionEnumerator(ProjectedCellRegion region)
: this()
{
r = region;
Reset();
current = new PPos(u, v);
}
public bool MoveNext()

View File

@@ -179,13 +179,14 @@ namespace OpenRA
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { return GetEnumerator(); }
}
class MultipleEnumerator : IEnumerator<T>
struct MultipleEnumerator : IEnumerator<T>
{
readonly List<Actor> actors;
readonly List<T> traits;
readonly uint actor;
int index;
public MultipleEnumerator(TraitContainer<T> container, uint actor)
: this()
{
actors = container.actors;
traits = container.traits;
@@ -236,7 +237,7 @@ namespace OpenRA
}
}
class AllEnumerable : IEnumerable<TraitPair<T>>
struct AllEnumerable : IEnumerable<TraitPair<T>>
{
readonly TraitContainer<T> container;
public AllEnumerable(TraitContainer<T> container) { this.container = container; }
@@ -244,12 +245,13 @@ namespace OpenRA
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { return GetEnumerator(); }
}
class AllEnumerator : IEnumerator<TraitPair<T>>
struct AllEnumerator : IEnumerator<TraitPair<T>>
{
readonly List<Actor> actors;
readonly List<T> traits;
int index;
public AllEnumerator(TraitContainer<T> container)
: this()
{
actors = container.actors;
traits = container.traits;