use spacebar to go to last attack event

This commit is contained in:
Chris Forbes
2011-12-31 10:36:53 +13:00
parent 85eeb8b819
commit 0d25b6b5c9
2 changed files with 24 additions and 3 deletions

View File

@@ -27,8 +27,8 @@ namespace OpenRA.Mods.RA
{ {
BaseAttackNotifierInfo info; BaseAttackNotifierInfo info;
public int lastAttackTime; public int lastAttackTime = -1;
public int2 lastAttackLocation; public float2 lastAttackLocation;
public BaseAttackNotifier(BaseAttackNotifierInfo info) { this.info = info; } public BaseAttackNotifier(BaseAttackNotifierInfo info) { this.info = info; }
@@ -45,7 +45,7 @@ namespace OpenRA.Mods.RA
if (self.World.FrameNumber - lastAttackTime > info.NotifyInterval * 25) if (self.World.FrameNumber - lastAttackTime > info.NotifyInterval * 25)
Sound.PlayToPlayer(self.Owner, info.Audio); Sound.PlayToPlayer(self.Owner, info.Audio);
lastAttackLocation = self.Location; lastAttackLocation = self.CenterLocation / Game.CellSize;
lastAttackTime = self.World.FrameNumber; lastAttackTime = self.World.FrameNumber;
} }
} }

View File

@@ -29,6 +29,8 @@ namespace OpenRA.Mods.RA.Widgets
public string DeployKey = "f"; public string DeployKey = "f";
public string StanceCycleKey = "z"; public string StanceCycleKey = "z";
public string BaseCycleKey = "backspace"; public string BaseCycleKey = "backspace";
public string GotoLastEventKey = "space";
public readonly OrderManager OrderManager; public readonly OrderManager OrderManager;
[ObjectCreator.UseCtor] [ObjectCreator.UseCtor]
@@ -52,6 +54,9 @@ namespace OpenRA.Mods.RA.Widgets
if (e.KeyName == BaseCycleKey) if (e.KeyName == BaseCycleKey)
return CycleBases(); return CycleBases();
if (e.KeyName == GotoLastEventKey)
return GotoLastEvent();
if (!World.Selection.Actors.Any()) if (!World.Selection.Actors.Any())
return false; return false;
@@ -162,5 +167,21 @@ namespace OpenRA.Mods.RA.Widgets
Game.viewport.Center(World.Selection.Actors); Game.viewport.Center(World.Selection.Actors);
return true; return true;
} }
bool GotoLastEvent()
{
if (World.LocalPlayer == null)
return true;
var eventNotifier = World.LocalPlayer.PlayerActor.TraitOrDefault<BaseAttackNotifier>();
if (eventNotifier == null)
return true;
if (eventNotifier.lastAttackTime < 0)
return true;
Game.viewport.Center(eventNotifier.lastAttackLocation);
return true;
}
} }
} }