enum SubCell => int & Dictionary<SubCell, WVec> => WVec[]

This commit is contained in:
atlimit8
2014-07-29 08:33:46 -05:00
parent e3d85f29c9
commit 43478dd500
13 changed files with 41 additions and 46 deletions

View File

@@ -63,13 +63,12 @@ namespace OpenRA
public CPos Value(World world) { return value; }
}
public class SubCellInit : IActorInit<SubCell>
public class SubCellInit : IActorInit<int>
{
[FieldFromYamlKey] public readonly int value = 0;
public SubCellInit() { }
public SubCellInit(int init) { value = init; }
public SubCellInit(SubCell init) { value = (int)init; }
public SubCell Value(World world) { return (SubCell)value; }
public int Value(World world) { return value; }
}
public class CenterPositionInit : IActorInit<WPos>

View File

@@ -126,7 +126,7 @@ namespace OpenRA.Traits
{
WPos CenterPosition { get; }
CPos TopLeft { get; }
IEnumerable<Pair<CPos, SubCell>> OccupiedCells();
IEnumerable<Pair<CPos, int>> OccupiedCells();
}
public static class IOccupySpaceExts

View File

@@ -29,15 +29,11 @@ namespace OpenRA.Traits
class InfluenceNode
{
public InfluenceNode Next;
public SubCell SubCell;
public int SubCell;
public Actor Actor;
}
static readonly SubCell[] SubCells =
{
SubCell.TopLeft, SubCell.TopRight, SubCell.Center,
SubCell.BottomLeft, SubCell.BottomRight
};
static readonly int[] SubCells = { 1, 2, 3, 4, 5 };
readonly ActorMapInfo info;
readonly Map map;
@@ -79,13 +75,13 @@ namespace OpenRA.Traits
yield return i.Actor;
}
public IEnumerable<Actor> GetUnitsAt(CPos a, SubCell sub)
public IEnumerable<Actor> GetUnitsAt(CPos a, int sub)
{
if (!map.Contains(a))
yield break;
for (var i = influence[a]; i != null; i = i.Next)
if (!i.Actor.Destroyed && (i.SubCell == sub || i.SubCell == SubCell.FullCell))
if (!i.Actor.Destroyed && (i.SubCell == sub || i.SubCell == 0))
yield return i.Actor;
}
@@ -97,7 +93,7 @@ namespace OpenRA.Traits
return SubCells.Any(b => !AnyUnitsAt(a, b));
}
public SubCell? FreeSubCell(CPos a)
public int? FreeSubCell(CPos a)
{
if (!HasFreeSubCell(a))
return null;
@@ -110,10 +106,10 @@ namespace OpenRA.Traits
return influence[a] != null;
}
public bool AnyUnitsAt(CPos a, SubCell sub)
public bool AnyUnitsAt(CPos a, int sub)
{
for (var i = influence[a]; i != null; i = i.Next)
if (i.SubCell == sub || i.SubCell == SubCell.FullCell)
if (i.SubCell == sub || i.SubCell == 0)
return true;
return false;