Improve behaviour of move orders wrt shroud/fog
This commit is contained in:
@@ -86,7 +86,6 @@ namespace OpenRA.Traits
|
|||||||
AddInfluence();
|
AddInfluence();
|
||||||
}
|
}
|
||||||
|
|
||||||
Shroud shroud;
|
|
||||||
UnitInfluence uim;
|
UnitInfluence uim;
|
||||||
|
|
||||||
public Mobile(ActorInitializer init, MobileInfo info)
|
public Mobile(ActorInitializer init, MobileInfo info)
|
||||||
@@ -94,7 +93,6 @@ namespace OpenRA.Traits
|
|||||||
this.self = init.self;
|
this.self = init.self;
|
||||||
this.Info = info;
|
this.Info = info;
|
||||||
|
|
||||||
shroud = self.World.WorldActor.Trait<Shroud>();
|
|
||||||
uim = self.World.WorldActor.Trait<UnitInfluence>();
|
uim = self.World.WorldActor.Trait<UnitInfluence>();
|
||||||
|
|
||||||
if (init.Contains<LocationInit>())
|
if (init.Contains<LocationInit>())
|
||||||
@@ -119,18 +117,15 @@ namespace OpenRA.Traits
|
|||||||
return mi.Modifiers.HasModifier(Modifiers.Alt) ? int.MaxValue : 0;
|
return mi.Modifiers.HasModifier(Modifiers.Alt) ? int.MaxValue : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Note: Returns a valid order even if the unit can't move to the target
|
||||||
public Order IssueOrder(Actor self, int2 xy, MouseInput mi, Actor underCursor)
|
public Order IssueOrder(Actor self, int2 xy, MouseInput mi, Actor underCursor)
|
||||||
{
|
{
|
||||||
if (Info.OnRails) return null;
|
if (Info.OnRails) return null;
|
||||||
|
|
||||||
if (mi.Button == MouseButton.Left) return null;
|
if (mi.Button == MouseButton.Left) return null;
|
||||||
|
|
||||||
if (!CanEnterCell(xy))
|
var type = (!self.World.LocalPlayer.Shroud.IsVisible(xy) || CanEnterCell(xy)) ? "Move" : "Move-Blocked";
|
||||||
return null;
|
return new Order(type, self, xy, mi.Modifiers.HasModifier(Modifiers.Shift));
|
||||||
|
|
||||||
if (xy == toCell) return null;
|
|
||||||
|
|
||||||
return new Order("Move", self, xy, mi.Modifiers.HasModifier(Modifiers.Shift));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int2 NearestMoveableCell(int2 target)
|
public int2 NearestMoveableCell(int2 target)
|
||||||
@@ -155,7 +150,7 @@ namespace OpenRA.Traits
|
|||||||
|
|
||||||
public void ResolveOrder(Actor self, Order order)
|
public void ResolveOrder(Actor self, Order order)
|
||||||
{
|
{
|
||||||
if (order.OrderString == "Move")
|
if (order.OrderString == "Move" || order.OrderString == "Move-Blocked")
|
||||||
{
|
{
|
||||||
int2 currentLocation = NearestMoveableCell(order.TargetLocation);
|
int2 currentLocation = NearestMoveableCell(order.TargetLocation);
|
||||||
if (!CanEnterCell(currentLocation))
|
if (!CanEnterCell(currentLocation))
|
||||||
@@ -177,17 +172,20 @@ namespace OpenRA.Traits
|
|||||||
|
|
||||||
public string CursorForOrder(Actor self, Order order)
|
public string CursorForOrder(Actor self, Order order)
|
||||||
{
|
{
|
||||||
if (order.OrderString != "Move")
|
if (order.OrderString == "Move")
|
||||||
return null;
|
return "move";
|
||||||
|
|
||||||
var xy = order.TargetLocation;
|
if (order.OrderString == "Move-Blocked")
|
||||||
return (!shroud.exploredCells[xy.X, xy.Y] || CanEnterCell(xy)) ? "move" : "move-blocked";
|
return "move-blocked";
|
||||||
|
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public string VoicePhraseForOrder(Actor self, Order order)
|
public string VoicePhraseForOrder(Actor self, Order order)
|
||||||
{
|
{
|
||||||
var xy = order.TargetLocation;
|
if (order.OrderString == "Move" || order.OrderString == "Move-Blocked")
|
||||||
return (order.OrderString == "Move" && (!shroud.exploredCells[xy.X, xy.Y] || CanEnterCell(xy))) ? "Move" : null;
|
return "Move";
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int2 TopLeft { get { return toCell; } }
|
public int2 TopLeft { get { return toCell; } }
|
||||||
|
|||||||
Reference in New Issue
Block a user