Unify TargetFlash handling around Targets.

This commit is contained in:
Paul Chote
2018-05-27 11:36:08 +00:00
committed by reaperrr
parent d0be594609
commit 768265bbd2
5 changed files with 14 additions and 29 deletions

View File

@@ -48,7 +48,7 @@ namespace OpenRA
public bool IsImmediate; public bool IsImmediate;
public bool SuppressVisualFeedback; public bool SuppressVisualFeedback;
public Actor VisualFeedbackTarget; public Target VisualFeedbackTarget;
/// <summary> /// <summary>
/// DEPRECATED: Use Target instead. /// DEPRECATED: Use Target instead.

View File

@@ -70,8 +70,7 @@ namespace OpenRA.Mods.Common
var frozen = order.Target.FrozenActor; var frozen = order.Target.FrozenActor;
// Flashes the frozen proxy self.SetTargetLine(order.Target, targetLine, true);
self.SetTargetLine(frozen, targetLine, true);
// Target is still alive - resolve the real order // Target is still alive - resolve the real order
if (frozen.Actor != null && frozen.Actor.IsInWorld) if (frozen.Actor != null && frozen.Actor.IsInWorld)

View File

@@ -70,7 +70,7 @@ namespace OpenRA.Mods.Common.Orders
if (repairBuilding == null) if (repairBuilding == null)
yield break; yield break;
yield return new Order(orderId, underCursor, Target.FromActor(repairBuilding), false) { VisualFeedbackTarget = underCursor }; yield return new Order(orderId, underCursor, Target.FromActor(repairBuilding), false) { VisualFeedbackTarget = Target.FromActor(underCursor) };
} }
public void Tick(World world) public void Tick(World world)

View File

@@ -121,23 +121,5 @@ namespace OpenRA.Mods.Common.Traits
line.SetTarget(self, target, color, display); line.SetTarget(self, target, color, display);
}); });
} }
public static void SetTargetLine(this Actor self, FrozenActor target, Color color, bool display)
{
if (self.Owner != self.World.LocalPlayer)
return;
self.World.AddFrameEndTask(w =>
{
if (self.Disposed)
return;
target.Flash();
var line = self.TraitOrDefault<DrawLineToTarget>();
if (line != null)
line.SetTarget(self, Target.FromPos(target.CenterPosition), color, display);
});
}
} }
} }

View File

@@ -200,17 +200,21 @@ namespace OpenRA.Mods.Common.Widgets
continue; continue;
if (!flashed && !o.SuppressVisualFeedback) if (!flashed && !o.SuppressVisualFeedback)
{ {
var visualTargetActor = o.VisualFeedbackTarget ?? o.TargetActor; var visualTarget = o.VisualFeedbackTarget.Type != TargetType.Invalid ? o.VisualFeedbackTarget : o.Target;
if (visualTargetActor != null) if (visualTarget.Type == TargetType.Actor)
{ {
world.AddFrameEndTask(w => w.Add(new FlashTarget(visualTargetActor))); world.AddFrameEndTask(w => w.Add(new FlashTarget(visualTarget.Actor)));
flashed = true; flashed = true;
} }
else if (o.TargetLocation != CPos.Zero) else if (visualTarget.Type == TargetType.FrozenActor)
{ {
var pos = world.Map.CenterOfCell(cell); visualTarget.FrozenActor.Flash();
world.AddFrameEndTask(w => w.Add(new SpriteEffect(pos, world, "moveflsh", "idle", "moveflash", true, true))); flashed = true;
}
else if (visualTarget.Type == TargetType.Terrain)
{
world.AddFrameEndTask(w => w.Add(new SpriteEffect(visualTarget.CenterPosition, world, "moveflsh", "idle", "moveflash", true, true)));
flashed = true; flashed = true;
} }
} }