Unhardcode player beacons for documentation and lint testing.

This commit is contained in:
Matthias Mailänder
2016-04-24 23:42:57 +02:00
parent 76124b7c79
commit 9f4cdb9843
7 changed files with 26 additions and 10 deletions

View File

@@ -34,25 +34,25 @@ namespace OpenRA.Mods.Common.Effects
int arrowSpeed = 50;
// Player-placed beacons are removed after a delay
public Beacon(Player owner, WPos position, int duration, string palettePrefix)
public Beacon(Player owner, WPos position, int duration, string palettePrefix, string beaconCollection, string arrowSprite, string circleSprite)
{
this.owner = owner;
this.position = position;
this.palettePrefix = palettePrefix;
arrow = new Animation(owner.World, "beacon");
circles = new Animation(owner.World, "beacon");
arrow = new Animation(owner.World, beaconCollection);
circles = new Animation(owner.World, beaconCollection);
arrow.Play("arrow");
circles.Play("circles");
arrow.Play(arrowSprite);
circles.Play(circleSprite);
if (duration > 0)
owner.World.Add(new DelayedAction(duration, () => owner.World.Remove(this)));
}
// Support power beacons are expected to clean themselves up
public Beacon(Player owner, WPos position, string palettePrefix, string posterCollection, string posterType, string posterPalette, string clockSequence, Func<float> clockFraction)
: this(owner, position, -1, palettePrefix)
public Beacon(Player owner, WPos position, string palettePrefix, string posterCollection, string posterType, string posterPalette, string arrowSequence, string circleSequence,
string clockSequence, Func<float> clockFraction) : this(owner, position, -1, palettePrefix, posterCollection, arrowSequence, circleSequence)
{
this.posterPalette = posterPalette;

View File

@@ -27,9 +27,10 @@ namespace OpenRA.Mods.Common.Scripting
[Desc("Creates a new beacon that stays for the specified time at the specified WPos. " +
"Does not remove player set beacons, nor gets removed by placing them.")]
public Beacon New(Player owner, WPos position, int duration = 30 * 25, bool showRadarPings = true, string palettePrefix = "player")
public Beacon New(Player owner, WPos position, int duration = 30 * 25, bool showRadarPings = true,
string palettePrefix = "player", string beaconCollection = "beacon", string arrowSequence = "arrow", string circleSequence = "circle")
{
var playerBeacon = new Beacon(owner, position, duration, palettePrefix);
var playerBeacon = new Beacon(owner, position, duration, palettePrefix, beaconCollection, arrowSequence, circleSequence);
owner.PlayerActor.World.AddFrameEndTask(w => w.Add(playerBeacon));
if (showRadarPings && radarPings != null)

View File

@@ -19,8 +19,14 @@ namespace OpenRA.Mods.Common.Traits
public readonly int Duration = 30 * 25;
public readonly string NotificationType = "Sounds";
public readonly string Notification = "Beacon";
[PaletteReference(true)]
public readonly string PalettePrefix = "player";
public readonly string BeaconImage = "beacon";
[SequenceReference("BeaconImage")] public readonly string ArrowSequence = "arrow";
[SequenceReference("BeaconImage")] public readonly string CircleSequence = "circles";
public object Create(ActorInitializer init) { return new PlaceBeacon(init.Self, this); }
}
@@ -50,7 +56,7 @@ namespace OpenRA.Mods.Common.Traits
if (playerBeacon != null)
self.World.Remove(playerBeacon);
playerBeacon = new Beacon(self.Owner, pos, info.Duration, info.PalettePrefix);
playerBeacon = new Beacon(self.Owner, pos, info.Duration, info.PalettePrefix, info.BeaconImage, info.ArrowSequence, info.CircleSequence);
self.World.Add(playerBeacon);
if (self.Owner.IsAlliedWith(self.World.RenderPlayer))

View File

@@ -173,6 +173,8 @@ namespace OpenRA.Mods.Common.Traits
Info.BeaconImage,
Info.BeaconPoster,
Info.BeaconPosterPalette,
Info.ArrowSequence,
Info.CircleSequence,
Info.ClockSequence,
() => 1 - ((distanceTestActor.CenterPosition - target).HorizontalLength - info.BeaconDistanceOffset.Length) * 1f / distance);

View File

@@ -138,6 +138,8 @@ namespace OpenRA.Mods.Common.Traits
Info.BeaconImage,
Info.BeaconPoster,
Info.BeaconPosterPalette,
Info.ArrowSequence,
Info.CircleSequence,
Info.ClockSequence,
() => missile.FractionComplete);

View File

@@ -51,6 +51,9 @@ namespace OpenRA.Mods.Common.Traits
[PaletteReference] public readonly string BeaconPosterPalette = "chrome";
[SequenceReference("BeaconImage")] public readonly string ClockSequence = "clock";
[SequenceReference("BeaconImage")] public readonly string ArrowSequence = "arrow";
[SequenceReference("BeaconImage")] public readonly string CircleSequence = "circles";
public readonly bool DisplayRadarPing = false;
[Desc("Measured in ticks.")]

View File

@@ -208,6 +208,8 @@ namespace OpenRA.Mods.RA.Traits
Info.BeaconImage,
Info.BeaconPoster,
Info.BeaconPosterPalette,
Info.ArrowSequence,
Info.CircleSequence,
Info.ClockSequence,
() => 1 - ((distanceTestActor.CenterPosition - target).HorizontalLength - info.BeaconDistanceOffset.Length) * 1f / distance);