Add target flashing for C4. Closes #4659
This commit is contained in:
@@ -18,15 +18,13 @@ namespace OpenRA.Effects
|
|||||||
{
|
{
|
||||||
Actor target;
|
Actor target;
|
||||||
Player player;
|
Player player;
|
||||||
int remainingTicks = 4;
|
int remainingTicks;
|
||||||
|
|
||||||
public FlashTarget(Actor target)
|
public FlashTarget(Actor target, Player asPlayer = null, int ticks = 4)
|
||||||
: this(target, null) { }
|
|
||||||
|
|
||||||
public FlashTarget(Actor target, Player asPlayer)
|
|
||||||
{
|
{
|
||||||
this.target = target;
|
this.target = target;
|
||||||
player = asPlayer;
|
player = asPlayer;
|
||||||
|
remainingTicks = ticks;
|
||||||
foreach (var e in target.World.Effects.OfType<FlashTarget>().Where(a => a.target == target).ToArray())
|
foreach (var e in target.World.Effects.OfType<FlashTarget>().Where(a => a.target == target).ToArray())
|
||||||
target.World.Remove(e);
|
target.World.Remove(e);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,13 +16,21 @@ namespace OpenRA.Mods.RA.Activities
|
|||||||
{
|
{
|
||||||
class Demolish : Activity
|
class Demolish : Activity
|
||||||
{
|
{
|
||||||
Target target;
|
readonly Target target;
|
||||||
int delay;
|
readonly int delay;
|
||||||
|
readonly int flashes;
|
||||||
|
readonly int flashesDelay;
|
||||||
|
readonly int flashInterval;
|
||||||
|
readonly int flashDuration;
|
||||||
|
|
||||||
public Demolish(Actor target, int delay)
|
public Demolish(Actor target, int delay, int flashes, int flashesDelay, int flashInterval, int flashDuration)
|
||||||
{
|
{
|
||||||
this.target = Target.FromActor(target);
|
this.target = Target.FromActor(target);
|
||||||
this.delay = delay;
|
this.delay = delay;
|
||||||
|
this.flashes = flashes;
|
||||||
|
this.flashesDelay = flashesDelay;
|
||||||
|
this.flashInterval = flashInterval;
|
||||||
|
this.flashDuration = flashDuration;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Activity Tick(Actor self)
|
public override Activity Tick(Actor self)
|
||||||
@@ -30,7 +38,13 @@ namespace OpenRA.Mods.RA.Activities
|
|||||||
if (IsCanceled || !target.IsValidFor(self))
|
if (IsCanceled || !target.IsValidFor(self))
|
||||||
return NextActivity;
|
return NextActivity;
|
||||||
|
|
||||||
self.World.AddFrameEndTask(w => w.Add(new DelayedAction(delay, () =>
|
self.World.AddFrameEndTask(w =>
|
||||||
|
{
|
||||||
|
for (var f = 0; f < flashes; f++)
|
||||||
|
w.Add(new DelayedAction(flashesDelay + f * flashInterval, () =>
|
||||||
|
w.Add(new FlashTarget(target.Actor, ticks: flashDuration))));
|
||||||
|
|
||||||
|
w.Add(new DelayedAction(delay, () =>
|
||||||
{
|
{
|
||||||
// Can't demolish an already dead actor
|
// Can't demolish an already dead actor
|
||||||
if (target.Type != TargetType.Actor)
|
if (target.Type != TargetType.Actor)
|
||||||
@@ -47,7 +61,8 @@ namespace OpenRA.Mods.RA.Activities
|
|||||||
|
|
||||||
if (modifier > 0)
|
if (modifier > 0)
|
||||||
demolishable.Demolish(target.Actor, self);
|
demolishable.Demolish(target.Actor, self);
|
||||||
})));
|
}));
|
||||||
|
});
|
||||||
|
|
||||||
return NextActivity;
|
return NextActivity;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,6 +22,14 @@ namespace OpenRA.Mods.RA
|
|||||||
[Desc("Delay to demolish the target once the C4 is planted." +
|
[Desc("Delay to demolish the target once the C4 is planted." +
|
||||||
"Measured in game ticks. Default is 1.8 seconds.")]
|
"Measured in game ticks. Default is 1.8 seconds.")]
|
||||||
public readonly int C4Delay = 45;
|
public readonly int C4Delay = 45;
|
||||||
|
[Desc("Number of times to flash the target")]
|
||||||
|
public readonly int Flashes = 3;
|
||||||
|
[Desc("Delay before the flashing starts")]
|
||||||
|
public readonly int FlashesDelay = 4;
|
||||||
|
[Desc("Interval between each flash")]
|
||||||
|
public readonly int FlashInterval = 4;
|
||||||
|
[Desc("Duration of each flash")]
|
||||||
|
public readonly int FlashDuration = 3;
|
||||||
|
|
||||||
public object Create(ActorInitializer init) { return new C4Demolition(this); }
|
public object Create(ActorInitializer init) { return new C4Demolition(this); }
|
||||||
}
|
}
|
||||||
@@ -68,7 +76,8 @@ namespace OpenRA.Mods.RA
|
|||||||
self.CancelActivity();
|
self.CancelActivity();
|
||||||
|
|
||||||
self.SetTargetLine(target, Color.Red);
|
self.SetTargetLine(target, Color.Red);
|
||||||
self.QueueActivity(new Enter(target.Actor, new Demolish(target.Actor, info.C4Delay)));
|
self.QueueActivity(new Enter(target.Actor, new Demolish(
|
||||||
|
target.Actor, info.C4Delay, info.Flashes, info.FlashesDelay, info.FlashInterval, info.FlashDuration)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public string VoicePhraseForOrder(Actor self, Order order)
|
public string VoicePhraseForOrder(Actor self, Order order)
|
||||||
|
|||||||
Reference in New Issue
Block a user