enum SubCell => int & Dictionary<SubCell, WVec> => WVec[]
This commit is contained in:
@@ -63,7 +63,7 @@ namespace OpenRA.Mods.RA.Activities
|
||||
var exitCell = ChooseExitCell(actor);
|
||||
if (exitCell == null)
|
||||
{
|
||||
foreach (var blocker in BlockedExitCells(actor).SelectMany(self.World.ActorMap.GetUnitsAt))
|
||||
foreach (var blocker in BlockedExitCells(actor).SelectMany(p => self.World.ActorMap.GetUnitsAt(p)))
|
||||
{
|
||||
foreach (var nbm in blocker.TraitsImplementing<INotifyBlockingMove>())
|
||||
nbm.OnNotifyBlockingMove(blocker, self);
|
||||
|
||||
@@ -46,7 +46,7 @@ namespace OpenRA.Mods.RA.Air
|
||||
|
||||
public class Aircraft : IFacing, IPositionable, ISync, INotifyKilled, IIssueOrder, IOrderVoice, INotifyAddedToWorld, INotifyRemovedFromWorld
|
||||
{
|
||||
static readonly Pair<CPos, SubCell>[] NoCells = { };
|
||||
static readonly Pair<CPos, int>[] NoCells = { };
|
||||
|
||||
readonly AircraftInfo info;
|
||||
readonly Actor self;
|
||||
@@ -210,7 +210,7 @@ namespace OpenRA.Mods.RA.Air
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<Pair<CPos, SubCell>> OccupiedCells() { return NoCells; }
|
||||
public IEnumerable<Pair<CPos, int>> OccupiedCells() { return NoCells; }
|
||||
|
||||
public WVec FlyStep(int facing)
|
||||
{
|
||||
|
||||
@@ -133,14 +133,14 @@ namespace OpenRA.Mods.RA.Buildings
|
||||
this.Info = info;
|
||||
|
||||
occupiedCells = FootprintUtils.UnpathableTiles( self.Info.Name, Info, TopLeft )
|
||||
.Select(c => Pair.New(c, SubCell.FullCell)).ToArray();
|
||||
.Select(c => Pair.New(c, 0)).ToArray();
|
||||
|
||||
CenterPosition = init.world.Map.CenterOfCell(topLeft) + FootprintUtils.CenterOffset(init.world, Info);
|
||||
SkipMakeAnimation = init.Contains<SkipMakeAnimsInit>();
|
||||
}
|
||||
|
||||
Pair<CPos, SubCell>[] occupiedCells;
|
||||
public IEnumerable<Pair<CPos, SubCell>> OccupiedCells() { return occupiedCells; }
|
||||
Pair<CPos, int>[] occupiedCells;
|
||||
public IEnumerable<Pair<CPos, int>> OccupiedCells() { return occupiedCells; }
|
||||
|
||||
public void Created(Actor self)
|
||||
{
|
||||
|
||||
@@ -89,7 +89,7 @@ namespace OpenRA.Mods.RA
|
||||
}
|
||||
|
||||
public CPos TopLeft { get { return Location; } }
|
||||
public IEnumerable<Pair<CPos, SubCell>> OccupiedCells() { yield return Pair.New(Location, SubCell.FullCell); }
|
||||
public IEnumerable<Pair<CPos, int>> OccupiedCells() { yield return Pair.New(Location, 0); }
|
||||
|
||||
public WPos CenterPosition { get; private set; }
|
||||
public void SetPosition(Actor self, WPos pos) { SetPosition(self, self.World.Map.CellContaining(pos)); }
|
||||
|
||||
@@ -52,7 +52,7 @@ namespace OpenRA.Mods.RA
|
||||
self.QueueActivity(new Drag(CenterPosition, finalPos, distance / speed));
|
||||
}
|
||||
|
||||
public IEnumerable<Pair<CPos, SubCell>> OccupiedCells() { yield return Pair.New(TopLeft, SubCell.FullCell); }
|
||||
public IEnumerable<Pair<CPos, int>> OccupiedCells() { yield return Pair.New(TopLeft, 0); }
|
||||
public bool CanEnterCell(CPos cell, Actor ignoreActor, bool checkTransientActors)
|
||||
{
|
||||
if (!self.World.Map.Contains(cell))
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace OpenRA.Mods.RA
|
||||
{
|
||||
[Sync] readonly CPos location;
|
||||
[Sync] readonly WPos position;
|
||||
readonly IEnumerable<Pair<CPos, SubCell>> occupied;
|
||||
readonly IEnumerable<Pair<CPos, int>> occupied;
|
||||
|
||||
public Immobile(ActorInitializer init, ImmobileInfo info)
|
||||
{
|
||||
@@ -32,14 +32,14 @@ namespace OpenRA.Mods.RA
|
||||
position = init.world.Map.CenterOfCell(location);
|
||||
|
||||
if (info.OccupiesSpace)
|
||||
occupied = new [] { Pair.New(TopLeft, SubCell.FullCell) };
|
||||
occupied = new [] { Pair.New(TopLeft, 0) };
|
||||
else
|
||||
occupied = new Pair<CPos, SubCell>[0];
|
||||
occupied = new Pair<CPos, int>[0];
|
||||
}
|
||||
|
||||
public CPos TopLeft { get { return location; } }
|
||||
public WPos CenterPosition { get { return position; } }
|
||||
public IEnumerable<Pair<CPos, SubCell>> OccupiedCells() { return occupied; }
|
||||
public IEnumerable<Pair<CPos, int>> OccupiedCells() { return occupied; }
|
||||
|
||||
public void AddedToWorld(Actor self)
|
||||
{
|
||||
|
||||
@@ -133,14 +133,14 @@ namespace OpenRA.Mods.RA.Move
|
||||
return TilesetMovementClass[tileset];
|
||||
}
|
||||
|
||||
public static readonly Dictionary<SubCell, WVec> SubCellOffsets = new Dictionary<SubCell, WVec>()
|
||||
public static readonly WVec[] SubCellOffsets =
|
||||
{
|
||||
{SubCell.TopLeft, new WVec(-299, -256, 0)},
|
||||
{SubCell.TopRight, new WVec(256, -256, 0)},
|
||||
{SubCell.Center, new WVec(0, 0, 0)},
|
||||
{SubCell.BottomLeft, new WVec(-299, 256, 0)},
|
||||
{SubCell.BottomRight, new WVec(256, 256, 0)},
|
||||
{SubCell.FullCell, new WVec(0, 0, 0)},
|
||||
new WVec(0, 0, 0),
|
||||
new WVec(-299, -256, 0),
|
||||
new WVec(256, -256, 0),
|
||||
new WVec(0, 0, 0),
|
||||
new WVec(-299, 256, 0),
|
||||
new WVec(256, 256, 0),
|
||||
};
|
||||
|
||||
static bool IsMovingInMyDirection(Actor self, Actor other)
|
||||
@@ -208,7 +208,7 @@ namespace OpenRA.Mods.RA.Move
|
||||
|
||||
int __facing;
|
||||
CPos __fromCell, __toCell;
|
||||
public SubCell fromSubCell, toSubCell;
|
||||
public int fromSubCell, toSubCell;
|
||||
|
||||
//int __altitude;
|
||||
|
||||
@@ -226,7 +226,7 @@ namespace OpenRA.Mods.RA.Move
|
||||
|
||||
[Sync] public int PathHash; // written by Move.EvalPath, to temporarily debug this crap.
|
||||
|
||||
public void SetLocation(CPos from, SubCell fromSub, CPos to, SubCell toSub)
|
||||
public void SetLocation(CPos from, int fromSub, CPos to, int toSub)
|
||||
{
|
||||
if (fromCell == from && toCell == to && fromSubCell == fromSub && toSubCell == toSub)
|
||||
return;
|
||||
@@ -248,10 +248,11 @@ namespace OpenRA.Mods.RA.Move
|
||||
this.self = init.self;
|
||||
this.Info = info;
|
||||
|
||||
toSubCell = fromSubCell = info.SharesCell ? SubCell.Center : SubCell.FullCell;
|
||||
// TODO replace 3 w/ SubCellDefaultIndex
|
||||
toSubCell = fromSubCell = info.SharesCell ? 3 : 0;
|
||||
if (init.Contains<SubCellInit>())
|
||||
{
|
||||
this.fromSubCell = this.toSubCell = init.Get<SubCellInit, SubCell>();
|
||||
this.fromSubCell = this.toSubCell = init.Get<SubCellInit, int>();
|
||||
}
|
||||
|
||||
if (init.Contains<LocationInit>())
|
||||
@@ -414,7 +415,7 @@ namespace OpenRA.Mods.RA.Move
|
||||
|
||||
public CPos TopLeft { get { return toCell; } }
|
||||
|
||||
public IEnumerable<Pair<CPos, SubCell>> OccupiedCells()
|
||||
public IEnumerable<Pair<CPos, int>> OccupiedCells()
|
||||
{
|
||||
if (fromCell == toCell)
|
||||
yield return Pair.New(fromCell, fromSubCell);
|
||||
@@ -427,14 +428,13 @@ namespace OpenRA.Mods.RA.Move
|
||||
}
|
||||
}
|
||||
|
||||
public SubCell GetDesiredSubcell(CPos a, Actor ignoreActor)
|
||||
public int GetDesiredSubcell(CPos a, Actor ignoreActor)
|
||||
{
|
||||
if (!Info.SharesCell)
|
||||
return SubCell.FullCell;
|
||||
return 0;
|
||||
|
||||
// Prioritise the current subcell
|
||||
return new[]{ fromSubCell, SubCell.TopLeft, SubCell.TopRight, SubCell.Center,
|
||||
SubCell.BottomLeft, SubCell.BottomRight}.First(b =>
|
||||
return new[]{ fromSubCell, 1, 2, 3, 4, 5}.First(b =>
|
||||
{
|
||||
var blockingActors = self.World.ActorMap.GetUnitsAt(a, b).Where(c => c != ignoreActor);
|
||||
if (blockingActors.Any())
|
||||
|
||||
@@ -180,7 +180,7 @@ namespace OpenRA.Mods.RA.Move
|
||||
}
|
||||
}
|
||||
|
||||
Pair<CPos, SubCell>? PopPath(Actor self, Mobile mobile)
|
||||
Pair<CPos, int>? PopPath(Actor self, Mobile mobile)
|
||||
{
|
||||
if (path.Count == 0)
|
||||
return null;
|
||||
|
||||
@@ -80,7 +80,7 @@ namespace OpenRA.Mods.RA.Move
|
||||
}
|
||||
}
|
||||
|
||||
public List<CPos> FindUnitPathToRange(CPos src, SubCell srcSub, WPos target, WRange range, Actor self)
|
||||
public List<CPos> FindUnitPathToRange(CPos src, int srcSub, WPos target, WRange range, Actor self)
|
||||
{
|
||||
using (new PerfSample("Pathfinder"))
|
||||
{
|
||||
|
||||
@@ -61,7 +61,7 @@ namespace OpenRA.Mods.RA
|
||||
throw new InvalidOperationException("No cells available to spawn starting unit {0}".F(s));
|
||||
|
||||
var cell = validCells.Random(w.SharedRandom);
|
||||
var subCell = mi.SharesCell ? w.ActorMap.FreeSubCell(cell).Value : SubCell.FullCell;
|
||||
var subCell = mi.SharesCell ? w.ActorMap.FreeSubCell(cell).Value : 0;
|
||||
|
||||
w.CreateActor(s.ToLowerInvariant(), new TypeDictionary
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user