Merge PlaceSimpleBeacon and AnimatedBeacon into PlaceBeacon and Beacon

This commit is contained in:
abcdefg30
2018-12-26 10:36:42 +01:00
committed by reaperrr
parent 8edbf665c5
commit 8578ce1346
8 changed files with 34 additions and 13 deletions

View File

@@ -23,13 +23,9 @@ namespace OpenRA.Mods.Common.Effects
readonly Player owner;
readonly WPos position;
readonly string beaconPalette;
readonly bool isPlayerPalette;
readonly string posterPalette;
readonly Animation arrow;
readonly Animation circles;
readonly Animation poster;
readonly Animation clock;
readonly string beaconPalette, posterPalette;
readonly Animation arrow, beacon, circles, clock, poster;
readonly int duration;
int delay;
@@ -39,7 +35,7 @@ namespace OpenRA.Mods.Common.Effects
// 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, int delay = 0)
string beaconCollection, string beaconSequence, string arrowSprite, string circleSprite, int delay = 0)
{
this.owner = owner;
this.position = position;
@@ -48,6 +44,12 @@ namespace OpenRA.Mods.Common.Effects
this.duration = duration;
this.delay = delay;
if (!string.IsNullOrEmpty(beaconSequence))
{
beacon = new Animation(owner.World, beaconCollection);
beacon.PlayRepeating(beaconSequence);
}
if (!string.IsNullOrEmpty(arrowSprite))
{
arrow = new Animation(owner.World, beaconCollection);
@@ -63,8 +65,8 @@ namespace OpenRA.Mods.Common.Effects
// By default, support power beacons are expected to clean themselves up
public Beacon(Player owner, WPos position, bool isPlayerPalette, string palette, string posterCollection, string posterType, string posterPalette,
string arrowSequence, string circleSequence, string clockSequence, Func<float> clockFraction, int delay = 0, int duration = -1)
: this(owner, position, duration, palette, isPlayerPalette, posterCollection, arrowSequence, circleSequence, delay)
string beaconSequence, string arrowSequence, string circleSequence, string clockSequence, Func<float> clockFraction, int delay = 0, int duration = -1)
: this(owner, position, duration, palette, isPlayerPalette, posterCollection, beaconSequence, arrowSequence, circleSequence, delay)
{
this.posterPalette = posterPalette;
@@ -97,6 +99,9 @@ namespace OpenRA.Mods.Common.Effects
if (arrow != null)
arrow.Tick();
if (beacon != null)
beacon.Tick();
if (circles != null)
circles.Tick();
@@ -119,6 +124,10 @@ namespace OpenRA.Mods.Common.Effects
var palette = r.Palette(isPlayerPalette ? beaconPalette + owner.InternalName : beaconPalette);
if (beacon != null)
foreach (var a in beacon.Render(position, palette))
yield return a;
if (circles != null)
foreach (var a in circles.Render(position, palette))
yield return a;