Unify TargetFlash handling around Targets.
This commit is contained in:
@@ -48,7 +48,7 @@ namespace OpenRA
|
||||
public bool IsImmediate;
|
||||
|
||||
public bool SuppressVisualFeedback;
|
||||
public Actor VisualFeedbackTarget;
|
||||
public Target VisualFeedbackTarget;
|
||||
|
||||
/// <summary>
|
||||
/// DEPRECATED: Use Target instead.
|
||||
|
||||
@@ -70,8 +70,7 @@ namespace OpenRA.Mods.Common
|
||||
|
||||
var frozen = order.Target.FrozenActor;
|
||||
|
||||
// Flashes the frozen proxy
|
||||
self.SetTargetLine(frozen, targetLine, true);
|
||||
self.SetTargetLine(order.Target, targetLine, true);
|
||||
|
||||
// Target is still alive - resolve the real order
|
||||
if (frozen.Actor != null && frozen.Actor.IsInWorld)
|
||||
|
||||
@@ -70,7 +70,7 @@ namespace OpenRA.Mods.Common.Orders
|
||||
if (repairBuilding == null)
|
||||
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)
|
||||
|
||||
@@ -121,23 +121,5 @@ namespace OpenRA.Mods.Common.Traits
|
||||
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);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -201,16 +201,20 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
|
||||
if (!flashed && !o.SuppressVisualFeedback)
|
||||
{
|
||||
var visualTargetActor = o.VisualFeedbackTarget ?? o.TargetActor;
|
||||
if (visualTargetActor != null)
|
||||
var visualTarget = o.VisualFeedbackTarget.Type != TargetType.Invalid ? o.VisualFeedbackTarget : o.Target;
|
||||
if (visualTarget.Type == TargetType.Actor)
|
||||
{
|
||||
world.AddFrameEndTask(w => w.Add(new FlashTarget(visualTargetActor)));
|
||||
world.AddFrameEndTask(w => w.Add(new FlashTarget(visualTarget.Actor)));
|
||||
flashed = true;
|
||||
}
|
||||
else if (o.TargetLocation != CPos.Zero)
|
||||
else if (visualTarget.Type == TargetType.FrozenActor)
|
||||
{
|
||||
var pos = world.Map.CenterOfCell(cell);
|
||||
world.AddFrameEndTask(w => w.Add(new SpriteEffect(pos, world, "moveflsh", "idle", "moveflash", true, true)));
|
||||
visualTarget.FrozenActor.Flash();
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user