Refactored in new enum SubCell
This commit is contained in:
@@ -41,7 +41,7 @@ namespace OpenRA.Mods.RA.Activities
|
||||
mobile.IsMoving = true;
|
||||
|
||||
from = self.CenterPosition;
|
||||
to = self.World.Map.CenterOfCell(targetMobile.fromCell) + self.World.Map.SubCellOffsets[targetMobile.fromSubCell];
|
||||
to = self.World.Map.CenterOf(targetMobile.fromCell, targetMobile.fromSubCell);
|
||||
length = Math.Max((to - from).Length / speed.Range, 1);
|
||||
|
||||
self.Trait<RenderInfantry>().Attacking(self, Target.FromActor(target));
|
||||
|
||||
@@ -32,15 +32,15 @@ namespace OpenRA.Mods.RA.Activities
|
||||
this.unloadAll = unloadAll;
|
||||
}
|
||||
|
||||
public Pair<CPos, int>? ChooseExitSubCell(Actor passenger)
|
||||
public Pair<CPos, SubCell>? ChooseExitSubCell(Actor passenger)
|
||||
{
|
||||
var pos = passenger.Trait<IPositionable>();
|
||||
|
||||
return cargo.CurrentAdjacentCells
|
||||
.Shuffle(self.World.SharedRandom)
|
||||
.Select(c => Pair.New(c, pos.GetAvailableSubcell(c, -1, null)))
|
||||
.Cast<Pair<CPos, int>?>()
|
||||
.FirstOrDefault(s => s.Value.Second >= 0);
|
||||
.Select(c => Pair.New(c, pos.GetAvailableSubcell(c, SubCell.AnySubCell, null)))
|
||||
.Cast<Pair<CPos, SubCell>?>()
|
||||
.FirstOrDefault(s => s.Value.Second != SubCell.InvalidSubCell);
|
||||
}
|
||||
|
||||
IEnumerable<CPos> BlockedExitCells(Actor passenger)
|
||||
@@ -86,9 +86,6 @@ namespace OpenRA.Mods.RA.Activities
|
||||
w.Add(actor);
|
||||
actor.CancelActivity();
|
||||
pos.SetVisualPosition(actor, spawn);
|
||||
var mobile = move as Mobile;
|
||||
if (mobile != null)
|
||||
mobile.SetLocation(exitSubCell.Value.First, exitSubCell.Value.Second, exitSubCell.Value.First, exitSubCell.Value.Second);
|
||||
actor.QueueActivity(move.MoveIntoWorld(actor, exitSubCell.Value.First, exitSubCell.Value.Second));
|
||||
actor.SetTargetLine(Target.FromCell(w, exitSubCell.Value.First, exitSubCell.Value.Second), Color.Green, false);
|
||||
});
|
||||
|
||||
@@ -46,7 +46,7 @@ namespace OpenRA.Mods.RA.Air
|
||||
|
||||
public class Aircraft : IFacing, IPositionable, ISync, INotifyKilled, IIssueOrder, IOrderVoice, INotifyAddedToWorld, INotifyRemovedFromWorld
|
||||
{
|
||||
static readonly Pair<CPos, int>[] NoCells = { };
|
||||
static readonly Pair<CPos, SubCell>[] NoCells = { };
|
||||
|
||||
readonly AircraftInfo info;
|
||||
readonly Actor self;
|
||||
@@ -170,7 +170,7 @@ namespace OpenRA.Mods.RA.Air
|
||||
}
|
||||
|
||||
// Changes position, but not altitude
|
||||
public void SetPosition(Actor self, CPos cell, int subCell = -1)
|
||||
public void SetPosition(Actor self, CPos cell, SubCell subCell = SubCell.AnySubCell)
|
||||
{
|
||||
SetPosition(self, self.World.Map.CenterOfCell(cell) + new WVec(0, 0, CenterPosition.Z));
|
||||
}
|
||||
@@ -199,8 +199,8 @@ namespace OpenRA.Mods.RA.Air
|
||||
|| info.RepairBuildings.Contains(a.Info.Name);
|
||||
}
|
||||
|
||||
public bool IsLeaving(CPos location, int subCell = -1) { return false; } // TODO: handle landing
|
||||
public int GetAvailableSubcell(CPos a, int preferredSubCell = -1, Actor ignoreActor = null, bool checkTransientActors = true) { return -1; } // does not use any subcell
|
||||
public bool IsLeaving(CPos location, SubCell subCell = SubCell.AnySubCell) { return false; } // TODO: Handle landing
|
||||
public SubCell GetAvailableSubcell(CPos a, SubCell preferredSubCell = SubCell.AnySubCell, Actor ignoreActor = null, bool checkTransientActors = true) { return SubCell.InvalidSubCell; } // Does not use any subcell
|
||||
public bool CanEnterCell(CPos cell, Actor ignoreActor = null, bool checkTransientActors = true) { return true; }
|
||||
|
||||
public int MovementSpeed
|
||||
@@ -213,7 +213,7 @@ namespace OpenRA.Mods.RA.Air
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<Pair<CPos, int>> OccupiedCells() { return NoCells; }
|
||||
public IEnumerable<Pair<CPos, SubCell>> OccupiedCells() { return NoCells; }
|
||||
|
||||
public WVec FlyStep(int facing)
|
||||
{
|
||||
|
||||
@@ -148,7 +148,7 @@ namespace OpenRA.Mods.RA.Air
|
||||
public Activity MoveFollow(Actor self, Target target, WRange minRange, WRange maxRange) { return new Follow(self, target, minRange, maxRange); }
|
||||
public CPos NearestMoveableCell(CPos cell) { return cell; }
|
||||
|
||||
public Activity MoveIntoWorld(Actor self, CPos cell, int subCell = -1)
|
||||
public Activity MoveIntoWorld(Actor self, CPos cell, SubCell subCell = SubCell.AnySubCell)
|
||||
{
|
||||
return new HeliFly(self, Target.FromCell(self.World, cell));
|
||||
}
|
||||
|
||||
@@ -127,7 +127,7 @@ namespace OpenRA.Mods.RA.Air
|
||||
public Activity MoveFollow(Actor self, Target target, WRange minRange, WRange maxRange) { return new FlyFollow(self, target, minRange, maxRange); }
|
||||
public CPos NearestMoveableCell(CPos cell) { return cell; }
|
||||
|
||||
public Activity MoveIntoWorld(Actor self, CPos cell, int subCell = -1) { return new Fly(self, Target.FromCell(self.World, cell)); }
|
||||
public Activity MoveIntoWorld(Actor self, CPos cell, SubCell subCell = SubCell.AnySubCell) { return new Fly(self, Target.FromCell(self.World, cell)); }
|
||||
public Activity VisualMove(Actor self, WPos fromPos, WPos toPos) { return Util.SequenceActivities(new CallFunc(() => SetVisualPosition(self, fromPos)), new Fly(self, Target.FromPos(toPos))); }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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, 0)).ToArray();
|
||||
.Select(c => Pair.New(c, SubCell.FullCell)).ToArray();
|
||||
|
||||
CenterPosition = init.world.Map.CenterOfCell(topLeft) + FootprintUtils.CenterOffset(init.world, Info);
|
||||
SkipMakeAnimation = init.Contains<SkipMakeAnimsInit>();
|
||||
}
|
||||
|
||||
Pair<CPos, int>[] occupiedCells;
|
||||
public IEnumerable<Pair<CPos, int>> OccupiedCells() { return occupiedCells; }
|
||||
Pair<CPos, SubCell>[] occupiedCells;
|
||||
public IEnumerable<Pair<CPos, SubCell>> OccupiedCells() { return occupiedCells; }
|
||||
|
||||
public void Created(Actor self)
|
||||
{
|
||||
|
||||
@@ -89,38 +89,38 @@ namespace OpenRA.Mods.RA
|
||||
}
|
||||
|
||||
public CPos TopLeft { get { return Location; } }
|
||||
public IEnumerable<Pair<CPos, int>> OccupiedCells() { yield return Pair.New(Location, 0); }
|
||||
public IEnumerable<Pair<CPos, SubCell>> OccupiedCells() { yield return Pair.New(Location, SubCell.FullCell); }
|
||||
|
||||
public WPos CenterPosition { get; private set; }
|
||||
public void SetPosition(Actor self, WPos pos) { SetPosition(self, self.World.Map.CellContaining(pos)); }
|
||||
public void SetVisualPosition(Actor self, WPos pos) { SetPosition(self, self.World.Map.CellContaining(pos)); }
|
||||
|
||||
public bool IsLeaving(CPos location, int subCell = -1) { return self.Location == location && ticks + 1 == info.Lifetime * 25; }
|
||||
public int GetAvailableSubcell(CPos cell, int preferredSubCell = -1, Actor ignoreActor = null, bool checkTransientActors = true)
|
||||
public bool IsLeaving(CPos location, SubCell subCell = SubCell.AnySubCell) { return self.Location == location && ticks + 1 == info.Lifetime * 25; }
|
||||
public SubCell GetAvailableSubcell(CPos cell, SubCell preferredSubCell = SubCell.AnySubCell, Actor ignoreActor = null, bool checkTransientActors = true)
|
||||
{
|
||||
if (!self.World.Map.Contains(cell)) return -1;
|
||||
if (!self.World.Map.Contains(cell)) return SubCell.InvalidSubCell;
|
||||
|
||||
var type = self.World.Map.GetTerrainInfo(cell).Type;
|
||||
if (!info.TerrainTypes.Contains(type))
|
||||
return -1;
|
||||
return SubCell.InvalidSubCell;
|
||||
|
||||
if (self.World.WorldActor.Trait<BuildingInfluence>().GetBuildingAt(cell) != null)
|
||||
return -1;
|
||||
return SubCell.InvalidSubCell;
|
||||
|
||||
if (!checkTransientActors)
|
||||
return 0;
|
||||
return SubCell.FullCell;
|
||||
|
||||
return !self.World.ActorMap.GetUnitsAt(cell)
|
||||
.Where(x => x != ignoreActor)
|
||||
.Any() ? 0 : -1;
|
||||
.Any() ? SubCell.FullCell : SubCell.InvalidSubCell;
|
||||
}
|
||||
|
||||
public bool CanEnterCell(CPos a, Actor ignoreActor = null, bool checkTransientActors = true)
|
||||
{
|
||||
return GetAvailableSubcell(a, -1, ignoreActor, checkTransientActors) >= 0;
|
||||
return GetAvailableSubcell(a, SubCell.AnySubCell, ignoreActor, checkTransientActors) != SubCell.InvalidSubCell;
|
||||
}
|
||||
|
||||
public void SetPosition(Actor self, CPos cell, int subCell = -1)
|
||||
public void SetPosition(Actor self, CPos cell, SubCell subCell = SubCell.AnySubCell)
|
||||
{
|
||||
self.World.ActorMap.RemoveInfluence(self, this);
|
||||
Location = cell;
|
||||
|
||||
@@ -52,30 +52,30 @@ namespace OpenRA.Mods.RA
|
||||
self.QueueActivity(new Drag(CenterPosition, finalPos, distance / speed));
|
||||
}
|
||||
|
||||
public IEnumerable<Pair<CPos, int>> OccupiedCells() { yield return Pair.New(TopLeft, 0); }
|
||||
public bool IsLeaving(CPos location, int subCell = -1) { return false; }
|
||||
public int GetAvailableSubcell(CPos cell, int preferredSubCell = -1, Actor ignoreActor = null, bool checkTransientActors = true)
|
||||
public IEnumerable<Pair<CPos, SubCell>> OccupiedCells() { yield return Pair.New(TopLeft, SubCell.FullCell); }
|
||||
public bool IsLeaving(CPos location, SubCell subCell = SubCell.AnySubCell) { return false; }
|
||||
public SubCell GetAvailableSubcell(CPos cell, SubCell preferredSubCell = SubCell.AnySubCell, Actor ignoreActor = null, bool checkTransientActors = true)
|
||||
{
|
||||
if (!self.World.Map.Contains(cell))
|
||||
return -1;
|
||||
return SubCell.InvalidSubCell;
|
||||
|
||||
if (!info.AllowedTerrain.Contains(self.World.Map.GetTerrainInfo(cell).Type))
|
||||
return -1;
|
||||
return SubCell.InvalidSubCell;
|
||||
|
||||
if (!checkTransientActors)
|
||||
return 0;
|
||||
return SubCell.FullCell;
|
||||
|
||||
return !self.World.ActorMap.GetUnitsAt(cell)
|
||||
.Where(x => x != ignoreActor)
|
||||
.Any() ? 0 : -1;
|
||||
.Any() ? SubCell.FullCell : SubCell.InvalidSubCell;
|
||||
}
|
||||
|
||||
public bool CanEnterCell(CPos a, Actor ignoreActor = null, bool checkTransientActors = true)
|
||||
{
|
||||
return GetAvailableSubcell(a, -1, ignoreActor, checkTransientActors) >= 0;
|
||||
return GetAvailableSubcell(a, SubCell.AnySubCell, ignoreActor, checkTransientActors) != SubCell.InvalidSubCell;
|
||||
}
|
||||
|
||||
public void SetPosition(Actor self, CPos cell, int subCell = -1) { SetPosition(self, self.World.Map.CenterOfCell(cell)); }
|
||||
public void SetPosition(Actor self, CPos cell, SubCell subCell = SubCell.AnySubCell) { SetPosition(self, self.World.Map.CenterOfCell(cell)); }
|
||||
|
||||
public void SetVisualPosition(Actor self, WPos pos)
|
||||
{
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace OpenRA.Mods.RA
|
||||
{
|
||||
[Sync] readonly CPos location;
|
||||
[Sync] readonly WPos position;
|
||||
readonly IEnumerable<Pair<CPos, int>> occupied;
|
||||
readonly IEnumerable<Pair<CPos, SubCell>> 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, 0) };
|
||||
occupied = new [] { Pair.New(TopLeft, SubCell.FullCell) };
|
||||
else
|
||||
occupied = new Pair<CPos, int>[0];
|
||||
occupied = new Pair<CPos, SubCell>[0];
|
||||
}
|
||||
|
||||
public CPos TopLeft { get { return location; } }
|
||||
public WPos CenterPosition { get { return position; } }
|
||||
public IEnumerable<Pair<CPos, int>> OccupiedCells() { return occupied; }
|
||||
public IEnumerable<Pair<CPos, SubCell>> OccupiedCells() { return occupied; }
|
||||
|
||||
public void AddedToWorld(Actor self)
|
||||
{
|
||||
|
||||
@@ -191,10 +191,10 @@ namespace OpenRA.Mods.RA.Move
|
||||
return true;
|
||||
}
|
||||
|
||||
public int GetAvailableSubCell(World world, Actor self, CPos cell, int preferredSubCell = -1, Actor ignoreActor = null, CellConditions check = CellConditions.All)
|
||||
public SubCell GetAvailableSubCell(World world, Actor self, CPos cell, SubCell preferredSubCell = SubCell.AnySubCell, Actor ignoreActor = null, CellConditions check = CellConditions.All)
|
||||
{
|
||||
if (MovementCostForCell(world, cell) == int.MaxValue)
|
||||
return -1;
|
||||
return SubCell.InvalidSubCell;
|
||||
|
||||
if (check.HasFlag(CellConditions.TransientActors))
|
||||
{
|
||||
@@ -219,13 +219,13 @@ namespace OpenRA.Mods.RA.Move
|
||||
};
|
||||
|
||||
if (!SharesCell)
|
||||
return world.ActorMap.AnyUnitsAt(cell, 0, checkTransient)? -1 : 0;
|
||||
return world.ActorMap.AnyUnitsAt(cell, SubCell.FullCell, checkTransient)? SubCell.InvalidSubCell : SubCell.FullCell;
|
||||
|
||||
return world.ActorMap.FreeSubCell(cell, preferredSubCell, checkTransient);
|
||||
}
|
||||
|
||||
if (!SharesCell)
|
||||
return world.ActorMap.AnyUnitsAt(cell, 0)? -1 : 0;
|
||||
return world.ActorMap.AnyUnitsAt(cell, SubCell.FullCell)? SubCell.InvalidSubCell : SubCell.FullCell;
|
||||
|
||||
return world.ActorMap.FreeSubCell(cell, preferredSubCell);
|
||||
}
|
||||
@@ -241,7 +241,7 @@ namespace OpenRA.Mods.RA.Move
|
||||
|
||||
int __facing;
|
||||
CPos __fromCell, __toCell;
|
||||
public int fromSubCell, toSubCell;
|
||||
public SubCell fromSubCell, toSubCell;
|
||||
|
||||
//int __altitude;
|
||||
|
||||
@@ -259,7 +259,7 @@ namespace OpenRA.Mods.RA.Move
|
||||
|
||||
[Sync] public int PathHash; // written by Move.EvalPath, to temporarily debug this crap.
|
||||
|
||||
public void SetLocation(CPos from, int fromSub, CPos to, int toSub)
|
||||
public void SetLocation(CPos from, SubCell fromSub, CPos to, SubCell toSub)
|
||||
{
|
||||
if (fromCell == from && toCell == to && fromSubCell == fromSub && toSubCell == toSub)
|
||||
return;
|
||||
@@ -281,16 +281,16 @@ namespace OpenRA.Mods.RA.Move
|
||||
this.self = init.self;
|
||||
this.Info = info;
|
||||
|
||||
toSubCell = fromSubCell = info.SharesCell ? init.world.Map.SubCellDefaultIndex : 0;
|
||||
toSubCell = fromSubCell = info.SharesCell ? init.world.Map.DefaultSubCell : SubCell.FullCell;
|
||||
if (init.Contains<SubCellInit>())
|
||||
{
|
||||
this.fromSubCell = this.toSubCell = init.Get<SubCellInit, int>();
|
||||
this.fromSubCell = this.toSubCell = init.Get<SubCellInit, SubCell>();
|
||||
}
|
||||
|
||||
if (init.Contains<LocationInit>())
|
||||
{
|
||||
this.__fromCell = this.__toCell = init.Get<LocationInit, CPos>();
|
||||
SetVisualPosition(self, init.world.Map.CenterOfCell(fromCell) + self.World.Map.SubCellOffsets[fromSubCell]);
|
||||
SetVisualPosition(self, init.world.Map.CenterOf(fromCell, fromSubCell));
|
||||
}
|
||||
|
||||
this.Facing = init.Contains<FacingInit>() ? init.Get<FacingInit, int>() : info.InitialFacing;
|
||||
@@ -301,19 +301,18 @@ namespace OpenRA.Mods.RA.Move
|
||||
SetVisualPosition(self, init.Get<CenterPositionInit, WPos>());
|
||||
}
|
||||
|
||||
public void SetPosition(Actor self, CPos cell, int subCell = -1)
|
||||
public void SetPosition(Actor self, CPos cell, SubCell subCell = SubCell.AnySubCell)
|
||||
{
|
||||
// Try same sub-cell
|
||||
if (subCell < 0)
|
||||
if (subCell == SubCell.AnySubCell)
|
||||
subCell = fromSubCell;
|
||||
|
||||
// Fix sub-cell assignment
|
||||
if (Info.SharesCell != (subCell != 0))
|
||||
subCell = Info.SharesCell ? self.World.Map.SubCellDefaultIndex : 0;
|
||||
if (Info.SharesCell != (subCell != SubCell.FullCell))
|
||||
subCell = Info.SharesCell ? self.World.Map.DefaultSubCell : SubCell.FullCell;
|
||||
|
||||
SetLocation(cell, subCell, cell, subCell);
|
||||
SetVisualPosition(self, self.World.Map.CenterOfCell(cell)
|
||||
+ self.World.Map.SubCellOffsets[subCell]);
|
||||
SetVisualPosition(self, self.World.Map.CenterOf(cell, subCell));
|
||||
FinishedMoving(self);
|
||||
}
|
||||
|
||||
@@ -456,7 +455,7 @@ namespace OpenRA.Mods.RA.Move
|
||||
|
||||
public CPos TopLeft { get { return toCell; } }
|
||||
|
||||
public IEnumerable<Pair<CPos, int>> OccupiedCells()
|
||||
public IEnumerable<Pair<CPos, SubCell>> OccupiedCells()
|
||||
{
|
||||
if (fromCell == toCell)
|
||||
yield return Pair.New(fromCell, fromSubCell);
|
||||
@@ -469,13 +468,13 @@ namespace OpenRA.Mods.RA.Move
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsLeaving(CPos location, int subCell = -1)
|
||||
public bool IsLeaving(CPos location, SubCell subCell = SubCell.AnySubCell)
|
||||
{
|
||||
return toCell != location && __fromCell == location
|
||||
&& (subCell == -1 || fromSubCell == subCell || subCell == 0 || fromSubCell == 0);
|
||||
&& (subCell == SubCell.AnySubCell || fromSubCell == subCell || subCell == SubCell.FullCell || fromSubCell == SubCell.FullCell);
|
||||
}
|
||||
|
||||
public int GetAvailableSubcell(CPos a, int preferredSubCell, Actor ignoreActor = null, bool checkTransientActors = true)
|
||||
public SubCell GetAvailableSubcell(CPos a, SubCell preferredSubCell = SubCell.AnySubCell, Actor ignoreActor = null, bool checkTransientActors = true)
|
||||
{
|
||||
return Info.GetAvailableSubCell(self.World, self, a, preferredSubCell, ignoreActor, checkTransientActors? CellConditions.All : CellConditions.None);
|
||||
}
|
||||
@@ -629,23 +628,23 @@ namespace OpenRA.Mods.RA.Move
|
||||
Nudge(self, blocking, true);
|
||||
}
|
||||
|
||||
public Activity MoveIntoWorld(Actor self, CPos cell, int subCell = -1)
|
||||
public Activity MoveIntoWorld(Actor self, CPos cell, SubCell subCell = SubCell.AnySubCell)
|
||||
{
|
||||
var pos = self.CenterPosition;
|
||||
|
||||
if (subCell == -1)
|
||||
if (subCell == SubCell.AnySubCell)
|
||||
subCell = self.World.ActorMap.FreeSubCell(cell, subCell);
|
||||
|
||||
// TODO: solve/reduce cell is full problem
|
||||
if (subCell < 0)
|
||||
subCell = self.World.Map.SubCellDefaultIndex;
|
||||
if (subCell == SubCell.InvalidSubCell)
|
||||
subCell = self.World.Map.DefaultSubCell;
|
||||
|
||||
// Reserve the exit cell
|
||||
SetPosition(self, cell, subCell);
|
||||
SetVisualPosition(self, pos);
|
||||
|
||||
// Animate transition
|
||||
var to = self.World.Map.CenterOfCell(cell) + self.World.Map.SubCellOffsets[subCell];
|
||||
var to = self.World.Map.CenterOf(cell, subCell);
|
||||
var speed = MovementSpeedForCell(self, cell);
|
||||
var length = speed > 0 ? (to - pos).Length / speed : 0;
|
||||
|
||||
|
||||
@@ -57,10 +57,10 @@ namespace OpenRA.Mods.RA.Move
|
||||
this.nearEnough = nearEnough;
|
||||
}
|
||||
|
||||
public Move(CPos destination, int subCell, WRange nearEnough)
|
||||
public Move(CPos destination, SubCell subCell, WRange nearEnough)
|
||||
{
|
||||
this.getPath = (self, mobile) => self.World.WorldActor.Trait<PathFinder>()
|
||||
.FindUnitPathToRange(mobile.fromCell, subCell, self.World.Map.CenterOfCell(destination) + self.World.Map.SubCellOffsets[subCell], nearEnough, self);
|
||||
.FindUnitPathToRange(mobile.fromCell, subCell, self.World.Map.CenterOf(destination, subCell), nearEnough, self);
|
||||
this.destination = destination;
|
||||
this.nearEnough = nearEnough;
|
||||
}
|
||||
@@ -158,8 +158,8 @@ namespace OpenRA.Mods.RA.Move
|
||||
mobile.SetLocation(mobile.fromCell, mobile.fromSubCell, nextCell.Value.First, nextCell.Value.Second);
|
||||
var move = new MoveFirstHalf(
|
||||
this,
|
||||
self.World.Map.CenterOfCell(mobile.fromCell) + self.World.Map.SubCellOffsets[mobile.fromSubCell],
|
||||
Util.BetweenCells(self.World, mobile.fromCell, mobile.toCell) + (self.World.Map.SubCellOffsets[mobile.fromSubCell] + self.World.Map.SubCellOffsets[mobile.toSubCell]) / 2,
|
||||
self.World.Map.CenterOf(mobile.fromCell, mobile.fromSubCell),
|
||||
Util.BetweenCells(self.World, mobile.fromCell, mobile.toCell) + (self.World.Map.OffsetOf(mobile.fromSubCell) + self.World.Map.OffsetOf(mobile.toSubCell)) / 2,
|
||||
mobile.Facing,
|
||||
mobile.Facing,
|
||||
0);
|
||||
@@ -188,7 +188,7 @@ namespace OpenRA.Mods.RA.Move
|
||||
}
|
||||
}
|
||||
|
||||
Pair<CPos, int>? PopPath(Actor self, Mobile mobile)
|
||||
Pair<CPos, SubCell>? PopPath(Actor self, Mobile mobile)
|
||||
{
|
||||
if (path.Count == 0)
|
||||
return null;
|
||||
@@ -245,7 +245,7 @@ namespace OpenRA.Mods.RA.Move
|
||||
hasWaited = false;
|
||||
path.RemoveAt(path.Count - 1);
|
||||
|
||||
var subCell = mobile.GetAvailableSubcell(nextCell, -1, ignoreBuilding);
|
||||
var subCell = mobile.GetAvailableSubcell(nextCell, SubCell.AnySubCell, ignoreBuilding);
|
||||
return Pair.New(nextCell, subCell);
|
||||
}
|
||||
|
||||
@@ -355,15 +355,15 @@ namespace OpenRA.Mods.RA.Move
|
||||
|
||||
protected override MovePart OnComplete(Actor self, Mobile mobile, Move parent)
|
||||
{
|
||||
var fromSubcellOffset = self.World.Map.SubCellOffsets[mobile.fromSubCell];
|
||||
var toSubcellOffset = self.World.Map.SubCellOffsets[mobile.toSubCell];
|
||||
var fromSubcellOffset = self.World.Map.OffsetOf(mobile.fromSubCell);
|
||||
var toSubcellOffset = self.World.Map.OffsetOf(mobile.toSubCell);
|
||||
|
||||
var nextCell = parent.PopPath(self, mobile);
|
||||
if (nextCell != null)
|
||||
{
|
||||
if (IsTurn(mobile, nextCell.Value.First))
|
||||
{
|
||||
var nextSubcellOffset = self.World.Map.SubCellOffsets[nextCell.Value.Second];
|
||||
var nextSubcellOffset = self.World.Map.OffsetOf(nextCell.Value.Second);
|
||||
var ret = new MoveFirstHalf(
|
||||
move,
|
||||
Util.BetweenCells(self.World, mobile.fromCell, mobile.toCell) + (fromSubcellOffset + toSubcellOffset) / 2,
|
||||
|
||||
@@ -80,7 +80,7 @@ namespace OpenRA.Mods.RA.Move
|
||||
}
|
||||
}
|
||||
|
||||
public List<CPos> FindUnitPathToRange(CPos src, int srcSub, WPos target, WRange range, Actor self)
|
||||
public List<CPos> FindUnitPathToRange(CPos src, SubCell srcSub, WPos target, WRange range, Actor self)
|
||||
{
|
||||
using (new PerfSample("Pathfinder"))
|
||||
{
|
||||
@@ -89,7 +89,7 @@ namespace OpenRA.Mods.RA.Move
|
||||
var rangeSquared = range.Range*range.Range;
|
||||
|
||||
// Correct for SubCell offset
|
||||
target -= self.World.Map.SubCellOffsets[srcSub];
|
||||
target -= self.World.Map.OffsetOf(srcSub);
|
||||
|
||||
// Select only the tiles that are within range from the requested SubCell
|
||||
// This assumes that the SubCell does not change during the path traversal
|
||||
|
||||
Reference in New Issue
Block a user