Introduce Order.SuppressVisualFeedback to cleanly disable flashes.

This commit is contained in:
Paul Chote
2014-06-21 22:05:36 +12:00
parent 32e0bf3edf
commit 7d24053f52
12 changed files with 22 additions and 15 deletions

View File

@@ -45,6 +45,7 @@ namespace OpenRA
public CPos ExtraLocation; public CPos ExtraLocation;
public uint ExtraData; public uint ExtraData;
public bool IsImmediate; public bool IsImmediate;
public bool SuppressVisualFeedback;
public Player Player { get { return Subject.Owner; } } public Player Player { get { return Subject.Owner; } }

View File

@@ -152,14 +152,14 @@ namespace OpenRA.Widgets
if (o == null) if (o == null)
continue; continue;
if (!flashed) if (!flashed && !o.SuppressVisualFeedback)
{ {
if (o.TargetActor != null) if (o.TargetActor != null)
{ {
world.AddFrameEndTask(w => w.Add(new FlashTarget(o.TargetActor))); world.AddFrameEndTask(w => w.Add(new FlashTarget(o.TargetActor)));
flashed = true; flashed = true;
} }
else if (o.Subject != world.LocalPlayer.PlayerActor && o.TargetLocation != CPos.Zero) // TODO: this filters building placement, but also suppport powers :( else if (o.TargetLocation != CPos.Zero)
{ {
world.AddFrameEndTask(w => w.Add(new MoveFlash(worldRenderer.Position(worldRenderer.Viewport.ViewToWorldPx(mi.Location)), world))); world.AddFrameEndTask(w => w.Add(new MoveFlash(worldRenderer.Position(worldRenderer.Viewport.ViewToWorldPx(mi.Location)), world)));
flashed = true; flashed = true;

View File

@@ -84,7 +84,8 @@ namespace OpenRA.Mods.RA.AI
ai.world.IssueOrder(new Order("PlaceBuilding", ai.p.PlayerActor, false) ai.world.IssueOrder(new Order("PlaceBuilding", ai.p.PlayerActor, false)
{ {
TargetLocation = location.Value, TargetLocation = location.Value,
TargetString = currentBuilding.Item TargetString = currentBuilding.Item,
SuppressVisualFeedback = true
}); });
} }
} }

View File

@@ -688,7 +688,7 @@ namespace OpenRA.Mods.RA.AI
p.PlayerName, buildings.Length); p.PlayerName, buildings.Length);
foreach (var a in buildings) foreach (var a in buildings)
world.IssueOrder(new Order("SetRallyPoint", a.Actor, false) { TargetLocation = ChooseRallyLocationNear(a.Actor.Location) }); world.IssueOrder(new Order("SetRallyPoint", a.Actor, false) { TargetLocation = ChooseRallyLocationNear(a.Actor.Location), SuppressVisualFeedback = true });
} }
// Won't work for shipyards... // Won't work for shipyards...
@@ -773,7 +773,7 @@ namespace OpenRA.Mods.RA.AI
if (attackLocation == null) if (attackLocation == null)
return; return;
world.IssueOrder(new Order(sp.Info.OrderName, supportPowerMngr.self, false) { TargetLocation = attackLocation.Value }); world.IssueOrder(new Order(sp.Info.OrderName, supportPowerMngr.self, false) { TargetLocation = attackLocation.Value, SuppressVisualFeedback = true });
} }
} }
} }

View File

@@ -23,7 +23,7 @@ namespace OpenRA.Mods.RA.Orders
if (!world.ShroudObscures(xy)) if (!world.ShroudObscures(xy))
{ {
world.CancelInputMode(); world.CancelInputMode();
yield return new Order("PlaceBeacon", world.LocalPlayer.PlayerActor, false) { TargetLocation = xy }; yield return new Order("PlaceBeacon", world.LocalPlayer.PlayerActor, false) { TargetLocation = xy, SuppressVisualFeedback = true };
} }
} }

View File

