Display a blocked cursor when not allowed to MoveIntoShroud.

This commit is contained in:
Matthias Mailänder
2017-09-16 11:55:03 +02:00
committed by abcdefg30
parent b27289106d
commit ebb982789e

View File

@@ -39,11 +39,12 @@ namespace OpenRA.Mods.Common.Traits
class AttackMove : INotifyCreated, ITick, IResolveOrder, IOrderVoice, INotifyIdle, ISync class AttackMove : INotifyCreated, ITick, IResolveOrder, IOrderVoice, INotifyIdle, ISync
{ {
public readonly AttackMoveInfo Info;
[Sync] public CPos _targetLocation { get { return TargetLocation.HasValue ? TargetLocation.Value : CPos.Zero; } } [Sync] public CPos _targetLocation { get { return TargetLocation.HasValue ? TargetLocation.Value : CPos.Zero; } }
public CPos? TargetLocation = null; public CPos? TargetLocation = null;
readonly IMove move; readonly IMove move;
readonly AttackMoveInfo info;
ConditionManager conditionManager; ConditionManager conditionManager;
int attackMoveToken = ConditionManager.InvalidConditionToken; int attackMoveToken = ConditionManager.InvalidConditionToken;
@@ -53,7 +54,7 @@ namespace OpenRA.Mods.Common.Traits
public AttackMove(Actor self, AttackMoveInfo info) public AttackMove(Actor self, AttackMoveInfo info)
{ {
move = self.Trait<IMove>(); move = self.Trait<IMove>();
this.info = info; Info = info;
} }
void INotifyCreated.Created(Actor self) void INotifyCreated.Created(Actor self)
@@ -70,24 +71,24 @@ namespace OpenRA.Mods.Common.Traits
var attackActive = activity != null && !assaultMoving; var attackActive = activity != null && !assaultMoving;
var assaultActive = activity != null && assaultMoving; var assaultActive = activity != null && assaultMoving;
if (attackActive && attackMoveToken == ConditionManager.InvalidConditionToken && !string.IsNullOrEmpty(info.AttackMoveScanCondition)) if (attackActive && attackMoveToken == ConditionManager.InvalidConditionToken && !string.IsNullOrEmpty(Info.AttackMoveScanCondition))
attackMoveToken = conditionManager.GrantCondition(self, info.AttackMoveScanCondition); attackMoveToken = conditionManager.GrantCondition(self, Info.AttackMoveScanCondition);
else if (!attackActive && attackMoveToken != ConditionManager.InvalidConditionToken) else if (!attackActive && attackMoveToken != ConditionManager.InvalidConditionToken)
attackMoveToken = conditionManager.RevokeCondition(self, attackMoveToken); attackMoveToken = conditionManager.RevokeCondition(self, attackMoveToken);
if (assaultActive && assaultMoveToken == ConditionManager.InvalidConditionToken && !string.IsNullOrEmpty(info.AssaultMoveScanCondition)) if (assaultActive && assaultMoveToken == ConditionManager.InvalidConditionToken && !string.IsNullOrEmpty(Info.AssaultMoveScanCondition))
assaultMoveToken = conditionManager.GrantCondition(self, info.AssaultMoveScanCondition); assaultMoveToken = conditionManager.GrantCondition(self, Info.AssaultMoveScanCondition);
else if (!assaultActive && assaultMoveToken != ConditionManager.InvalidConditionToken) else if (!assaultActive && assaultMoveToken != ConditionManager.InvalidConditionToken)
assaultMoveToken = conditionManager.RevokeCondition(self, assaultMoveToken); assaultMoveToken = conditionManager.RevokeCondition(self, assaultMoveToken);
} }
string IOrderVoice.VoicePhraseForOrder(Actor self, Order order) string IOrderVoice.VoicePhraseForOrder(Actor self, Order order)
{ {
if (!info.MoveIntoShroud && !self.Owner.Shroud.IsExplored(order.TargetLocation)) if (!Info.MoveIntoShroud && !self.Owner.Shroud.IsExplored(order.TargetLocation))
return null; return null;
if (order.OrderString == "AttackMove" || order.OrderString == "AssaultMove") if (order.OrderString == "AttackMove" || order.OrderString == "AssaultMove")
return info.Voice; return Info.Voice;
return null; return null;
} }
@@ -114,7 +115,7 @@ namespace OpenRA.Mods.Common.Traits
if (!order.Queued) if (!order.Queued)
self.CancelActivity(); self.CancelActivity();
if (!info.MoveIntoShroud && !self.Owner.Shroud.IsExplored(order.TargetLocation)) if (!Info.MoveIntoShroud && !self.Owner.Shroud.IsExplored(order.TargetLocation))
return; return;
TargetLocation = move.NearestMoveableCell(order.TargetLocation); TargetLocation = move.NearestMoveableCell(order.TargetLocation);
@@ -166,7 +167,15 @@ namespace OpenRA.Mods.Common.Traits
public override string GetCursor(World world, CPos cell, int2 worldPixel, MouseInput mi) public override string GetCursor(World world, CPos cell, int2 worldPixel, MouseInput mi)
{ {
var prefix = mi.Modifiers.HasModifier(Modifiers.Ctrl) ? "assaultmove" : "attackmove"; var prefix = mi.Modifiers.HasModifier(Modifiers.Ctrl) ? "assaultmove" : "attackmove";
return world.Map.Contains(cell) ? prefix : prefix + "-blocked";
if (world.Map.Contains(cell))
{
var explored = subjects.First().Actor.Owner.Shroud.IsExplored(cell);
var blocked = !explored && subjects.Any(a => !a.Trait.Info.MoveIntoShroud);
return blocked ? prefix + "-blocked" : prefix;
}
return prefix + "-blocked";
} }
public override bool InputOverridesSelection(World world, int2 xy, MouseInput mi) public override bool InputOverridesSelection(World world, int2 xy, MouseInput mi)