Merge pull request #5502 from pchote/support-beacons
Support beacon polish fixes.
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using OpenRA.Effects;
|
||||
@@ -24,16 +25,18 @@ namespace OpenRA.Mods.RA.Effects
|
||||
readonly Animation arrow;
|
||||
readonly Animation circles;
|
||||
readonly Animation poster;
|
||||
readonly Animation clock;
|
||||
|
||||
static readonly int maxArrowHeight = 512;
|
||||
int arrowHeight = maxArrowHeight;
|
||||
int arrowSpeed = 50;
|
||||
|
||||
public Beacon(Player owner, WPos position, int duration, string palettePrefix, string posterType, string posterPalette)
|
||||
// Player-placed beacons are removed after a delay
|
||||
public Beacon(Player owner, WPos position, int duration, string palettePrefix)
|
||||
{
|
||||
this.owner = owner;
|
||||
this.position = position;
|
||||
this.palettePrefix = palettePrefix;
|
||||
this.posterPalette = posterPalette;
|
||||
|
||||
arrow = new Animation(owner.World, "beacon");
|
||||
circles = new Animation(owner.World, "beacon");
|
||||
@@ -41,14 +44,27 @@ namespace OpenRA.Mods.RA.Effects
|
||||
arrow.Play("arrow");
|
||||
circles.Play("circles");
|
||||
|
||||
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 posterType, string posterPalette, Func<float> clockFraction)
|
||||
: this(owner, position, -1, palettePrefix)
|
||||
{
|
||||
this.posterPalette = posterPalette;
|
||||
|
||||
if (posterType != null)
|
||||
{
|
||||
poster = new Animation(owner.World, "beacon");
|
||||
poster.Play(posterType);
|
||||
}
|
||||
|
||||
if (duration > 0)
|
||||
owner.World.Add(new DelayedAction(duration, () => owner.World.Remove(this)));
|
||||
if (clockFraction != null)
|
||||
{
|
||||
clock = new Animation(owner.World, "beacon");
|
||||
clock.PlayFetchIndex("clock", () => Exts.Clamp((int)(clockFraction() * (clock.CurrentSequence.Length - 1)), 0, clock.CurrentSequence.Length - 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Tick(World world)
|
||||
@@ -63,6 +79,9 @@ namespace OpenRA.Mods.RA.Effects
|
||||
|
||||
arrow.Tick();
|
||||
circles.Tick();
|
||||
|
||||
if (clock != null)
|
||||
clock.Tick();
|
||||
}
|
||||
|
||||
public IEnumerable<IRenderable> Render(WorldRenderer r)
|
||||
@@ -78,8 +97,14 @@ namespace OpenRA.Mods.RA.Effects
|
||||
yield return a;
|
||||
|
||||
if (poster != null)
|
||||
{
|
||||
foreach (var a in poster.Render(position, r.Palette(posterPalette)))
|
||||
yield return a;
|
||||
|
||||
if (clock != null)
|
||||
foreach (var a in clock.Render(position, r.Palette(posterPalette)))
|
||||
yield return a;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -90,5 +90,7 @@ namespace OpenRA.Mods.RA.Effects
|
||||
{
|
||||
return anim.Render(pos, wr.Palette("effect"));
|
||||
}
|
||||
|
||||
public float FractionComplete { get { return ticks * 1f / delay; } }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ namespace OpenRA.Mods.RA
|
||||
if (playerBeacon != null)
|
||||
self.World.Remove(playerBeacon);
|
||||
|
||||
playerBeacon = new Beacon(self.Owner, pos, info.Duration, info.PalettePrefix, null, null);
|
||||
playerBeacon = new Beacon(self.Owner, pos, info.Duration, info.PalettePrefix);
|
||||
self.World.Add(playerBeacon);
|
||||
|
||||
if (self.Owner.IsAlliedWith(self.World.RenderPlayer))
|
||||
|
||||
@@ -13,6 +13,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using OpenRA.Mods.RA.Activities;
|
||||
using OpenRA.Mods.RA.Air;
|
||||
using OpenRA.Mods.RA.Effects;
|
||||
using OpenRA.Primitives;
|
||||
using OpenRA.Traits;
|
||||
|
||||
@@ -42,6 +43,9 @@ namespace OpenRA.Mods.RA
|
||||
[Desc("Amount of time to keep the camera alive after the aircraft have finished attacking")]
|
||||
public readonly int CameraRemoveDelay = 25;
|
||||
|
||||
[Desc("Weapon range offset to apply during the beacon clock calculation")]
|
||||
public readonly WRange BeaconDistanceOffset = WRange.FromCells(6);
|
||||
|
||||
public override object Create(ActorInitializer init) { return new AirstrikePower(init.self, this); }
|
||||
}
|
||||
|
||||
@@ -66,6 +70,7 @@ namespace OpenRA.Mods.RA
|
||||
|
||||
Actor flare = null;
|
||||
Actor camera = null;
|
||||
Beacon beacon = null;
|
||||
Dictionary<Actor, bool> aircraftInRange = new Dictionary<Actor, bool>();
|
||||
|
||||
Action<Actor> onEnterRange = a =>
|
||||
@@ -132,6 +137,7 @@ namespace OpenRA.Mods.RA
|
||||
var notification = self.Owner.IsAlliedWith(self.World.RenderPlayer) ? Info.LaunchSound : Info.IncomingSound;
|
||||
Sound.Play(notification);
|
||||
|
||||
Actor distanceTestActor = null;
|
||||
for (var i = -info.SquadSize / 2; i <= info.SquadSize / 2; i++)
|
||||
{
|
||||
// Even-sized squads skip the lead plane
|
||||
@@ -159,6 +165,23 @@ namespace OpenRA.Mods.RA
|
||||
a.QueueActivity(new Fly(a, Target.FromPos(finishEdge + spawnOffset)));
|
||||
a.QueueActivity(new RemoveSelf());
|
||||
aircraftInRange.Add(a, false);
|
||||
distanceTestActor = a;
|
||||
}
|
||||
|
||||
if (Info.DisplayBeacon)
|
||||
{
|
||||
var distance = (target - startEdge).HorizontalLength;
|
||||
|
||||
beacon = new Beacon(
|
||||
order.Player,
|
||||
order.TargetLocation.CenterPosition,
|
||||
Info.BeaconPalettePrefix,
|
||||
Info.BeaconPoster,
|
||||
Info.BeaconPosterPalette,
|
||||
() => 1 - ((distanceTestActor.CenterPosition - target).HorizontalLength - info.BeaconDistanceOffset.Range) * 1f / distance
|
||||
);
|
||||
|
||||
w.Add(beacon);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -77,10 +77,12 @@ namespace OpenRA.Mods.RA
|
||||
var rb = self.Trait<RenderSimple>();
|
||||
rb.PlayCustomAnim(self, "active");
|
||||
|
||||
self.World.AddFrameEndTask(w => w.Add(new NukeLaunch(self.Owner, npi.MissileWeapon,
|
||||
var missile = new NukeLaunch(self.Owner, npi.MissileWeapon,
|
||||
self.CenterPosition + body.LocalToWorld(npi.SpawnOffset),
|
||||
order.TargetLocation.CenterPosition,
|
||||
npi.FlightVelocity, npi.FlightDelay, npi.SkipAscent)));
|
||||
npi.FlightVelocity, npi.FlightDelay, npi.SkipAscent);
|
||||
|
||||
self.World.AddFrameEndTask(w => w.Add(missile));
|
||||
|
||||
if (npi.CameraActor != null)
|
||||
{
|
||||
@@ -97,15 +99,29 @@ namespace OpenRA.Mods.RA
|
||||
self.World.AddFrameEndTask(w => w.Add(new DelayedAction(npi.FlightDelay - npi.CameraSpawnAdvance, addCamera)));
|
||||
}
|
||||
|
||||
if (beacon != null)
|
||||
if (Info.DisplayBeacon)
|
||||
{
|
||||
var beacon = new Beacon(
|
||||
order.Player,
|
||||
order.TargetLocation.CenterPosition,
|
||||
Info.BeaconPalettePrefix,
|
||||
Info.BeaconPoster,
|
||||
Info.BeaconPosterPalette,
|
||||
() => missile.FractionComplete
|
||||
);
|
||||
|
||||
|
||||
Action removeBeacon = () => self.World.AddFrameEndTask(w =>
|
||||
{
|
||||
w.Remove(beacon);
|
||||
beacon = null;
|
||||
});
|
||||
|
||||
self.World.AddFrameEndTask(w => w.Add(new DelayedAction(npi.FlightDelay - npi.BeaconRemoveAdvance, removeBeacon)));
|
||||
self.World.AddFrameEndTask(w =>
|
||||
{
|
||||
w.Add(beacon);
|
||||
w.Add(new DelayedAction(npi.FlightDelay - npi.BeaconRemoveAdvance, removeBeacon));
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,11 +31,12 @@ namespace OpenRA.Mods.RA
|
||||
|
||||
public readonly bool DisplayTimer = false;
|
||||
|
||||
[Desc("Beacons are only supported on the Airstrike and Nuke powers")]
|
||||
public readonly bool DisplayBeacon = false;
|
||||
public readonly int BeaconDuration = 10 * 25;
|
||||
public readonly string BeaconPalettePrefix = "player";
|
||||
public readonly string BeaconPoster = null;
|
||||
public readonly string BeaconPosterPalette = "chrome";
|
||||
|
||||
public readonly bool DisplayRadarPing = false;
|
||||
public readonly int RadarPingDuration = 5 * 25;
|
||||
|
||||
@@ -49,7 +50,6 @@ namespace OpenRA.Mods.RA
|
||||
{
|
||||
public readonly Actor self;
|
||||
public readonly SupportPowerInfo Info;
|
||||
protected Beacon beacon;
|
||||
protected RadarPing ping;
|
||||
|
||||
public SupportPower(Actor self, SupportPowerInfo info)
|
||||
@@ -70,25 +70,14 @@ namespace OpenRA.Mods.RA
|
||||
|
||||
public virtual void Activate(Actor self, Order order, SupportPowerManager manager)
|
||||
{
|
||||
if (Info.DisplayBeacon)
|
||||
{
|
||||
beacon = new Beacon(
|
||||
order.Player,
|
||||
order.TargetLocation.CenterPosition,
|
||||
Info.BeaconDuration,
|
||||
Info.BeaconPalettePrefix,
|
||||
Info.BeaconPoster,
|
||||
Info.BeaconPosterPalette);
|
||||
|
||||
self.World.Add(beacon);
|
||||
}
|
||||
|
||||
if (Info.DisplayRadarPing && manager.RadarPings != null)
|
||||
{
|
||||
ping = manager.RadarPings.Value.Add(
|
||||
() => order.Player.IsAlliedWith(self.World.RenderPlayer),
|
||||
order.TargetLocation.CenterPosition,
|
||||
order.Player.Color.RGB,
|
||||
Info.RadarPingDuration);
|
||||
}
|
||||
}
|
||||
|
||||
public virtual IOrderGenerator OrderGenerator(string order, SupportPowerManager manager)
|
||||
|
||||
BIN
mods/cnc/bits/beaconclock.shp
Normal file
BIN
mods/cnc/bits/beaconclock.shp
Normal file
Binary file not shown.
@@ -169,6 +169,10 @@ beacon:
|
||||
Start: 0
|
||||
Length: 1
|
||||
Offset: 0,-42
|
||||
clock: beaconclock
|
||||
Start: 0
|
||||
Length: *
|
||||
Offset: 0,-42
|
||||
|
||||
select:
|
||||
repair:
|
||||
|
||||
BIN
mods/ra/bits/beaconclock.shp
Normal file
BIN
mods/ra/bits/beaconclock.shp
Normal file
Binary file not shown.
@@ -125,6 +125,10 @@ beacon:
|
||||
Start: 0
|
||||
Length: *
|
||||
Offset: 0,-42
|
||||
clock: beaconclock
|
||||
Start: 0
|
||||
Length: *
|
||||
Offset: 0,-42
|
||||
|
||||
smoke_m:
|
||||
idle:
|
||||
|
||||
Reference in New Issue
Block a user