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

@@ -129,19 +129,10 @@ namespace OpenRA.Orders
if (self.Owner != self.World.LocalPlayer)
return null;
if (!self.World.Map.IsInMap(xy.X, xy.Y))
return null;
if (self.Destroyed)
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 )
{
var uim = self.World.WorldActor.Trait<UnitInfluence>();

View File

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

View File

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

View File

@@ -211,7 +211,10 @@ namespace OpenRA.Mods.RA.Move
public void ResolveOrder(Actor self, Order order)
{
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)

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)
{
return true;
return self.World.Map.IsInMap(location);
}
public bool IsQueued { get { return false; } } // unused