move some MobileInfo-related bits onto MobileInfo

This commit is contained in:
Chris Forbes
2010-12-27 18:41:07 +13:00
parent 31b98c0eb4
commit 9d768fa1c1
5 changed files with 337 additions and 330 deletions

View File

@@ -63,7 +63,7 @@ namespace OpenRA.Mods.RA.Crates
var mi = Rules.Info[Info.Unit].Traits.GetOrDefault<MobileInfo>(); var mi = Rules.Info[Info.Unit].Traits.GetOrDefault<MobileInfo>();
for (var i = -1; i < 2; i++) for (var i = -1; i < 2; i++)
for (var j = -1; j < 2; j++) for (var j = -1; j < 2; j++)
if (Mobile.CanEnterCell(self.World, mi, near + new int2(i, j), null, true)) if (mi.CanEnterCell(self.World, near + new int2(i, j), null, true))
yield return near + new int2(i, j); yield return near + new int2(i, j);
} }

View File

@@ -22,376 +22,383 @@ using OpenRA.Traits;
namespace OpenRA.Mods.RA.Move namespace OpenRA.Mods.RA.Move
{ {
public class MobileInfo : ITraitInfo public class MobileInfo : ITraitInfo
{ {
[FieldLoader.LoadUsing( "LoadSpeeds" )] [FieldLoader.LoadUsing("LoadSpeeds")]
public readonly Dictionary<string, TerrainInfo> TerrainSpeeds; public readonly Dictionary<string, TerrainInfo> TerrainSpeeds;
[FieldLoader.Load] public readonly string[] Crushes; [FieldLoader.Load]
[FieldLoader.Load] public readonly int WaitAverage = 60; public readonly string[] Crushes;
[FieldLoader.Load] public readonly int WaitSpread = 20; [FieldLoader.Load]
[FieldLoader.Load] public readonly int InitialFacing = 128; public readonly int WaitAverage = 60;
[FieldLoader.Load] public readonly int ROT = 255; [FieldLoader.Load]
[FieldLoader.Load] public readonly int Speed = 1; public readonly int WaitSpread = 20;
[FieldLoader.Load] public readonly bool OnRails = false; [FieldLoader.Load]
public readonly int InitialFacing = 128;
[FieldLoader.Load]
public readonly int ROT = 255;
[FieldLoader.Load]
public readonly int Speed = 1;
[FieldLoader.Load]
public readonly bool OnRails = false;
public virtual object Create(ActorInitializer init) { return new Mobile(init, this); } public virtual object Create(ActorInitializer init) { return new Mobile(init, this); }
static object LoadSpeeds( MiniYaml y )
{
Dictionary<string,TerrainInfo> ret = new Dictionary<string, TerrainInfo>();
foreach (var t in y.NodesDict["TerrainSpeeds"].Nodes)
{
var speed = (decimal)FieldLoader.GetValue("speed", typeof(decimal),t.Value.Value);
var cost = t.Value.NodesDict.ContainsKey("PathingCost") ? (int)FieldLoader.GetValue("cost", typeof(int), t.Value.NodesDict["PathingCost"].Value) : (int)(10000/speed);
ret.Add(t.Key, new TerrainInfo{Speed = speed, Cost = cost});
}
return ret;
}
public class TerrainInfo
{
public int Cost = int.MaxValue;
public decimal Speed = 0;
}
}
public class Mobile : IIssueOrder, IResolveOrder, IOrderVoice, IOccupySpace, IMove, IFacing, INudge
{
public readonly Actor self;
public readonly MobileInfo Info;
public bool IsMoving { get; internal set; }
int __facing; static object LoadSpeeds(MiniYaml y)
int2 __fromCell, __toCell; {
int __altitude; Dictionary<string, TerrainInfo> ret = new Dictionary<string, TerrainInfo>();
foreach (var t in y.NodesDict["TerrainSpeeds"].Nodes)
{
var speed = (decimal)FieldLoader.GetValue("speed", typeof(decimal), t.Value.Value);
var cost = t.Value.NodesDict.ContainsKey("PathingCost") ? (int)FieldLoader.GetValue("cost", typeof(int), t.Value.NodesDict["PathingCost"].Value) : (int)(10000 / speed);
ret.Add(t.Key, new TerrainInfo { Speed = speed, Cost = cost });
}
[Sync] return ret;
public int Facing }
{
get { return __facing; }
set { __facing = value; }
}
[Sync] public class TerrainInfo
public int Altitude {
{ public int Cost = int.MaxValue;
get { return __altitude; } public decimal Speed = 0;
set { __altitude = value; } }
}
public int ROT { get { return Info.ROT; } }
public int InitialFacing { get { return Info.InitialFacing; } }
[Sync] public int MovementCostForCell(World world, int2 cell)
public int2 PxPosition { get; set; } {
[Sync] if (!world.Map.IsInMap(cell.X, cell.Y))
public int2 fromCell { get { return __fromCell; } } return int.MaxValue;
[Sync]
public int2 toCell { get { return __toCell; } }
[Sync] var type = world.GetTerrainType(cell);
public int PathHash; // written by Move.EvalPath, to temporarily debug this crap. if (!TerrainSpeeds.ContainsKey(type))
return int.MaxValue;
public void SetLocation(int2 from, int2 to) return TerrainSpeeds[type].Cost;
{ }
if (fromCell == from && toCell == to) return;
RemoveInfluence();
__fromCell = from;
__toCell = to;
AddInfluence();
}
UnitInfluence uim; public bool CanEnterCell(World world, UnitInfluence uim, int2 cell, Actor ignoreActor, bool checkTransientActors)
{
if (MovementCostForCell(world, cell) == int.MaxValue)
return false;
const int avgTicksBeforePathing = 5; var blockingActors = uim.GetUnitsAt(cell).Where(x => x != ignoreActor).ToList();
const int spreadTicksBeforePathing = 5; if (checkTransientActors && blockingActors.Count > 0)
internal int ticksBeforePathing = 0; {
// We can enter a cell with nonshareable units only if we can crush all of them
public Mobile(ActorInitializer init, MobileInfo info) if (Crushes == null)
{ return false;
this.self = init.self;
this.Info = info;
uim = self.World.WorldActor.Trait<UnitInfluence>();
if (init.Contains<LocationInit>())
{
this.__fromCell = this.__toCell = init.Get<LocationInit,int2>();
this.PxPosition = Util.CenterOfCell( fromCell );
}
this.Facing = init.Contains<FacingInit>() ? init.Get<FacingInit,int>() : info.InitialFacing;
this.Altitude = init.Contains<AltitudeInit>() ? init.Get<AltitudeInit,int>() : 0;
}
public void SetPosition(Actor self, int2 cell) if (blockingActors.Any(a => !(a.HasTrait<ICrushable>() &&
{ a.TraitsImplementing<ICrushable>().Any(b => b.CrushClasses.Intersect(Crushes).Any()))))
SetLocation( cell, cell ); return false;
PxPosition = Util.CenterOfCell(fromCell); }
FinishedMoving(self);
}
public void SetPxPosition( Actor self, int2 px ) return true;
{ }
var cell = Util.CellContaining( px );
SetLocation( cell, cell );
PxPosition = px;
FinishedMoving(self);
}
public IEnumerable<IOrderTargeter> Orders { get { yield return new MoveOrderTargeter( Info ); } } public bool CanEnterCell(World world, int2 cell, Actor ignoreActor, bool checkTransientActors)
{
var uim = world.WorldActor.Trait<UnitInfluence>();
return CanEnterCell(world, uim, cell, ignoreActor, checkTransientActors);
}
}
// Note: Returns a valid order even if the unit can't move to the target public class Mobile : IIssueOrder, IResolveOrder, IOrderVoice, IOccupySpace, IMove, IFacing, INudge
public Order IssueOrder( Actor self, IOrderTargeter order, Target target, bool queued ) {
{ public readonly Actor self;
if( order is MoveOrderTargeter ) public readonly MobileInfo Info;
{ public bool IsMoving { get; internal set; }
if( Info.OnRails ) return null;
return new Order( "Move", self, queued ) { TargetLocation = Util.CellContaining( target.CenterLocation ) };
}
return null;
}
public int2 NearestMoveableCell(int2 target) int __facing;
{ int2 __fromCell, __toCell;
if (CanEnterCell(target)) int __altitude;
return target;
var searched = new List<int2>(){};
// Limit search to a radius of 10 tiles
for (int r = 1; r < 10; r++)
foreach (var tile in self.World.FindTilesInCircle(target,r).Except(searched))
{
if (CanEnterCell(tile))
return tile;
searched.Add(tile);
}
// Couldn't find a cell
return target;
}
protected void PerformMove(Actor self, int2 targetLocation, bool queued) [Sync]
{ public int Facing
var ph = new QueuedActivity( {
(qa) => get { return __facing; }
{ set { __facing = value; }
int2 currentLocation = NearestMoveableCell(targetLocation); }
if (!CanEnterCell(currentLocation)) [Sync]
{ public int Altitude
if (queued) self.CancelActivity(); {
return; get { return __altitude; }
} set { __altitude = value; }
}
if (!queued) self.CancelActivity(); public int ROT { get { return Info.ROT; } }
public int InitialFacing { get { return Info.InitialFacing; } }
ticksBeforePathing = avgTicksBeforePathing + self.World.SharedRandom.Next(-spreadTicksBeforePathing, spreadTicksBeforePathing); [Sync]
public int2 PxPosition { get; set; }
[Sync]
public int2 fromCell { get { return __fromCell; } }
[Sync]
public int2 toCell { get { return __toCell; } }
qa.Insert(new Move(currentLocation, 8)); [Sync]
public int PathHash; // written by Move.EvalPath, to temporarily debug this crap.
self.SetTargetLine(Target.FromCell(currentLocation), Color.Green);
});
self.QueueActivity(queued ? ph : ph.Run(self)); public void SetLocation(int2 from, int2 to)
} {
if (fromCell == from && toCell == to) return;
RemoveInfluence();
__fromCell = from;
__toCell = to;
AddInfluence();
}
public void ResolveOrder(Actor self, Order order) UnitInfluence uim;
{
if (order.OrderString == "Move")
{
var target = order.TargetLocation.Clamp(self.World.Map.Bounds);
PerformMove(self, target, order.Queued && !self.IsIdle);
}
if (order.OrderString == "Stop") const int avgTicksBeforePathing = 5;
{ const int spreadTicksBeforePathing = 5;
self.CancelActivity(); internal int ticksBeforePathing = 0;
}
}
public string VoicePhraseForOrder(Actor self, Order order)
{
if (order.OrderString == "Move")
return "Move";
return null;
}
public int2 TopLeft { get { return toCell; } } public Mobile(ActorInitializer init, MobileInfo info)
{
this.self = init.self;
this.Info = info;
public IEnumerable<int2> OccupiedCells() uim = self.World.WorldActor.Trait<UnitInfluence>();
{
return (fromCell == toCell)
? new[] { fromCell }
: CanEnterCell(toCell)
? new[] { toCell }
: new[] { fromCell, toCell };
}
public bool CanEnterCell(int2 p) if (init.Contains<LocationInit>())
{ {
return CanEnterCell( p, null, true); this.__fromCell = this.__toCell = init.Get<LocationInit, int2>();
} this.PxPosition = Util.CenterOfCell(fromCell);
}
public static bool CanEnterCell( World world, MobileInfo mi, int2 cell, Actor ignoreActor, bool checkTransientActors ) this.Facing = init.Contains<FacingInit>() ? init.Get<FacingInit, int>() : info.InitialFacing;
{ this.Altitude = init.Contains<AltitudeInit>() ? init.Get<AltitudeInit, int>() : 0;
var uim = world.WorldActor.Trait<UnitInfluence>(); }
return Mobile.CanEnterCell( mi, world, uim, cell, ignoreActor, checkTransientActors );
}
public bool CanEnterCell( int2 cell, Actor ignoreActor, bool checkTransientActors )
{
var uim = self.World.WorldActor.Trait<UnitInfluence>();
return CanEnterCell( Info, self.World, uim, cell, ignoreActor, checkTransientActors );
}
public static bool CanEnterCell( MobileInfo mobileInfo, World world, UnitInfluence uim, int2 cell, Actor ignoreActor, bool checkTransientActors ) public void SetPosition(Actor self, int2 cell)
{ {
if (MovementCostForCell(mobileInfo, world, cell) == int.MaxValue) SetLocation(cell, cell);
return false; PxPosition = Util.CenterOfCell(fromCell);
FinishedMoving(self);
}
var blockingActors = uim.GetUnitsAt( cell ).Where( x => x != ignoreActor ).ToList(); public void SetPxPosition(Actor self, int2 px)
if (checkTransientActors && blockingActors.Count > 0) {
{ var cell = Util.CellContaining(px);
// We can enter a cell with nonshareable units only if we can crush all of them SetLocation(cell, cell);
if (mobileInfo.Crushes == null) PxPosition = px;
return false; FinishedMoving(self);
}
if (blockingActors.Any(a => !(a.HasTrait<ICrushable>() && public IEnumerable<IOrderTargeter> Orders { get { yield return new MoveOrderTargeter(Info); } }
a.TraitsImplementing<ICrushable>().Any(b => b.CrushClasses.Intersect(mobileInfo.Crushes).Any()))))
return false;
}
return true; // Note: Returns a valid order even if the unit can't move to the target
} public Order IssueOrder(Actor self, IOrderTargeter order, Target target, bool queued)
{
public void FinishedMoving(Actor self) if (order is MoveOrderTargeter)
{ {
var crushable = uim.GetUnitsAt(toCell).Where(a => a != self && a.HasTrait<ICrushable>()); if (Info.OnRails) return null;
foreach (var a in crushable) return new Order("Move", self, queued) { TargetLocation = Util.CellContaining(target.CenterLocation) };
{ }
var crushActions = a.TraitsImplementing<ICrushable>().Where(b => b.CrushClasses.Intersect(Info.Crushes).Any()); return null;
foreach (var b in crushActions) }
b.OnCrush(self);
}
}
public static int MovementCostForCell(MobileInfo info, World world, int2 cell) public int2 NearestMoveableCell(int2 target)
{ {
if (!world.Map.IsInMap(cell.X,cell.Y)) if (CanEnterCell(target))
return int.MaxValue; return target;
var type = world.GetTerrainType(cell); var searched = new List<int2>() { };
if (!info.TerrainSpeeds.ContainsKey(type)) // Limit search to a radius of 10 tiles
return int.MaxValue; for (int r = 1; r < 10; r++)
foreach (var tile in self.World.FindTilesInCircle(target, r).Except(searched))
return info.TerrainSpeeds[type].Cost; {
} if (CanEnterCell(tile))
return tile;
public int MovementSpeedForCell(Actor self, int2 cell) searched.Add(tile);
{ }
var type = self.World.GetTerrainType(cell);
if (!Info.TerrainSpeeds.ContainsKey(type))
return 0;
decimal speed = Info.Speed * Info.TerrainSpeeds[type].Speed; // Couldn't find a cell
foreach( var t in self.TraitsImplementing<ISpeedModifier>() ) return target;
speed *= t.GetSpeedModifier(); }
return (int)(speed / 100);
}
public void AddInfluence()
{
if( self.IsInWorld )
uim.Add( self, this );
}
public void RemoveInfluence()
{
if( self.IsInWorld )
uim.Remove( self, this );
}
public void OnNudge(Actor self, Actor nudger) protected void PerformMove(Actor self, int2 targetLocation, bool queued)
{ {
/* initial fairly braindead implementation. */ var ph = new QueuedActivity(
(qa) =>
{
int2 currentLocation = NearestMoveableCell(targetLocation);
if (self.Owner.Stances[nudger.Owner] != Stance.Ally) if (!CanEnterCell(currentLocation))
return; /* don't allow ourselves to be pushed around {
if (queued) self.CancelActivity();
return;
}
if (!queued) self.CancelActivity();
ticksBeforePathing = avgTicksBeforePathing + self.World.SharedRandom.Next(-spreadTicksBeforePathing, spreadTicksBeforePathing);
qa.Insert(new Move(currentLocation, 8));
self.SetTargetLine(Target.FromCell(currentLocation), Color.Green);
});
self.QueueActivity(queued ? ph : ph.Run(self));
}
public void ResolveOrder(Actor self, Order order)
{
if (order.OrderString == "Move")
{
var target = order.TargetLocation.Clamp(self.World.Map.Bounds);
PerformMove(self, target, order.Queued && !self.IsIdle);
}
if (order.OrderString == "Stop")
{
self.CancelActivity();
}
}
public string VoicePhraseForOrder(Actor self, Order order)
{
if (order.OrderString == "Move")
return "Move";
return null;
}
public int2 TopLeft { get { return toCell; } }
public IEnumerable<int2> OccupiedCells()
{
return (fromCell == toCell)
? new[] { fromCell }
: CanEnterCell(toCell)
? new[] { toCell }
: new[] { fromCell, toCell };
}
public bool CanEnterCell(int2 p)
{
return CanEnterCell(p, null, true);
}
public bool CanEnterCell(int2 cell, Actor ignoreActor, bool checkTransientActors)
{
var uim = self.World.WorldActor.Trait<UnitInfluence>();
return Info.CanEnterCell(self.World, uim, cell, ignoreActor, checkTransientActors);
}
public void FinishedMoving(Actor self)
{
var crushable = uim.GetUnitsAt(toCell).Where(a => a != self && a.HasTrait<ICrushable>());
foreach (var a in crushable)
{
var crushActions = a.TraitsImplementing<ICrushable>().Where(b => b.CrushClasses.Intersect(Info.Crushes).Any());
foreach (var b in crushActions)
b.OnCrush(self);
}
}
public int MovementSpeedForCell(Actor self, int2 cell)
{
var type = self.World.GetTerrainType(cell);
if (!Info.TerrainSpeeds.ContainsKey(type))
return 0;
decimal speed = Info.Speed * Info.TerrainSpeeds[type].Speed;
foreach (var t in self.TraitsImplementing<ISpeedModifier>())
speed *= t.GetSpeedModifier();
return (int)(speed / 100);
}
public void AddInfluence()
{
if (self.IsInWorld)
uim.Add(self, this);
}
public void RemoveInfluence()
{
if (self.IsInWorld)
uim.Remove(self, this);
}
public void OnNudge(Actor self, Actor nudger)
{
/* initial fairly braindead implementation. */
if (self.Owner.Stances[nudger.Owner] != Stance.Ally)
return; /* don't allow ourselves to be pushed around
* by the enemy! */ * by the enemy! */
if (!self.IsIdle) if (!self.IsIdle)
return; /* don't nudge if we're busy doing something! */ return; /* don't nudge if we're busy doing something! */
// pick an adjacent available cell. // pick an adjacent available cell.
var availCells = new List<int2>(); var availCells = new List<int2>();
var notStupidCells = new List<int2>(); var notStupidCells = new List<int2>();
for( var i = -1; i < 2; i++ ) for (var i = -1; i < 2; i++)
for (var j = -1; j < 2; j++) for (var j = -1; j < 2; j++)
{ {
var p = toCell + new int2(i, j); var p = toCell + new int2(i, j);
if (CanEnterCell(p)) if (CanEnterCell(p))
availCells.Add(p); availCells.Add(p);
else else
if (p != nudger.Location && p != toCell) if (p != nudger.Location && p != toCell)
notStupidCells.Add(p); notStupidCells.Add(p);
} }
var moveTo = availCells.Any() ? availCells.Random(self.World.SharedRandom) : var moveTo = availCells.Any() ? availCells.Random(self.World.SharedRandom) :
notStupidCells.Any() ? notStupidCells.Random(self.World.SharedRandom) : (int2?)null; notStupidCells.Any() ? notStupidCells.Random(self.World.SharedRandom) : (int2?)null;
if (moveTo.HasValue) if (moveTo.HasValue)
{ {
self.CancelActivity(); self.CancelActivity();
self.SetTargetLine(Target.FromCell(moveTo.Value), Color.Green, false); self.SetTargetLine(Target.FromCell(moveTo.Value), Color.Green, false);
self.QueueActivity(new Move(moveTo.Value, 0)); self.QueueActivity(new Move(moveTo.Value, 0));
Log.Write("debug", "OnNudge #{0} from {1} to {2}", Log.Write("debug", "OnNudge #{0} from {1} to {2}",
self.ActorID, self.Location, moveTo.Value); self.ActorID, self.Location, moveTo.Value);
} }
else else
Log.Write("debug", "OnNudge #{0} refuses at {1}", Log.Write("debug", "OnNudge #{0} refuses at {1}",
self.ActorID, self.Location); self.ActorID, self.Location);
} }
class MoveOrderTargeter : IOrderTargeter class MoveOrderTargeter : IOrderTargeter
{ {
readonly MobileInfo unitType; readonly MobileInfo unitType;
public MoveOrderTargeter( MobileInfo unitType ) public MoveOrderTargeter(MobileInfo unitType)
{ {
this.unitType = unitType; this.unitType = unitType;
} }
public string OrderID { get { return "Move"; } } public string OrderID { get { return "Move"; } }
public int OrderPriority { get { return 4; } } public int OrderPriority { get { return 4; } }
public bool IsQueued { get; protected set; } public bool IsQueued { get; protected set; }
public bool CanTargetUnit(Actor self, Actor target, bool forceAttack, bool forceMove, bool forceQueued, ref string cursor) public bool CanTargetUnit(Actor self, Actor target, bool forceAttack, bool forceMove, bool forceQueued, ref string cursor)
{ {
return false; return false;
} }
public bool CanTargetLocation(Actor self, int2 location, List<Actor> actorsAtLocation, bool forceAttack, bool forceMove, bool forceQueued, ref string cursor) public bool CanTargetLocation(Actor self, int2 location, List<Actor> actorsAtLocation, bool forceAttack, bool forceMove, bool forceQueued, ref string cursor)
{ {
IsQueued = forceQueued; IsQueued = forceQueued;
cursor = "move"; cursor = "move";
if( !self.World.Map.IsInMap(location) || (self.World.LocalPlayer.Shroud.IsExplored( location ) && if (!self.World.Map.IsInMap(location) || (self.World.LocalPlayer.Shroud.IsExplored(location) &&
Mobile.MovementCostForCell(self.Trait<Mobile>().Info, self.World, location) == int.MaxValue)) self.Trait<Mobile>().Info.MovementCostForCell(self.World, location) == int.MaxValue))
cursor = "move-blocked"; cursor = "move-blocked";
return true;
}
}
public IActivity ScriptedMove( int2 cell ) { return new Move( cell ); } return true;
public IActivity MoveTo( int2 cell, int nearEnough ) { return new Move( cell, nearEnough ); } }
public IActivity MoveTo( int2 cell, Actor ignoredActor ) { return new Move( cell, ignoredActor ); } }
public IActivity MoveWithinRange( Actor target, int range ) { return new Move( target, range ); }
public IActivity MoveWithinRange( Target target, int range ) { return new Move( target, range ); } public IActivity ScriptedMove(int2 cell) { return new Move(cell); }
public IActivity MoveTo( Func<List<int2>> pathFunc ) { return new Move( pathFunc ); } public IActivity MoveTo(int2 cell, int nearEnough) { return new Move(cell, nearEnough); }
} public IActivity MoveTo(int2 cell, Actor ignoredActor) { return new Move(cell, ignoredActor); }
public IActivity MoveWithinRange(Actor target, int range) { return new Move(target, range); }
public IActivity MoveWithinRange(Target target, int range) { return new Move(target, range); }
public IActivity MoveTo(Func<List<int2>> pathFunc) { return new Move(pathFunc); }
}
} }

View File

@@ -74,7 +74,7 @@ namespace OpenRA.Mods.RA.Move
{ {
var mi = self.Info.Traits.Get<MobileInfo>(); var mi = self.Info.Traits.Get<MobileInfo>();
var tilesInRange = world.FindTilesInCircle(target, range) var tilesInRange = world.FindTilesInCircle(target, range)
.Where( t => Mobile.CanEnterCell(self.World, mi, t, null, true)); .Where( t => mi.CanEnterCell(self.World, t, null, true));
var path = FindBidiPath( var path = FindBidiPath(
PathSearch.FromPoints(world, mi, tilesInRange, src, true) PathSearch.FromPoints(world, mi, tilesInRange, src, true)

View File

@@ -87,7 +87,7 @@ namespace OpenRA.Mods.RA.Move
cellInfo[p.Location.X, p.Location.Y].Seen = true; cellInfo[p.Location.X, p.Location.Y].Seen = true;
var thisCost = Mobile.MovementCostForCell(mobileInfo, world, p.Location); var thisCost = mobileInfo.MovementCostForCell(world, p.Location);
if (thisCost == int.MaxValue) if (thisCost == int.MaxValue)
return p.Location; return p.Location;
@@ -100,12 +100,12 @@ namespace OpenRA.Mods.RA.Move
if( cellInfo[ newHere.X, newHere.Y ].Seen ) if( cellInfo[ newHere.X, newHere.Y ].Seen )
continue; continue;
var costHere = Mobile.MovementCostForCell(mobileInfo, world, newHere); var costHere = mobileInfo.MovementCostForCell(world, newHere);
if (costHere == int.MaxValue) if (costHere == int.MaxValue)
continue; continue;
if (!Mobile.CanEnterCell(mobileInfo, world, uim, newHere, ignoreBuilding, checkForBlocked)) if (!mobileInfo.CanEnterCell(world, uim, newHere, ignoreBuilding, checkForBlocked))
continue; continue;
if (customBlock != null && customBlock(newHere)) if (customBlock != null && customBlock(newHere))

View File

@@ -94,7 +94,7 @@ namespace OpenRA.Mods.RA
// Pick a spawn/exit point pair // Pick a spawn/exit point pair
// Todo: Reorder in a synced random way // Todo: Reorder in a synced random way
foreach (var s in self.Info.Traits.WithInterface<ExitInfo>()) foreach (var s in self.Info.Traits.WithInterface<ExitInfo>())
if( Mobile.CanEnterCell( mobileInfo, self.World, uim, self.Location + s.ExitCell,self,true ) ) if( mobileInfo.CanEnterCell( self.World, uim, self.Location + s.ExitCell,self,true ) )
{ {
DoProduction(self, producee, s); DoProduction(self, producee, s);
return true; return true;