Replace DelayedAction in Beacon effects with Tick-based solution
This commit is contained in:
@@ -30,9 +30,11 @@ namespace OpenRA.Mods.Common.Effects
|
|||||||
readonly Animation circles;
|
readonly Animation circles;
|
||||||
readonly Animation poster;
|
readonly Animation poster;
|
||||||
readonly Animation clock;
|
readonly Animation clock;
|
||||||
|
readonly int duration;
|
||||||
|
|
||||||
int arrowHeight = MaxArrowHeight;
|
int arrowHeight = MaxArrowHeight;
|
||||||
int arrowSpeed = 50;
|
int arrowSpeed = 50;
|
||||||
|
int tick;
|
||||||
|
|
||||||
// Player-placed beacons are removed after a delay
|
// Player-placed beacons are removed after a delay
|
||||||
public Beacon(Player owner, WPos position, int duration, string beaconPalette, bool isPlayerPalette, string beaconCollection, string arrowSprite, string circleSprite)
|
public Beacon(Player owner, WPos position, int duration, string beaconPalette, bool isPlayerPalette, string beaconCollection, string arrowSprite, string circleSprite)
|
||||||
@@ -41,6 +43,7 @@ namespace OpenRA.Mods.Common.Effects
|
|||||||
this.position = position;
|
this.position = position;
|
||||||
this.beaconPalette = beaconPalette;
|
this.beaconPalette = beaconPalette;
|
||||||
this.isPlayerPalette = isPlayerPalette;
|
this.isPlayerPalette = isPlayerPalette;
|
||||||
|
this.duration = duration;
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(arrowSprite))
|
if (!string.IsNullOrEmpty(arrowSprite))
|
||||||
{
|
{
|
||||||
@@ -53,9 +56,6 @@ namespace OpenRA.Mods.Common.Effects
|
|||||||
circles = new Animation(owner.World, beaconCollection);
|
circles = new Animation(owner.World, beaconCollection);
|
||||||
circles.Play(circleSprite);
|
circles.Play(circleSprite);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (duration > 0)
|
|
||||||
owner.World.AddFrameEndTask(w => w.Add(new DelayedAction(duration, () => owner.World.Remove(this))));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Support power beacons are expected to clean themselves up
|
// Support power beacons are expected to clean themselves up
|
||||||
@@ -96,6 +96,9 @@ namespace OpenRA.Mods.Common.Effects
|
|||||||
|
|
||||||
if (clock != null)
|
if (clock != null)
|
||||||
clock.Tick();
|
clock.Tick();
|
||||||
|
|
||||||
|
if (duration > 0 && duration <= tick++)
|
||||||
|
owner.World.AddFrameEndTask(w => w.Remove(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
IEnumerable<IRenderable> IEffect.Render(WorldRenderer r) { return SpriteRenderable.None; }
|
IEnumerable<IRenderable> IEffect.Render(WorldRenderer r) { return SpriteRenderable.None; }
|
||||||
|
|||||||
@@ -25,6 +25,9 @@ namespace OpenRA.Mods.TS.Effects
|
|||||||
readonly string beaconPalette;
|
readonly string beaconPalette;
|
||||||
readonly bool isPlayerPalette;
|
readonly bool isPlayerPalette;
|
||||||
readonly Animation beacon;
|
readonly Animation beacon;
|
||||||
|
readonly int duration;
|
||||||
|
|
||||||
|
int tick;
|
||||||
|
|
||||||
public AnimatedBeacon(Player owner, WPos position, int duration, string beaconPalette, bool isPlayerPalette, string beaconImage, string beaconSequence)
|
public AnimatedBeacon(Player owner, WPos position, int duration, string beaconPalette, bool isPlayerPalette, string beaconImage, string beaconSequence)
|
||||||
{
|
{
|
||||||
@@ -32,6 +35,7 @@ namespace OpenRA.Mods.TS.Effects
|
|||||||
this.position = position;
|
this.position = position;
|
||||||
this.beaconPalette = beaconPalette;
|
this.beaconPalette = beaconPalette;
|
||||||
this.isPlayerPalette = isPlayerPalette;
|
this.isPlayerPalette = isPlayerPalette;
|
||||||
|
this.duration = duration;
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(beaconSequence))
|
if (!string.IsNullOrEmpty(beaconSequence))
|
||||||
{
|
{
|
||||||
@@ -47,6 +51,9 @@ namespace OpenRA.Mods.TS.Effects
|
|||||||
{
|
{
|
||||||
if (beacon != null)
|
if (beacon != null)
|
||||||
beacon.Tick();
|
beacon.Tick();
|
||||||
|
|
||||||
|
if (duration > 0 && duration <= tick++)
|
||||||
|
owner.World.AddFrameEndTask(w => w.Remove(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
IEnumerable<IRenderable> IEffect.Render(WorldRenderer r) { return SpriteRenderable.None; }
|
IEnumerable<IRenderable> IEffect.Render(WorldRenderer r) { return SpriteRenderable.None; }
|
||||||
|
|||||||
Reference in New Issue
Block a user