Iron Curtain.
This commit is contained in:
@@ -16,7 +16,7 @@ using OpenRA.Mods.RA.Effects;
|
|||||||
using OpenRA.Mods.RA.Render;
|
using OpenRA.Mods.RA.Render;
|
||||||
using OpenRA.Traits;
|
using OpenRA.Traits;
|
||||||
using TUtil = OpenRA.Traits.Util;
|
using TUtil = OpenRA.Traits.Util;
|
||||||
/*
|
|
||||||
namespace OpenRA.Mods.RA
|
namespace OpenRA.Mods.RA
|
||||||
{
|
{
|
||||||
class IronCurtainPowerInfo : SupportPowerInfo
|
class IronCurtainPowerInfo : SupportPowerInfo
|
||||||
@@ -27,46 +27,29 @@ namespace OpenRA.Mods.RA
|
|||||||
public override object Create(ActorInitializer init) { return new IronCurtainPower(init.self, this); }
|
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) { }
|
public IronCurtainPower(Actor self, IronCurtainPowerInfo info) : base(self, info) { }
|
||||||
|
public override IOrderGenerator OrderGenerator(string order, SupportPowerManager manager)
|
||||||
protected override void OnBeginCharging() { Sound.PlayToPlayer(Owner, "ironchg1.aud"); }
|
|
||||||
protected override void OnFinishCharging() { Sound.PlayToPlayer(Owner, "ironrdy1.aud"); }
|
|
||||||
protected override void OnActivate()
|
|
||||||
{
|
{
|
||||||
Self.World.OrderGenerator = new SelectTarget(this);
|
Sound.PlayToPlayer(manager.self.Owner, Info.SelectTargetSound);
|
||||||
Sound.Play("slcttgt1.aud");
|
return new SelectTarget(order, manager, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ResolveOrder(Actor self, Order order)
|
public override void Activate(Actor self, Order order)
|
||||||
{
|
{
|
||||||
if (!IsReady) return;
|
self.Trait<RenderBuilding>().PlayCustomAnim(self, "active");
|
||||||
|
|
||||||
if (order.OrderString == "IronCurtain")
|
|
||||||
{
|
|
||||||
var curtain = self.World.Queries
|
|
||||||
.OwnedBy[self.Owner]
|
|
||||||
.WithTrait<IronCurtain>()
|
|
||||||
.Select(x => x.Actor).FirstOrDefault();
|
|
||||||
|
|
||||||
if (curtain != null)
|
|
||||||
curtain.Trait<RenderBuilding>().PlayCustomAnim(curtain, "active");
|
|
||||||
|
|
||||||
Sound.Play("ironcur9.aud", Game.CellSize * order.TargetLocation);
|
|
||||||
foreach (var target in UnitsInRange(order.TargetLocation))
|
|
||||||
target.Trait<IronCurtainable>().Activate(target, (Info as IronCurtainPowerInfo).Duration * 25);
|
|
||||||
|
|
||||||
FinishActivate();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
Sound.Play("ironcur9.aud", Game.CellSize * order.TargetLocation);
|
||||||
|
foreach (var target in UnitsInRange(order.TargetLocation))
|
||||||
|
target.Trait<IronCurtainable>().Activate(target, (Info as IronCurtainPowerInfo).Duration * 25);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<Actor> UnitsInRange(int2 xy)
|
public IEnumerable<Actor> UnitsInRange(int2 xy)
|
||||||
{
|
{
|
||||||
int range = (Info as IronCurtainPowerInfo).Range;
|
int range = (Info as IronCurtainPowerInfo).Range;
|
||||||
var uim = Self.World.WorldActor.Trait<UnitInfluence>();
|
var uim = self.World.WorldActor.Trait<UnitInfluence>();
|
||||||
var tiles = Self.World.FindTilesInCircle(xy, range);
|
var tiles = self.World.FindTilesInCircle(xy, range);
|
||||||
var units = new List<Actor>();
|
var units = new List<Actor>();
|
||||||
foreach (var t in tiles)
|
foreach (var t in tiles)
|
||||||
units.AddRange(uim.GetUnitsAt(t));
|
units.AddRange(uim.GetUnitsAt(t));
|
||||||
@@ -76,12 +59,16 @@ namespace OpenRA.Mods.RA
|
|||||||
|
|
||||||
class SelectTarget : IOrderGenerator
|
class SelectTarget : IOrderGenerator
|
||||||
{
|
{
|
||||||
IronCurtainPower power;
|
readonly IronCurtainPower power;
|
||||||
int range;
|
readonly int range;
|
||||||
Sprite tile;
|
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.power = power;
|
||||||
this.range = (power.Info as IronCurtainPowerInfo).Range;
|
this.range = (power.Info as IronCurtainPowerInfo).Range;
|
||||||
tile = UiOverlay.SynthesizeTile(0x04);
|
tile = UiOverlay.SynthesizeTile(0x04);
|
||||||
@@ -89,28 +76,15 @@ namespace OpenRA.Mods.RA
|
|||||||
|
|
||||||
public IEnumerable<Order> Order(World world, int2 xy, MouseInput mi)
|
public IEnumerable<Order> Order(World world, int2 xy, MouseInput mi)
|
||||||
{
|
{
|
||||||
if (mi.Button == MouseButton.Right)
|
world.CancelInputMode();
|
||||||
world.CancelInputMode();
|
if (mi.Button == MouseButton.Left && power.UnitsInRange(xy).Any())
|
||||||
|
yield return new Order(order, manager.self, false) { TargetLocation = xy };
|
||||||
return OrderInner(world, xy, mi);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
IEnumerable<Order> 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)
|
public void Tick(World world)
|
||||||
{
|
{
|
||||||
var hasStructure = world.Queries.OwnedBy[world.LocalPlayer]
|
// Cancel the OG if we can't use the power
|
||||||
.WithTrait<IronCurtain>()
|
if (!manager.Powers.ContainsKey(order))
|
||||||
.Any();
|
|
||||||
|
|
||||||
if (!hasStructure)
|
|
||||||
world.CancelInputMode();
|
world.CancelInputMode();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -134,9 +108,4 @@ namespace OpenRA.Mods.RA
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// tag trait for the building
|
|
||||||
class IronCurtainInfo : TraitInfo<IronCurtain> { }
|
|
||||||
class IronCurtain { }
|
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
@@ -201,7 +201,16 @@ IRON:
|
|||||||
Range: 10
|
Range: 10
|
||||||
Bib:
|
Bib:
|
||||||
IronCurtainable:
|
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:
|
PDOX:
|
||||||
RequiresPower:
|
RequiresPower:
|
||||||
|
|||||||
@@ -25,13 +25,6 @@ Player:
|
|||||||
BuildSpeed: .4
|
BuildSpeed: .4
|
||||||
LowPowerSlowdown: 3
|
LowPowerSlowdown: 3
|
||||||
PlaceBuilding:
|
PlaceBuilding:
|
||||||
# IronCurtainPower:
|
|
||||||
# Image: infxicon
|
|
||||||
# ChargeTime: 2
|
|
||||||
# Description: Invulnerability
|
|
||||||
# LongDesc: Makes a group of units invulnerable\nfor 10 seconds.
|
|
||||||
# Prerequisites: IRON
|
|
||||||
# Duration: 10
|
|
||||||
# SonarPulsePower:
|
# SonarPulsePower:
|
||||||
# Image: sonricon
|
# Image: sonricon
|
||||||
# ChargeTime: 10
|
# ChargeTime: 10
|
||||||
|
|||||||
Reference in New Issue
Block a user