Change spacebar key to move to the last visible radar ping location

This commit is contained in:
ScottNZ
2014-02-21 22:11:43 +13:00
parent 06caf7f156
commit 0a9a959ecf
4 changed files with 13 additions and 15 deletions

View File

@@ -28,8 +28,7 @@ namespace OpenRA.Mods.RA
readonly RadarPings radarPings; readonly RadarPings radarPings;
readonly BaseAttackNotifierInfo info; readonly BaseAttackNotifierInfo info;
public int lastAttackTime; int lastAttackTime;
public CPos lastAttackLocation;
public BaseAttackNotifier(Actor self, BaseAttackNotifierInfo info) public BaseAttackNotifier(Actor self, BaseAttackNotifierInfo info)
{ {
@@ -61,7 +60,6 @@ namespace OpenRA.Mods.RA
radarPings.Add(() => self.Owner == self.World.LocalPlayer, self.CenterPosition, info.RadarPingColor, info.RadarPingDuration); radarPings.Add(() => self.Owner == self.World.LocalPlayer, self.CenterPosition, info.RadarPingColor, info.RadarPingDuration);
} }
lastAttackLocation = self.CenterPosition.ToCPos();
lastAttackTime = self.World.FrameNumber; lastAttackTime = self.World.FrameNumber;
} }
} }

View File

@@ -27,8 +27,7 @@ namespace OpenRA.Mods.RA
readonly RadarPings radarPings; readonly RadarPings radarPings;
readonly HarvesterAttackNotifierInfo info; readonly HarvesterAttackNotifierInfo info;
public int lastAttackTime; int lastAttackTime;
public CPos lastAttackLocation;
public HarvesterAttackNotifier(Actor self, HarvesterAttackNotifierInfo info) public HarvesterAttackNotifier(Actor self, HarvesterAttackNotifierInfo info)
{ {
@@ -55,7 +54,6 @@ namespace OpenRA.Mods.RA
radarPings.Add(() => self.Owner == self.World.LocalPlayer, self.CenterPosition, info.RadarPingColor, info.RadarPingDuration); radarPings.Add(() => self.Owner == self.World.LocalPlayer, self.CenterPosition, info.RadarPingColor, info.RadarPingDuration);
} }
lastAttackLocation = self.CenterPosition.ToCPos();
lastAttackTime = self.World.FrameNumber; lastAttackTime = self.World.FrameNumber;
} }
} }

View File

@@ -22,12 +22,14 @@ namespace OpenRA.Mods.RA.Widgets
{ {
readonly World world; readonly World world;
readonly WorldRenderer worldRenderer; readonly WorldRenderer worldRenderer;
readonly RadarPings radarPings;
[ObjectCreator.UseCtor] [ObjectCreator.UseCtor]
public WorldCommandWidget(World world, WorldRenderer worldRenderer) public WorldCommandWidget(World world, WorldRenderer worldRenderer)
{ {
this.world = world; this.world = world;
this.worldRenderer = worldRenderer; this.worldRenderer = worldRenderer;
radarPings = world.WorldActor.TraitOrDefault<RadarPings>();
} }
public override string GetCursor(int2 pos) { return null; } public override string GetCursor(int2 pos) { return null; }
@@ -241,17 +243,10 @@ namespace OpenRA.Mods.RA.Widgets
bool ToLastEvent() bool ToLastEvent()
{ {
if (world.LocalPlayer == null) if (radarPings == null || radarPings.LastPingPosition == null)
return true; return true;
var eventNotifier = world.LocalPlayer.PlayerActor.TraitOrDefault<BaseAttackNotifier>(); worldRenderer.Viewport.Center(radarPings.LastPingPosition.Value);
if (eventNotifier == null)
return true;
if (eventNotifier.lastAttackTime < 0)
return true;
worldRenderer.Viewport.Center(eventNotifier.lastAttackLocation.CenterPosition);
return true; return true;
} }

View File

@@ -30,6 +30,8 @@ namespace OpenRA.Mods.RA
public readonly List<RadarPing> Pings = new List<RadarPing>(); public readonly List<RadarPing> Pings = new List<RadarPing>();
readonly RadarPingsInfo info; readonly RadarPingsInfo info;
public WPos? LastPingPosition;
public RadarPings(RadarPingsInfo info) public RadarPings(RadarPingsInfo info)
{ {
this.info = info; this.info = info;
@@ -46,7 +48,12 @@ namespace OpenRA.Mods.RA
{ {
var ping = new RadarPing(isVisible, position, color, duration, var ping = new RadarPing(isVisible, position, color, duration,
info.FromRadius, info.ToRadius, info.ShrinkSpeed, info.RotationSpeed); info.FromRadius, info.ToRadius, info.ShrinkSpeed, info.RotationSpeed);
if (ping.IsVisible())
LastPingPosition = ping.Position;
Pings.Add(ping); Pings.Add(ping);
return ping; return ping;
} }