diff --git a/OpenRa.Game/Orders/IronCurtainOrderGenerator.cs b/OpenRa.Game/Orders/IronCurtainOrderGenerator.cs index 286fef488b..36bf9bc406 100644 --- a/OpenRa.Game/Orders/IronCurtainOrderGenerator.cs +++ b/OpenRa.Game/Orders/IronCurtainOrderGenerator.cs @@ -9,8 +9,8 @@ namespace OpenRa.Game.Orders { class IronCurtainOrderGenerator : IOrderGenerator { - ISupportPowerImpl power; - public IronCurtainOrderGenerator(ISupportPowerImpl power) + SupportPower power; + public IronCurtainOrderGenerator(SupportPower power) { this.power = power; } @@ -36,10 +36,7 @@ namespace OpenRa.Game.Orders var unit = underCursor != null ? underCursor.Info as UnitInfo : null; if (unit != null) - { - yield return new Order("IronCurtain", underCursor, this.power); - //yield return new Order("IronCurtain", underCursor, null, int2.Zero, null); - } + yield return new Order("IronCurtain", underCursor, null, int2.Zero, power.Name); } } diff --git a/OpenRa.Game/Orders/Order.cs b/OpenRa.Game/Orders/Order.cs index 6caa67148d..1501aa68fb 100644 --- a/OpenRa.Game/Orders/Order.cs +++ b/OpenRa.Game/Orders/Order.cs @@ -32,19 +32,6 @@ namespace OpenRa.Game this.TargetLocation = targetLocation; this.TargetString = targetString; } - // This is a hack - fix me - public readonly ISupportPowerImpl Power; - public Order(string orderString, Actor subject, ISupportPowerImpl power) - { - this.OrderString = orderString; - this.SubjectId = UIntFromActor( subject ); - - this.Power = power; - - this.TargetActorId = UIntFromActor(null); - this.TargetLocation = int2.Zero; - this.TargetString = null; - } public bool Validate() { diff --git a/OpenRa.Game/Player.cs b/OpenRa.Game/Player.cs index b84e10f668..b4ff66fe75 100644 --- a/OpenRa.Game/Player.cs +++ b/OpenRa.Game/Player.cs @@ -41,7 +41,7 @@ namespace OpenRa.Game SupportPowers = Rules.SupportPowerInfo.ToDictionary( spi => spi.Key, - spi => new SupportPower(spi.Value, this)); + spi => new SupportPower(spi.Key, spi.Value, this)); } void UpdatePower() diff --git a/OpenRa.Game/SupportPower.cs b/OpenRa.Game/SupportPower.cs index 6740323686..0c54dd6718 100644 --- a/OpenRa.Game/SupportPower.cs +++ b/OpenRa.Game/SupportPower.cs @@ -11,7 +11,8 @@ namespace OpenRa.Game { public readonly SupportPowerInfo Info; public readonly Player Owner; - readonly ISupportPowerImpl Impl; + public readonly ISupportPowerImpl Impl; + public readonly string Name; static ISupportPowerImpl ConstructPowerImpl(string implName) { @@ -21,8 +22,9 @@ namespace OpenRa.Game return (ISupportPowerImpl)ctor.Invoke(new object[] { }); } - public SupportPower(SupportPowerInfo info, Player owner) + public SupportPower(string name, SupportPowerInfo info, Player owner) { + Name = name; Info = info; Owner = owner; RemainingTime = TotalTime = (int)(info.ChargeTime * 60 * 25); diff --git a/OpenRa.Game/SupportPowers/IronCurtainPower.cs b/OpenRa.Game/SupportPowers/IronCurtainPower.cs index 67bb0b5c6d..6b69cd0278 100644 --- a/OpenRa.Game/SupportPowers/IronCurtainPower.cs +++ b/OpenRa.Game/SupportPowers/IronCurtainPower.cs @@ -36,7 +36,7 @@ namespace OpenRa.Game.SupportPowers { this.p = p; // Pick a building to use - Game.controller.orderGenerator = new IronCurtainOrderGenerator(this); + Game.controller.orderGenerator = new IronCurtainOrderGenerator(p); Sound.Play("slcttgt1.aud"); } } diff --git a/OpenRa.Game/Traits/IronCurtainable.cs b/OpenRa.Game/Traits/IronCurtainable.cs index e49ace50a3..bfb691de44 100644 --- a/OpenRa.Game/Traits/IronCurtainable.cs +++ b/OpenRa.Game/Traits/IronCurtainable.cs @@ -28,7 +28,8 @@ namespace OpenRa.Game.Traits { if (order.OrderString == "IronCurtain") { - order.Power.OnFireNotification(self, self.Location); + var power = self.Owner.SupportPowers[order.TargetString].Impl; + power.OnFireNotification(self, self.Location); Game.world.AddFrameEndTask(w => w.Add(new InvulnEffect(self))); RemainingTicks = (int)(Rules.General.IronCurtain * 60 * 25); }