Polish: Show the "move-blocked" cursor for locations outside the map. Clamp move orders to the map bounds for these orders.

This commit is contained in:
Paul Chote
2010-11-26 13:42:33 +13:00
parent 5470264f00
commit 5f43923b80
7 changed files with 24 additions and 21 deletions

View File

@@ -96,7 +96,7 @@ namespace OpenRA.Orders
public string GetCursor( World world, int2 xy, MouseInput mi ) public string GetCursor( World world, int2 xy, MouseInput mi )
{ {
bool useSelect = false; bool useSelect = false;
var custom = world.WorldActor.TraitOrDefault<ICustomUnitOrderGenerator>(); var custom = world.WorldActor.TraitOrDefault<ICustomUnitOrderGenerator>();
if (custom != null) if (custom != null)
@@ -129,19 +129,10 @@ namespace OpenRA.Orders
if (self.Owner != self.World.LocalPlayer) if (self.Owner != self.World.LocalPlayer)
return null; return null;
if (!self.World.Map.IsInMap(xy.X, xy.Y))
return null;
if (self.Destroyed) if (self.Destroyed)
return null; return null;
//var old = self.TraitsImplementing<IIssueOrder>()
// .OrderByDescending( x => x.OrderPriority( self, xy, mi, underCursor ) )
// .Select( x => x.IssueOrder( self, xy, mi, underCursor ) )
// .FirstOrDefault( x => x != null );
//if( old != null )
// return old;
if( mi.Button == MouseButton.Right ) if( mi.Button == MouseButton.Right )
{ {
var uim = self.World.WorldActor.Trait<UnitInfluence>(); var uim = self.World.WorldActor.Trait<UnitInfluence>();

View File

@@ -77,6 +77,8 @@ namespace OpenRA.Mods.RA.Air
if (order.OrderString == "Move") if (order.OrderString == "Move")
{ {
var target = order.TargetLocation.Clamp(self.World.Map.Bounds);
if (self.Owner == self.World.LocalPlayer) if (self.Owner == self.World.LocalPlayer)
self.World.AddFrameEndTask(w => self.World.AddFrameEndTask(w =>
{ {
@@ -84,12 +86,12 @@ namespace OpenRA.Mods.RA.Air
w.Add(new MoveFlash(self.World, order.TargetLocation)); w.Add(new MoveFlash(self.World, order.TargetLocation));
var line = self.TraitOrDefault<DrawLineToTarget>(); var line = self.TraitOrDefault<DrawLineToTarget>();
if (line != null) if (line != null)
line.SetTarget(self, Target.FromOrder(order), Color.Green); line.SetTarget(self, Target.FromCell(target), Color.Green);
}); });
self.CancelActivity(); self.CancelActivity();
self.QueueActivity(new HeliFly(Util.CenterOfCell(order.TargetLocation))); self.QueueActivity(new HeliFly(Util.CenterOfCell(target)));
if (Info.LandWhenIdle) if (Info.LandWhenIdle)
{ {
self.QueueActivity(new Turn(Info.InitialFacing)); self.QueueActivity(new Turn(Info.InitialFacing));
@@ -114,7 +116,7 @@ namespace OpenRA.Mods.RA.Air
w.Add(new FlashTarget(order.TargetActor)); w.Add(new FlashTarget(order.TargetActor));
var line = self.TraitOrDefault<DrawLineToTarget>(); var line = self.TraitOrDefault<DrawLineToTarget>();
if (line != null) if (line != null)
line.SetTarget(self, Target.FromOrder(order), Color.Green); line.SetTarget(self, Target.FromActor(order.TargetActor), Color.Green);
}); });
self.CancelActivity(); self.CancelActivity();

View File

@@ -90,7 +90,8 @@ namespace OpenRA.Mods.RA.Air
if (order.OrderString == "Move") if (order.OrderString == "Move")
{ {
UnReserve(); UnReserve();
var target = order.TargetLocation.Clamp(self.World.Map.Bounds);
if (self.Owner == self.World.LocalPlayer) if (self.Owner == self.World.LocalPlayer)
self.World.AddFrameEndTask(w => self.World.AddFrameEndTask(w =>
{ {
@@ -98,11 +99,11 @@ namespace OpenRA.Mods.RA.Air
w.Add(new MoveFlash(self.World, order.TargetLocation)); w.Add(new MoveFlash(self.World, order.TargetLocation));
var line = self.TraitOrDefault<DrawLineToTarget>(); var line = self.TraitOrDefault<DrawLineToTarget>();
if (line != null) if (line != null)
line.SetTarget(self, Target.FromOrder(order), Color.Green); line.SetTarget(self, Target.FromCell(target), Color.Green);
}); });
self.CancelActivity(); self.CancelActivity();
self.QueueActivity(Fly.ToCell(order.TargetLocation)); self.QueueActivity(Fly.ToCell(target));
} }
else if (order.OrderString == "Enter") else if (order.OrderString == "Enter")
@@ -120,7 +121,7 @@ namespace OpenRA.Mods.RA.Air
w.Add(new FlashTarget(order.TargetActor)); w.Add(new FlashTarget(order.TargetActor));
var line = self.TraitOrDefault<DrawLineToTarget>(); var line = self.TraitOrDefault<DrawLineToTarget>();
if (line != null) if (line != null)
line.SetTarget(self, Target.FromOrder(order), Color.Green); line.SetTarget(self, Target.FromActor(order.TargetActor), Color.Green);
}); });
self.CancelActivity(); self.CancelActivity();
@@ -150,7 +151,7 @@ namespace OpenRA.Mods.RA.Air
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 = self.World.Map.IsInMap(location) ? "move" : "move-blocked";
return true; return true;
} }
public bool IsQueued { get; protected set; } public bool IsQueued { get; protected set; }

View File

@@ -263,6 +263,9 @@ namespace OpenRA.Mods.RA
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)
{ {
if (!self.World.Map.IsInMap(location))
return false;
IsQueued = forceQueued; IsQueued = forceQueued;
cursor = isHeal ? "heal" : "attack"; cursor = isHeal ? "heal" : "attack";

View File

@@ -160,6 +160,9 @@ namespace OpenRA.Mods.RA
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)
{ {
if (!self.World.Map.IsInMap(location))
return false;
cursor = "ability"; cursor = "ability";
IsQueued = forceQueued; IsQueued = forceQueued;

View File

@@ -211,7 +211,10 @@ namespace OpenRA.Mods.RA.Move
public void ResolveOrder(Actor self, Order order) public void ResolveOrder(Actor self, Order order)
{ {
if (order.OrderString == "Move") if (order.OrderString == "Move")
PerformMove(self, order.TargetLocation, order.Queued && !self.IsIdle); {
var target = order.TargetLocation.Clamp(self.World.Map.Bounds);
PerformMove(self, target, order.Queued && !self.IsIdle);
}
} }
public string VoicePhraseForOrder(Actor self, Order order) public string VoicePhraseForOrder(Actor self, Order order)

View File

@@ -76,7 +76,7 @@ namespace OpenRA.Mods.RA
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)
{ {
return true; return self.World.Map.IsInMap(location);
} }
public bool IsQueued { get { return false; } } // unused public bool IsQueued { get { return false; } } // unused