Unhardcode player beacons for documentation and lint testing.
This commit is contained in:
@@ -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;
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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))
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -138,6 +138,8 @@ namespace OpenRA.Mods.Common.Traits
|
||||
Info.BeaconImage,
|
||||
Info.BeaconPoster,
|
||||
Info.BeaconPosterPalette,
|
||||
Info.ArrowSequence,
|
||||
Info.CircleSequence,
|
||||
Info.ClockSequence,
|
||||
() => missile.FractionComplete);
|
||||
|
||||
|
||||
@@ -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.")]
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user