diff --git a/OpenRa.Game/OpenRa.Game.csproj b/OpenRa.Game/OpenRa.Game.csproj
index 82e8e60e09..31292b686b 100644
--- a/OpenRa.Game/OpenRa.Game.csproj
+++ b/OpenRa.Game/OpenRa.Game.csproj
@@ -122,7 +122,7 @@
-
+
diff --git a/OpenRa.Game/Orders/ChronoshiftDestinationOrderGenerator.cs b/OpenRa.Game/Orders/ChronoshiftDestinationOrderGenerator.cs
index a2cd5ef75f..a32d0ca117 100644
--- a/OpenRa.Game/Orders/ChronoshiftDestinationOrderGenerator.cs
+++ b/OpenRa.Game/Orders/ChronoshiftDestinationOrderGenerator.cs
@@ -1,19 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
-using System.Text;
using System.Drawing;
using OpenRa.Game.Traits;
+using OpenRa.Game.SupportPowers;
namespace OpenRa.Game.Orders
{
class ChronoshiftDestinationOrderGenerator : IOrderGenerator
{
public readonly Actor self;
+ SupportPower power;
- public ChronoshiftDestinationOrderGenerator(Actor self)
+ public ChronoshiftDestinationOrderGenerator(Actor self, SupportPower power)
{
this.self = self;
+ this.power = power;
}
public IEnumerable Order(int2 xy, MouseInput mi)
@@ -23,8 +25,8 @@ namespace OpenRa.Game.Orders
Game.controller.CancelInputMode();
yield break;
}
-
- yield return new Order("Chronoshift", self, null, xy, null);
+ yield return new Order("Chronoshift", self, null, xy,
+ power != null ? power.Name : null);
}
public void Tick() {}
diff --git a/OpenRa.Game/Orders/ChronosphereSelectOrderGenerator.cs b/OpenRa.Game/Orders/ChronosphereSelectOrderGenerator.cs
index 4ff3de312d..192f7a6690 100644
--- a/OpenRa.Game/Orders/ChronosphereSelectOrderGenerator.cs
+++ b/OpenRa.Game/Orders/ChronosphereSelectOrderGenerator.cs
@@ -1,14 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
-using System.Text;
using OpenRa.Game.GameRules;
using OpenRa.Game.Traits;
+using OpenRa.Game.SupportPowers;
namespace OpenRa.Game.Orders
{
class ChronosphereSelectOrderGenerator : IOrderGenerator
{
+ ISupportPowerImpl chronospherePower;
+ public ChronosphereSelectOrderGenerator(ISupportPowerImpl chronospherePower)
+ {
+ this.chronospherePower = chronospherePower;
+ }
+
public IEnumerable Order(int2 xy, MouseInput mi)
{
if (mi.Button == MouseButton.Right)
@@ -30,9 +36,7 @@ namespace OpenRa.Game.Orders
var unit = underCursor != null ? underCursor.Info as UnitInfo : null;
if (unit != null)
- {
- yield return new Order("ChronosphereSelect", underCursor, null, int2.Zero, null);
- }
+ yield return new Order("ChronosphereSelect", underCursor, null, int2.Zero, "ChronoshiftPower");
}
}
diff --git a/OpenRa.Game/Orders/IronCurtainOrderGenerator.cs b/OpenRa.Game/Orders/IronCurtainOrderGenerator.cs
index 36bf9bc406..0a75ca1dd6 100644
--- a/OpenRa.Game/Orders/IronCurtainOrderGenerator.cs
+++ b/OpenRa.Game/Orders/IronCurtainOrderGenerator.cs
@@ -1,10 +1,10 @@
using System;
using System.Collections.Generic;
using System.Linq;
-using System.Text;
using OpenRa.Game.GameRules;
using OpenRa.Game.Traits;
using OpenRa.Game.SupportPowers;
+
namespace OpenRa.Game.Orders
{
class IronCurtainOrderGenerator : IOrderGenerator
diff --git a/OpenRa.Game/Orders/Order.cs b/OpenRa.Game/Orders/Order.cs
index 1501aa68fb..754207101b 100644
--- a/OpenRa.Game/Orders/Order.cs
+++ b/OpenRa.Game/Orders/Order.cs
@@ -13,7 +13,7 @@ namespace OpenRa.Game
public readonly int2 TargetLocation;
public readonly string TargetString;
public bool IsImmediate;
-
+
public Actor Subject { get { return ActorFromUInt(SubjectId); } }
public Actor TargetActor { get { return ActorFromUInt(TargetActorId); } }
public Player Player { get { return Subject.Owner; } }
@@ -21,8 +21,8 @@ namespace OpenRa.Game
public Order(string orderString, Actor subject,
Actor targetActor, int2 targetLocation, string targetString)
: this( orderString, UIntFromActor( subject ),
- UIntFromActor( targetActor ), targetLocation, targetString ) {}
-
+ UIntFromActor( targetActor ), targetLocation, targetString) {}
+
Order(string orderString, uint subjectId,
uint targetActorId, int2 targetLocation, string targetString)
{
@@ -30,7 +30,7 @@ namespace OpenRa.Game
this.SubjectId = subjectId;
this.TargetActorId = targetActorId;
this.TargetLocation = targetLocation;
- this.TargetString = targetString;
+ this.TargetString = targetString;
}
public bool Validate()
diff --git a/OpenRa.Game/SupportPowers/Chronoshift.cs b/OpenRa.Game/SupportPowers/Chronoshift.cs
deleted file mode 100644
index ca0968bbeb..0000000000
--- a/OpenRa.Game/SupportPowers/Chronoshift.cs
+++ /dev/null
@@ -1,19 +0,0 @@
-using OpenRa.Game.Orders;
-
-namespace OpenRa.Game.SupportPowers
-{
- class Chronoshift : ISupportPowerImpl
- {
- public void Activate(SupportPower p)
- {
- // todo: someone has to call SupportPower.FinishActivate when we're done!
-
- if (Game.controller.ToggleInputMode())
- Sound.Play("slcttgt1.aud");
- }
-
- public void OnFireNotification(Actor target, int2 xy) {}
- public void IsChargingNotification(SupportPower p) {}
- public void IsReadyNotification(SupportPower p) {}
- }
-}
diff --git a/OpenRa.Game/SupportPowers/ChronospherePower.cs b/OpenRa.Game/SupportPowers/ChronospherePower.cs
new file mode 100644
index 0000000000..bab8c671eb
--- /dev/null
+++ b/OpenRa.Game/SupportPowers/ChronospherePower.cs
@@ -0,0 +1,39 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Drawing;
+using OpenRa.Game.Orders;
+using OpenRa.Game.Traits;
+
+namespace OpenRa.Game.SupportPowers
+{
+ class ChronospherePower : ISupportPowerImpl
+ {
+ public void IsReadyNotification(SupportPower p) { Sound.Play("chrordy1.aud"); }
+ public void IsChargingNotification(SupportPower p) { Sound.Play("chrochr1.aud"); }
+
+ public void OnFireNotification(Actor target, int2 xy)
+ {
+ p.FinishActivate();
+ Game.controller.CancelInputMode();
+
+ Sound.Play("chrono2.aud");
+
+ foreach (var a in Game.world.Actors.Where(a => a.traits.Contains()))
+ a.traits.Get().DoChronoshift();
+
+ // Play chronosphere active anim
+ var chronosphere = Game.world.Actors.Where(a => a.Owner == p.Owner && a.traits.Contains()).FirstOrDefault();
+
+ if (chronosphere != null)
+ chronosphere.traits.Get().PlayCustomAnim(chronosphere, "active");
+ }
+ SupportPower p;
+ public void Activate(SupportPower p)
+ {
+ this.p = p;
+ Game.controller.orderGenerator = new ChronosphereSelectOrderGenerator(this);
+ Sound.Play("slcttgt1.aud");
+ }
+ }
+}
diff --git a/OpenRa.Game/SupportPowers/IronCurtain.cs b/OpenRa.Game/SupportPowers/IronCurtain.cs
deleted file mode 100644
index 815c5271b5..0000000000
--- a/OpenRa.Game/SupportPowers/IronCurtain.cs
+++ /dev/null
@@ -1,15 +0,0 @@
-using OpenRa.Game.Orders;
-
-namespace OpenRa.Game.SupportPowers
-{
- class IronCurtain : ISupportPowerImpl
- {
- public void Activate(SupportPower p)
- {
- // todo: someone has to call SupportPower.FinishActivate when we're done!
-
- if (Game.controller.ToggleInputMode())
- Sound.Play("slcttgt1.aud");
- }
- }
-}
diff --git a/OpenRa.Game/Traits/Chronoshiftable.cs b/OpenRa.Game/Traits/Chronoshiftable.cs
index 923246982a..e5261e5361 100644
--- a/OpenRa.Game/Traits/Chronoshiftable.cs
+++ b/OpenRa.Game/Traits/Chronoshiftable.cs
@@ -2,7 +2,6 @@
using OpenRa.Game.Orders;
using System.Collections.Generic;
using System.Linq;
-using System.Drawing;
namespace OpenRa.Game.Traits
{
@@ -40,7 +39,8 @@ namespace OpenRa.Game.Traits
{
if (order.OrderString == "ChronosphereSelect")
{
- Game.controller.orderGenerator = new ChronoshiftDestinationOrderGenerator(self);
+ var power = self.Owner.SupportPowers[order.TargetString];
+ Game.controller.orderGenerator = new ChronoshiftDestinationOrderGenerator(self, power);
}
var movement = self.traits.WithInterface().FirstOrDefault();
@@ -49,38 +49,28 @@ namespace OpenRa.Game.Traits
// Cannot chronoshift into unexplored location
if (!self.Owner.Shroud.IsExplored(order.TargetLocation))
return;
-
+
// Set up return-to-sender info
chronoshiftOrigin = self.Location;
chronoshiftReturnTicks = (int)(Rules.General.ChronoDuration * 60 * 25);
- var chronosphere = Game.world.Actors.Where(a => a.Owner == order.Subject.Owner
- && a.traits.Contains()).FirstOrDefault();
-
// Kill cargo
if (Rules.General.ChronoKillCargo && self.traits.Contains())
{
var cargo = self.traits.Get();
while (!cargo.IsEmpty(self))
{
- if (chronosphere != null)
- chronosphere.Owner.Kills++;
+ order.Player.Kills++;
cargo.Unload(self);
}
}
// Set up the teleport
- Game.controller.CancelInputMode();
self.CancelActivity();
self.QueueActivity(new Activities.Teleport(order.TargetLocation));
- Sound.Play("chrono2.aud");
- foreach (var a in Game.world.Actors.Where(a => a.traits.Contains()))
- a.traits.Get().DoChronoshift();
-
- // Play chronosphere active anim
- if (chronosphere != null)
- chronosphere.traits.Get().PlayCustomAnim(chronosphere, "active");
+ var power = self.Owner.SupportPowers[order.TargetString].Impl;
+ power.OnFireNotification(self, self.Location);
}
}
diff --git a/units.ini b/units.ini
index 7264c4d7eb..4e22c79415 100644
--- a/units.ini
+++ b/units.ini
@@ -861,7 +861,7 @@ LongDesc=Temporarily teleports a vehicle across \nthe map.
Prerequisite=PDOX
Image=warpicon
TechLevel=12
-Impl=Chronoshift
+Impl=ChronospherePower
[SpyPlanePower] ; free with first AFLD
ChargeTime=3