Merge pull request #4682 from ScottNZ/beacon

closes #2320
closes #3767
closes #3810
This commit is contained in:
Matthias Mailänder
2014-02-23 09:55:23 +01:00
32 changed files with 432 additions and 42 deletions

View File

@@ -22,12 +22,14 @@ namespace OpenRA.Mods.RA.Widgets
{
readonly World world;
readonly WorldRenderer worldRenderer;
readonly RadarPings radarPings;
[ObjectCreator.UseCtor]
public WorldCommandWidget(World world, WorldRenderer worldRenderer)
{
this.world = world;
this.worldRenderer = worldRenderer;
radarPings = world.WorldActor.TraitOrDefault<RadarPings>();
}
public override string GetCursor(int2 pos) { return null; }
@@ -63,6 +65,9 @@ namespace OpenRA.Mods.RA.Widgets
if (key == ks.ToggleStatusBarsKey)
return ToggleStatusBars();
if (key == ks.PlaceBeaconKey)
return PerformPlaceBeacon();
// Put all functions that aren't unit-specific before this line!
if (!world.Selection.Actors.Any())
return false;
@@ -184,6 +189,15 @@ namespace OpenRA.Mods.RA.Widgets
return true;
}
bool PerformPlaceBeacon()
{
if (world.LocalPlayer == null)
return true;
world.OrderGenerator = new GenericSelectTarget(world.LocalPlayer.PlayerActor, "PlaceBeacon", "ability");
return true;
}
bool CycleBases()
{
var bases = world.ActorsWithTrait<BaseBuilding>()
@@ -233,17 +247,10 @@ namespace OpenRA.Mods.RA.Widgets
bool ToLastEvent()
{
if (world.LocalPlayer == null)
if (radarPings == null || radarPings.LastPingPosition == null)
return true;
var eventNotifier = world.LocalPlayer.PlayerActor.TraitOrDefault<BaseAttackNotifier>();
if (eventNotifier == null)
return true;
if (eventNotifier.lastAttackTime < 0)
return true;
worldRenderer.Viewport.Center(eventNotifier.lastAttackLocation.CenterPosition);
worldRenderer.Viewport.Center(radarPings.LastPingPosition.Value);
return true;
}