From 6b05b2c2f0b70db76689543abd16e683732f11a1 Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Sun, 5 Dec 2010 22:43:18 +1300 Subject: [PATCH] Iron Curtain. --- .../SupportPowers/IronCurtainPower.cs | 85 ++++++------------- mods/ra/rules/structures.yaml | 11 ++- mods/ra/rules/system.yaml | 7 -- 3 files changed, 37 insertions(+), 66 deletions(-) diff --git a/OpenRA.Mods.RA/SupportPowers/IronCurtainPower.cs b/OpenRA.Mods.RA/SupportPowers/IronCurtainPower.cs index c6c3b02656..99442db0b1 100755 --- a/OpenRA.Mods.RA/SupportPowers/IronCurtainPower.cs +++ b/OpenRA.Mods.RA/SupportPowers/IronCurtainPower.cs @@ -16,7 +16,7 @@ using OpenRA.Mods.RA.Effects; using OpenRA.Mods.RA.Render; using OpenRA.Traits; using TUtil = OpenRA.Traits.Util; -/* + namespace OpenRA.Mods.RA { class IronCurtainPowerInfo : SupportPowerInfo @@ -27,46 +27,29 @@ namespace OpenRA.Mods.RA public override object Create(ActorInitializer init) { return new IronCurtainPower(init.self, this); } } - class IronCurtainPower : SupportPower, IResolveOrder + class IronCurtainPower : SupportPower { public IronCurtainPower(Actor self, IronCurtainPowerInfo info) : base(self, info) { } - - protected override void OnBeginCharging() { Sound.PlayToPlayer(Owner, "ironchg1.aud"); } - protected override void OnFinishCharging() { Sound.PlayToPlayer(Owner, "ironrdy1.aud"); } - protected override void OnActivate() + public override IOrderGenerator OrderGenerator(string order, SupportPowerManager manager) { - Self.World.OrderGenerator = new SelectTarget(this); - Sound.Play("slcttgt1.aud"); + Sound.PlayToPlayer(manager.self.Owner, Info.SelectTargetSound); + return new SelectTarget(order, manager, this); } - - public void ResolveOrder(Actor self, Order order) + + public override void Activate(Actor self, Order order) { - if (!IsReady) return; - - if (order.OrderString == "IronCurtain") - { - var curtain = self.World.Queries - .OwnedBy[self.Owner] - .WithTrait() - .Select(x => x.Actor).FirstOrDefault(); - - if (curtain != null) - curtain.Trait().PlayCustomAnim(curtain, "active"); - - Sound.Play("ironcur9.aud", Game.CellSize * order.TargetLocation); - foreach (var target in UnitsInRange(order.TargetLocation)) - target.Trait().Activate(target, (Info as IronCurtainPowerInfo).Duration * 25); - - FinishActivate(); - } + self.Trait().PlayCustomAnim(self, "active"); + Sound.Play("ironcur9.aud", Game.CellSize * order.TargetLocation); + foreach (var target in UnitsInRange(order.TargetLocation)) + target.Trait().Activate(target, (Info as IronCurtainPowerInfo).Duration * 25); } public IEnumerable UnitsInRange(int2 xy) { int range = (Info as IronCurtainPowerInfo).Range; - var uim = Self.World.WorldActor.Trait(); - var tiles = Self.World.FindTilesInCircle(xy, range); + var uim = self.World.WorldActor.Trait(); + var tiles = self.World.FindTilesInCircle(xy, range); var units = new List(); foreach (var t in tiles) units.AddRange(uim.GetUnitsAt(t)); @@ -76,12 +59,16 @@ namespace OpenRA.Mods.RA class SelectTarget : IOrderGenerator { - IronCurtainPower power; - int range; - Sprite tile; + readonly IronCurtainPower power; + readonly int range; + readonly Sprite tile; + readonly SupportPowerManager manager; + readonly string order; - public SelectTarget(IronCurtainPower power) + public SelectTarget(string order, SupportPowerManager manager, IronCurtainPower power) { + this.manager = manager; + this.order = order; this.power = power; this.range = (power.Info as IronCurtainPowerInfo).Range; tile = UiOverlay.SynthesizeTile(0x04); @@ -89,28 +76,15 @@ namespace OpenRA.Mods.RA public IEnumerable Order(World world, int2 xy, MouseInput mi) { - if (mi.Button == MouseButton.Right) - world.CancelInputMode(); - - return OrderInner(world, xy, mi); + world.CancelInputMode(); + if (mi.Button == MouseButton.Left && power.UnitsInRange(xy).Any()) + yield return new Order(order, manager.self, false) { TargetLocation = xy }; } - - IEnumerable OrderInner(World world, int2 xy, MouseInput mi) - { - if (mi.Button == MouseButton.Left && power.UnitsInRange(xy).Any() ) - { - world.CancelInputMode(); - yield return new Order("IronCurtain", world.LocalPlayer.PlayerActor, false) { TargetLocation = xy }; - } - } - + public void Tick(World world) { - var hasStructure = world.Queries.OwnedBy[world.LocalPlayer] - .WithTrait() - .Any(); - - if (!hasStructure) + // Cancel the OG if we can't use the power + if (!manager.Powers.ContainsKey(order)) world.CancelInputMode(); } @@ -134,9 +108,4 @@ namespace OpenRA.Mods.RA } } } - - // tag trait for the building - class IronCurtainInfo : TraitInfo { } - class IronCurtain { } } -*/ \ No newline at end of file diff --git a/mods/ra/rules/structures.yaml b/mods/ra/rules/structures.yaml index 8b518ace88..927804d3a3 100755 --- a/mods/ra/rules/structures.yaml +++ b/mods/ra/rules/structures.yaml @@ -201,7 +201,16 @@ IRON: Range: 10 Bib: IronCurtainable: -# IronCurtain: + IronCurtainPower: + Image: infxicon +# ChargeTime: 120 + ChargeTime: 10 + Description: Invulnerability + LongDesc: Makes a group of units invulnerable\nfor 10 seconds. + Duration: 10 + SelectTargetSound: slcttgt1.aud + BeginChargeSound: ironchg1.aud + EndChargeSound: ironrdy1.aud PDOX: RequiresPower: diff --git a/mods/ra/rules/system.yaml b/mods/ra/rules/system.yaml index 5ca42f90aa..22172ee041 100644 --- a/mods/ra/rules/system.yaml +++ b/mods/ra/rules/system.yaml @@ -25,13 +25,6 @@ Player: BuildSpeed: .4 LowPowerSlowdown: 3 PlaceBuilding: -# IronCurtainPower: -# Image: infxicon -# ChargeTime: 2 -# Description: Invulnerability -# LongDesc: Makes a group of units invulnerable\nfor 10 seconds. -# Prerequisites: IRON -# Duration: 10 # SonarPulsePower: # Image: sonricon # ChargeTime: 10