@@ -62,8 +62,12 @@ namespace OpenRA.Mods.RA.Orders
} }
var isLineBuild = world.Map.Rules.Actors[Building].Traits.Contains<LineBuildInfo>(); var isLineBuild = world.Map.Rules.Actors[Building].Traits.Contains<LineBuildInfo>();
yield return new Order(isLineBuild ? "LineBuild" : "PlaceBuilding", yield return new Order(isLineBuild ? "LineBuild" : "PlaceBuilding", Producer.Owner.PlayerActor, false)
Producer.Owner.PlayerActor, false) { TargetLocation = topLeft, TargetString = Building }; {
TargetLocation = topLeft,
TargetString = Building,
SuppressVisualFeedback = true
};
} }
} }

View File

@@ -40,8 +40,8 @@ namespace OpenRA.Mods.RA
public Order IssueOrder( Actor self, IOrderTargeter order, Target target, bool queued ) public Order IssueOrder( Actor self, IOrderTargeter order, Target target, bool queued )
{ {
if( order.OrderID == "SetRallyPoint" ) if (order.OrderID == "SetRallyPoint")
return new Order(order.OrderID, self, false) { TargetLocation = target.CenterPosition.ToCPos() }; return new Order(order.OrderID, self, false) { TargetLocation = target.CenterPosition.ToCPos(), SuppressVisualFeedback = true };
return null; return null;
} }

View File

@@ -191,7 +191,8 @@ namespace OpenRA.Mods.RA
yield return new Order(order, manager.self, false) yield return new Order(order, manager.self, false)
{ {
TargetLocation = xy, TargetLocation = xy,
ExtraLocation = sourceLocation ExtraLocation = sourceLocation,
SuppressVisualFeedback = true
}; };
} }

View File

@@ -88,7 +88,7 @@ namespace OpenRA.Mods.RA
{ {
world.CancelInputMode(); world.CancelInputMode();
if (mi.Button == MouseButton.Left && power.UnitsInRange(xy).Any()) if (mi.Button == MouseButton.Left && power.UnitsInRange(xy).Any())
yield return new Order(order, manager.self, false) { TargetLocation = xy }; yield return new Order(order, manager.self, false) { TargetLocation = xy, SuppressVisualFeedback = true };
} }
public void Tick(World world) public void Tick(World world)

View File

@@ -246,7 +246,7 @@ namespace OpenRA.Mods.RA
{ {
world.CancelInputMode(); world.CancelInputMode();
if (mi.Button == expectedButton && world.Map.IsInMap(xy)) if (mi.Button == expectedButton && world.Map.IsInMap(xy))
yield return new Order(order, manager.self, false) { TargetLocation = xy }; yield return new Order(order, manager.self, false) { TargetLocation = xy, SuppressVisualFeedback = true };
} }
public virtual void Tick(World world) public virtual void Tick(World world)

View File

@@ -89,7 +89,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
// HACK: Abuse of the type system here with `CPos` // HACK: Abuse of the type system here with `CPos`
world.IssueOrder(new Order("SetStance", world.LocalPlayer.PlayerActor, false) world.IssueOrder(new Order("SetStance", world.LocalPlayer.PlayerActor, false)
{ TargetLocation = new CPos((int)ss, 0), TargetString = p.InternalName }); { TargetLocation = new CPos((int)ss, 0), TargetString = p.InternalName, SuppressVisualFeedback = true });
bw.Text = ss.ToString(); bw.Text = ss.ToString();
} }

View File

@@ -165,7 +165,7 @@ namespace OpenRA.Mods.RA.Widgets
at.PredictedStance = nextStance; at.PredictedStance = nextStance;
// FIXME: Abuse of the type system here with `CPos` // FIXME: Abuse of the type system here with `CPos`
return new Order("SetUnitStance", a, false) { TargetLocation = new CPos((int)nextStance, 0) }; return new Order("SetUnitStance", a, false) { TargetLocation = new CPos((int)nextStance, 0), SuppressVisualFeedback = true };
}); });
Game.Debug("Unit stance set to: {0}".F(nextStance)); Game.Debug("Unit stance set to: {0}".F(nextStance));