move ActorGroupProxy to mod; move SupportPower traits into directory
This commit is contained in:
82
OpenRA.Mods.RA/SupportPowers/AirstrikePower.cs
Executable file
82
OpenRA.Mods.RA/SupportPowers/AirstrikePower.cs
Executable file
@@ -0,0 +1,82 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford.
|
||||
* This file is part of OpenRA.
|
||||
*
|
||||
* OpenRA is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* OpenRA is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with OpenRA. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using OpenRA.Orders;
|
||||
using OpenRA.Traits;
|
||||
using OpenRA.Traits.Activities;
|
||||
using OpenRA.Mods.RA.Activities;
|
||||
|
||||
namespace OpenRA.Mods.RA
|
||||
{
|
||||
class AirstrikePowerInfo : SupportPowerInfo
|
||||
{
|
||||
[ActorReference]
|
||||
public readonly string UnitType = "badr.bomber";
|
||||
[ActorReference]
|
||||
public readonly string FlareType = null;
|
||||
|
||||
public override object Create(ActorInitializer init) { return new AirstrikePower(init.self, this); }
|
||||
}
|
||||
|
||||
class AirstrikePower : SupportPower, IResolveOrder
|
||||
{
|
||||
public AirstrikePower(Actor self, AirstrikePowerInfo info) : base(self, info) { }
|
||||
|
||||
protected override void OnActivate()
|
||||
{
|
||||
Game.controller.orderGenerator = new GenericSelectTarget(Owner.PlayerActor, Info.OrderName, "ability");
|
||||
}
|
||||
|
||||
public void ResolveOrder(Actor self, Order order)
|
||||
{
|
||||
if (!IsAvailable) return;
|
||||
|
||||
if (order.OrderString == Info.OrderName)
|
||||
{
|
||||
var startPos = Owner.World.ChooseRandomEdgeCell();
|
||||
|
||||
Owner.World.AddFrameEndTask(w =>
|
||||
{
|
||||
var flareType = (Info as AirstrikePowerInfo).FlareType;
|
||||
var flare = flareType != null ? w.CreateActor(flareType, order.TargetLocation, Owner) : null;
|
||||
|
||||
var a = w.CreateActor((Info as AirstrikePowerInfo).UnitType, startPos, Owner);
|
||||
a.traits.Get<Unit>().Facing = Util.GetFacing(order.TargetLocation - startPos, 0);
|
||||
a.traits.Get<Unit>().Altitude = a.Info.Traits.Get<PlaneInfo>().CruiseAltitude;
|
||||
a.traits.Get<CarpetBomb>().SetTarget(order.TargetLocation);
|
||||
|
||||
a.CancelActivity();
|
||||
a.QueueActivity(new Fly(order.TargetLocation));
|
||||
|
||||
if (flare != null)
|
||||
a.QueueActivity(new CallFunc(() => Owner.World.AddFrameEndTask(_w => _w.Remove(flare))));
|
||||
|
||||
a.QueueActivity(new FlyOffMap { Interruptible = false });
|
||||
a.QueueActivity(new RemoveSelf());
|
||||
});
|
||||
|
||||
if (Owner == Owner.World.LocalPlayer)
|
||||
Game.controller.CancelInputMode();
|
||||
|
||||
FinishActivate();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
195
OpenRA.Mods.RA/SupportPowers/ChronoshiftPower.cs
Executable file
195
OpenRA.Mods.RA/SupportPowers/ChronoshiftPower.cs
Executable file
@@ -0,0 +1,195 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford.
|
||||
* This file is part of OpenRA.
|
||||
*
|
||||
* OpenRA is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* OpenRA is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with OpenRA. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.RA
|
||||
{
|
||||
class ChronoshiftPowerInfo : SupportPowerInfo
|
||||
{
|
||||
public override object Create(ActorInitializer init) { return new ChronoshiftPower(init.self,this); }
|
||||
}
|
||||
|
||||
class ChronoshiftPower : SupportPower, IResolveOrder
|
||||
{
|
||||
public ChronoshiftPower(Actor self, ChronoshiftPowerInfo info) : base(self, info) { }
|
||||
protected override void OnActivate() { Game.controller.orderGenerator = new SelectTarget(); }
|
||||
|
||||
public void ResolveOrder(Actor self, Order order)
|
||||
{
|
||||
if (!IsAvailable) return;
|
||||
|
||||
if (order.OrderString == "ChronosphereSelect" && self.Owner == self.World.LocalPlayer)
|
||||
{
|
||||
Game.controller.orderGenerator = new SelectDestination(order.TargetActor);
|
||||
}
|
||||
|
||||
if (order.OrderString == "ChronosphereActivate")
|
||||
{
|
||||
if (self.Owner == self.World.LocalPlayer)
|
||||
Game.controller.CancelInputMode();
|
||||
|
||||
// Ensure the target cell is valid for the unit
|
||||
var movement = order.TargetActor.traits.GetOrDefault<IMove>();
|
||||
if (!movement.CanEnterCell(order.TargetLocation))
|
||||
return;
|
||||
|
||||
var chronosphere = self.World.Queries
|
||||
.OwnedBy[self.Owner]
|
||||
.WithTrait<Chronosphere>()
|
||||
.Select(x => x.Actor).FirstOrDefault();
|
||||
|
||||
chronosphere.traits.Get<Chronosphere>().Teleport(order.TargetActor, order.TargetLocation);
|
||||
|
||||
FinishActivate();
|
||||
}
|
||||
}
|
||||
|
||||
class SelectTarget : IOrderGenerator
|
||||
{
|
||||
public IEnumerable<Order> Order(World world, int2 xy, MouseInput mi)
|
||||
{
|
||||
if (mi.Button == MouseButton.Right)
|
||||
Game.controller.CancelInputMode();
|
||||
|
||||
return OrderInner(world, xy, mi);
|
||||
}
|
||||
|
||||
IEnumerable<Order> OrderInner(World world, int2 xy, MouseInput mi)
|
||||
{
|
||||
if (mi.Button == MouseButton.Left)
|
||||
{
|
||||
var underCursor = world.FindUnitsAtMouse(mi.Location)
|
||||
.Where(a => a.Owner != null && a.traits.Contains<Chronoshiftable>()
|
||||
&& a.traits.Contains<Selectable>()).FirstOrDefault();
|
||||
|
||||
if (underCursor != null)
|
||||
yield return new Order("ChronosphereSelect", world.LocalPlayer.PlayerActor, underCursor);
|
||||
}
|
||||
|
||||
yield break;
|
||||
}
|
||||
|
||||
public void Tick( World world )
|
||||
{
|
||||
var hasChronosphere = world.Queries.OwnedBy[world.LocalPlayer]
|
||||
.WithTrait<Chronosphere>()
|
||||
.Any();
|
||||
|
||||
if (!hasChronosphere)
|
||||
Game.controller.CancelInputMode();
|
||||
|
||||
// TODO: Check if the selected unit is still alive
|
||||
}
|
||||
|
||||
public void Render( World world ) { }
|
||||
|
||||
public string GetCursor(World world, int2 xy, MouseInput mi)
|
||||
{
|
||||
mi.Button = MouseButton.Left;
|
||||
return OrderInner(world, xy, mi).Any()
|
||||
? "chrono-select" : "move-blocked";
|
||||
}
|
||||
}
|
||||
|
||||
class SelectDestination : IOrderGenerator
|
||||
{
|
||||
Actor self;
|
||||
public SelectDestination(Actor self) { this.self = self; }
|
||||
|
||||
public IEnumerable<Order> Order(World world, int2 xy, MouseInput mi)
|
||||
{
|
||||
if (mi.Button == MouseButton.Right)
|
||||
{
|
||||
Game.controller.CancelInputMode();
|
||||
yield break;
|
||||
}
|
||||
|
||||
// Cannot chronoshift into unexplored location
|
||||
if (world.LocalPlayer.Shroud.IsExplored(xy))
|
||||
yield return new Order("ChronosphereActivate", world.LocalPlayer.PlayerActor, self, xy);
|
||||
}
|
||||
|
||||
public void Tick(World world)
|
||||
{
|
||||
var hasChronosphere = world.Queries.OwnedBy[world.LocalPlayer]
|
||||
.WithTrait<Chronosphere>()
|
||||
.Any();
|
||||
|
||||
if (!hasChronosphere)
|
||||
Game.controller.CancelInputMode();
|
||||
|
||||
// TODO: Check if the selected unit is still alive
|
||||
}
|
||||
|
||||
public void Render(World world)
|
||||
{
|
||||
world.WorldRenderer.DrawSelectionBox(self, Color.Red, true);
|
||||
}
|
||||
|
||||
public string GetCursor(World world, int2 xy, MouseInput mi)
|
||||
{
|
||||
if (!world.LocalPlayer.Shroud.IsExplored(xy))
|
||||
return "move-blocked";
|
||||
|
||||
var movement = self.traits.GetOrDefault<IMove>();
|
||||
return (movement.CanEnterCell(xy)) ? "chrono-target" : "move-blocked";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// tag trait for the building
|
||||
class ChronosphereInfo : ITraitInfo
|
||||
{
|
||||
public readonly int Duration = 30;
|
||||
public readonly bool KillCargo = true;
|
||||
public object Create(ActorInitializer init) { return new Chronosphere(init.self); }
|
||||
}
|
||||
|
||||
class Chronosphere
|
||||
{
|
||||
Actor self;
|
||||
public Chronosphere(Actor self)
|
||||
{
|
||||
this.self = self;
|
||||
}
|
||||
|
||||
public void Teleport(Actor targetActor, int2 targetLocation)
|
||||
{
|
||||
var info = self.Info.Traits.Get<ChronosphereInfo>();
|
||||
bool success = targetActor.traits.Get<Chronoshiftable>().Activate(targetActor, targetLocation, info.Duration * 25, info.KillCargo, self);
|
||||
|
||||
if (success)
|
||||
{
|
||||
Sound.Play("chrono2.aud", self.CenterLocation);
|
||||
Sound.Play("chrono2.aud", targetActor.CenterLocation);
|
||||
|
||||
// Trigger screen desaturate effect
|
||||
foreach (var a in self.World.Queries.WithTrait<ChronoshiftPaletteEffect>())
|
||||
a.Trait.Enable();
|
||||
|
||||
self.traits.Get<RenderBuilding>().PlayCustomAnim(self, "active");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
63
OpenRA.Mods.RA/SupportPowers/GpsPower.cs
Executable file
63
OpenRA.Mods.RA/SupportPowers/GpsPower.cs
Executable file
@@ -0,0 +1,63 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford.
|
||||
* This file is part of OpenRA.
|
||||
*
|
||||
* OpenRA is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* OpenRA is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with OpenRA. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System.Linq;
|
||||
using OpenRA.Effects;
|
||||
using OpenRA.Mods.RA.Effects;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.RA
|
||||
{
|
||||
class GpsPowerInfo : SupportPowerInfo
|
||||
{
|
||||
public readonly int RevealDelay = 0;
|
||||
|
||||
public override object Create(ActorInitializer init) { return new GpsPower(init.self, this); }
|
||||
}
|
||||
|
||||
class GpsPower : SupportPower
|
||||
{
|
||||
public GpsPower(Actor self, GpsPowerInfo info) : base(self, info) { }
|
||||
|
||||
protected override void OnFinishCharging()
|
||||
{
|
||||
var launchSite = Owner.World.Queries.OwnedBy[Owner]
|
||||
.FirstOrDefault(a => a.traits.Contains<GpsLaunchSite>());
|
||||
|
||||
if (launchSite == null)
|
||||
return;
|
||||
|
||||
Owner.World.AddFrameEndTask(w =>
|
||||
{
|
||||
Sound.PlayToPlayer(Owner, Info.LaunchSound);
|
||||
|
||||
w.Add(new SatelliteLaunch(launchSite));
|
||||
w.Add(new DelayedAction((Info as GpsPowerInfo).RevealDelay * 25,
|
||||
() => Owner.Shroud.Disabled = true));
|
||||
});
|
||||
|
||||
FinishActivate();
|
||||
}
|
||||
}
|
||||
|
||||
// tag trait to identify the building
|
||||
class GpsLaunchSiteInfo : TraitInfo<GpsLaunchSite> { }
|
||||
class GpsLaunchSite { }
|
||||
}
|
||||
121
OpenRA.Mods.RA/SupportPowers/IronCurtainPower.cs
Executable file
121
OpenRA.Mods.RA/SupportPowers/IronCurtainPower.cs
Executable file
@@ -0,0 +1,121 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford.
|
||||
* This file is part of OpenRA.
|
||||
*
|
||||
* OpenRA is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* OpenRA is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with OpenRA. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.RA
|
||||
{
|
||||
class IronCurtainPowerInfo : SupportPowerInfo
|
||||
{
|
||||
public readonly float Duration = 0f;
|
||||
public override object Create(ActorInitializer init) { return new IronCurtainPower(init.self, this); }
|
||||
}
|
||||
|
||||
class IronCurtainPower : SupportPower, IResolveOrder
|
||||
{
|
||||
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()
|
||||
{
|
||||
Game.controller.orderGenerator = new SelectTarget();
|
||||
Sound.Play("slcttgt1.aud");
|
||||
}
|
||||
|
||||
public void ResolveOrder(Actor self, Order order)
|
||||
{
|
||||
if (!IsAvailable) return;
|
||||
|
||||
if (order.OrderString == "IronCurtain")
|
||||
{
|
||||
if (self.Owner == self.World.LocalPlayer)
|
||||
Game.controller.CancelInputMode();
|
||||
|
||||
var curtain = self.World.Queries.WithTrait<IronCurtain>()
|
||||
.Where(a => a.Actor.Owner != null)
|
||||
.FirstOrDefault().Actor;
|
||||
if (curtain != null)
|
||||
curtain.traits.Get<RenderBuilding>().PlayCustomAnim(curtain, "active");
|
||||
|
||||
Sound.Play("ironcur9.aud", order.TargetActor.CenterLocation);
|
||||
|
||||
order.TargetActor.traits.Get<IronCurtainable>().Activate(order.TargetActor,
|
||||
(int)((Info as IronCurtainPowerInfo).Duration * 25 * 60));
|
||||
|
||||
FinishActivate();
|
||||
}
|
||||
}
|
||||
|
||||
class SelectTarget : IOrderGenerator
|
||||
{
|
||||
public SelectTarget() { }
|
||||
|
||||
public IEnumerable<Order> Order(World world, int2 xy, MouseInput mi)
|
||||
{
|
||||
if (mi.Button == MouseButton.Right)
|
||||
Game.controller.CancelInputMode();
|
||||
|
||||
return OrderInner(world, xy, mi);
|
||||
}
|
||||
|
||||
IEnumerable<Order> OrderInner(World world, int2 xy, MouseInput mi)
|
||||
{
|
||||
if (mi.Button == MouseButton.Left)
|
||||
{
|
||||
var underCursor = world.FindUnitsAtMouse(mi.Location)
|
||||
.Where(a => a.Owner != null
|
||||
&& a.traits.Contains<IronCurtainable>()
|
||||
&& a.traits.Contains<Selectable>()).FirstOrDefault();
|
||||
|
||||
if (underCursor != null)
|
||||
yield return new Order("IronCurtain", underCursor.Owner.PlayerActor, underCursor);
|
||||
}
|
||||
|
||||
yield break;
|
||||
}
|
||||
|
||||
public void Tick(World world)
|
||||
{
|
||||
var hasStructure = world.Queries.OwnedBy[world.LocalPlayer]
|
||||
.WithTrait<IronCurtain>()
|
||||
.Any();
|
||||
|
||||
if (!hasStructure)
|
||||
Game.controller.CancelInputMode();
|
||||
}
|
||||
|
||||
public void Render(World world) { }
|
||||
|
||||
public string GetCursor(World world, int2 xy, MouseInput mi)
|
||||
{
|
||||
mi.Button = MouseButton.Left;
|
||||
return OrderInner(world, xy, mi).Any()
|
||||
? "ability" : "move-blocked";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// tag trait for the building
|
||||
class IronCurtainInfo : TraitInfo<IronCurtain> { }
|
||||
class IronCurtain { }
|
||||
}
|
||||
94
OpenRA.Mods.RA/SupportPowers/NukePower.cs
Executable file
94
OpenRA.Mods.RA/SupportPowers/NukePower.cs
Executable file
@@ -0,0 +1,94 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford.
|
||||
* This file is part of OpenRA.
|
||||
*
|
||||
* OpenRA is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* OpenRA is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with OpenRA. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System.Linq;
|
||||
using OpenRA.Mods.RA.Effects;
|
||||
using OpenRA.Orders;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.RA
|
||||
{
|
||||
class NukePowerInfo : SupportPowerInfo
|
||||
{
|
||||
public override object Create(ActorInitializer init) { return new NukePower(init.self, this); }
|
||||
}
|
||||
|
||||
class NukePower : SupportPower, IResolveOrder
|
||||
{
|
||||
public NukePower(Actor self, NukePowerInfo info) : base(self, info) { }
|
||||
|
||||
protected override void OnActivate()
|
||||
{
|
||||
Game.controller.orderGenerator =
|
||||
new GenericSelectTargetWithBuilding<NukeSilo>(Owner.PlayerActor, "NuclearMissile", "nuke");
|
||||
}
|
||||
|
||||
public void ResolveOrder(Actor self, Order order)
|
||||
{
|
||||
if (!IsAvailable) return;
|
||||
|
||||
if (order.OrderString == "NuclearMissile")
|
||||
{
|
||||
var silo = self.World.Queries.OwnedBy[self.Owner]
|
||||
.Where(a => a.traits.Contains<NukeSilo>())
|
||||
.FirstOrDefault();
|
||||
if (silo != null)
|
||||
silo.traits.Get<RenderBuilding>().PlayCustomAnim(silo, "active");
|
||||
|
||||
// Play to everyone but the current player
|
||||
if (Owner != Owner.World.LocalPlayer)
|
||||
Sound.Play(Info.LaunchSound);
|
||||
|
||||
silo.traits.Get<NukeSilo>().Attack(order.TargetLocation);
|
||||
|
||||
Game.controller.CancelInputMode();
|
||||
FinishActivate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// tag trait for the building
|
||||
class NukeSiloInfo : ITraitInfo
|
||||
{
|
||||
[WeaponReference]
|
||||
public readonly string MissileWeapon = "";
|
||||
public object Create(ActorInitializer init) { return new NukeSilo(init.self); }
|
||||
}
|
||||
|
||||
class NukeSilo
|
||||
{
|
||||
Actor self;
|
||||
public NukeSilo(Actor self)
|
||||
{
|
||||
this.self = self;
|
||||
}
|
||||
|
||||
public void Attack(int2 targetLocation)
|
||||
{
|
||||
self.traits.Get<RenderBuilding>().PlayCustomAnim(self, "active");
|
||||
|
||||
self.World.AddFrameEndTask(w =>
|
||||
{
|
||||
//FIRE ZE MISSILES
|
||||
w.Add(new NukeLaunch(self, self.Info.Traits.Get<NukeSiloInfo>().MissileWeapon, targetLocation));
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
89
OpenRA.Mods.RA/SupportPowers/ParatroopersPower.cs
Executable file
89
OpenRA.Mods.RA/SupportPowers/ParatroopersPower.cs
Executable file
@@ -0,0 +1,89 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford.
|
||||
* This file is part of OpenRA.
|
||||
*
|
||||
* OpenRA is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* OpenRA is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with OpenRA. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using OpenRA.Orders;
|
||||
using OpenRA.Traits;
|
||||
using OpenRA.Traits.Activities;
|
||||
using OpenRA.Mods.RA.Activities;
|
||||
|
||||
namespace OpenRA.Mods.RA
|
||||
{
|
||||
class ParatroopersPowerInfo : SupportPowerInfo
|
||||
{
|
||||
[ActorReference]
|
||||
public string[] DropItems = { };
|
||||
[ActorReference]
|
||||
public string UnitType = "badr";
|
||||
[ActorReference]
|
||||
public string FlareType = "flare";
|
||||
|
||||
public override object Create(ActorInitializer init) { return new ParatroopersPower(init.self, this); }
|
||||
}
|
||||
|
||||
class ParatroopersPower : SupportPower, IResolveOrder
|
||||
{
|
||||
public ParatroopersPower(Actor self, ParatroopersPowerInfo info) : base(self, info) { }
|
||||
|
||||
protected override void OnActivate()
|
||||
{
|
||||
Game.controller.orderGenerator =
|
||||
new GenericSelectTarget( Owner.PlayerActor, "ParatroopersActivate", "ability" );
|
||||
}
|
||||
|
||||
public void ResolveOrder(Actor self, Order order)
|
||||
{
|
||||
if (!IsAvailable) return;
|
||||
|
||||
if (order.OrderString == "ParatroopersActivate")
|
||||
{
|
||||
if (self.Owner == self.World.LocalPlayer)
|
||||
Game.controller.CancelInputMode();
|
||||
|
||||
DoParadrop(Owner, order.TargetLocation,
|
||||
self.Info.Traits.Get<ParatroopersPowerInfo>().DropItems);
|
||||
|
||||
FinishActivate();
|
||||
}
|
||||
}
|
||||
|
||||
void DoParadrop(Player owner, int2 p, string[] items)
|
||||
{
|
||||
var startPos = owner.World.ChooseRandomEdgeCell();
|
||||
owner.World.AddFrameEndTask(w =>
|
||||
{
|
||||
var flareType = (Info as ParatroopersPowerInfo).FlareType;
|
||||
var flare = flareType != null ? w.CreateActor(flareType, p, owner) : null;
|
||||
|
||||
var a = w.CreateActor((Info as ParatroopersPowerInfo).UnitType, startPos, owner);
|
||||
a.traits.Get<Unit>().Facing = Util.GetFacing(p - startPos, 0);
|
||||
a.traits.Get<Unit>().Altitude = a.Info.Traits.Get<PlaneInfo>().CruiseAltitude;
|
||||
|
||||
a.CancelActivity();
|
||||
a.QueueActivity(new FlyCircle(p));
|
||||
a.traits.Get<ParaDrop>().SetLZ(p, flare);
|
||||
|
||||
var cargo = a.traits.Get<Cargo>();
|
||||
foreach (var i in items)
|
||||
cargo.Load(a, new Actor(owner.World, i.ToLowerInvariant(),
|
||||
new int2(0,0), a.Owner));
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
56
OpenRA.Mods.RA/SupportPowers/SonarPulsePower.cs
Executable file
56
OpenRA.Mods.RA/SupportPowers/SonarPulsePower.cs
Executable file
@@ -0,0 +1,56 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford.
|
||||
* This file is part of OpenRA.
|
||||
*
|
||||
* OpenRA is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* OpenRA is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with OpenRA. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.RA
|
||||
{
|
||||
public class SonarPulsePowerInfo : SupportPowerInfo
|
||||
{
|
||||
public override object Create(ActorInitializer init) { return new SonarPulsePower(init.self, this); }
|
||||
}
|
||||
|
||||
public class SonarPulsePower : SupportPower, IResolveOrder
|
||||
{
|
||||
public SonarPulsePower(Actor self, SonarPulsePowerInfo info) : base(self, info) { }
|
||||
|
||||
protected override void OnBeginCharging() { }
|
||||
protected override void OnFinishCharging() { Sound.PlayToPlayer(Owner, "pulse1.aud"); }
|
||||
|
||||
protected override void OnActivate()
|
||||
{
|
||||
Game.IssueOrder(new Order("SonarPulse", Owner.PlayerActor));
|
||||
}
|
||||
|
||||
public void ResolveOrder(Actor self, Order order)
|
||||
{
|
||||
if (!IsAvailable) return;
|
||||
|
||||
if (order.OrderString == "SonarPulse")
|
||||
{
|
||||
// TODO: Reveal submarines
|
||||
|
||||
// Should this play for all players?
|
||||
Sound.Play("sonpulse.aud");
|
||||
FinishActivate();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
75
OpenRA.Mods.RA/SupportPowers/SpyPlanePower.cs
Executable file
75
OpenRA.Mods.RA/SupportPowers/SpyPlanePower.cs
Executable file
@@ -0,0 +1,75 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford.
|
||||
* This file is part of OpenRA.
|
||||
*
|
||||
* OpenRA is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* OpenRA is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with OpenRA. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using OpenRA.Mods.RA.Activities;
|
||||
using OpenRA.Orders;
|
||||
using OpenRA.Traits;
|
||||
using OpenRA.Traits.Activities;
|
||||
|
||||
namespace OpenRA.Mods.RA
|
||||
{
|
||||
class SpyPlanePowerInfo : SupportPowerInfo
|
||||
{
|
||||
public readonly float RevealTime = .1f; // minutes
|
||||
public override object Create(ActorInitializer init) { return new SpyPlanePower(init.self,this); }
|
||||
}
|
||||
|
||||
class SpyPlanePower : SupportPower, IResolveOrder
|
||||
{
|
||||
public SpyPlanePower(Actor self, SpyPlanePowerInfo info) : base(self, info) { }
|
||||
|
||||
protected override void OnFinishCharging() { Sound.PlayToPlayer(Owner, "spypln1.aud"); }
|
||||
protected override void OnActivate()
|
||||
{
|
||||
Game.controller.orderGenerator = new GenericSelectTarget(Owner.PlayerActor, "SpyPlane", "ability");
|
||||
Sound.Play("slcttgt1.aud");
|
||||
}
|
||||
|
||||
public void ResolveOrder(Actor self, Order order)
|
||||
{
|
||||
if (!IsAvailable) return;
|
||||
|
||||
if (order.OrderString == "SpyPlane")
|
||||
{
|
||||
FinishActivate();
|
||||
|
||||
if (order.Player == Owner.World.LocalPlayer)
|
||||
Game.controller.CancelInputMode();
|
||||
|
||||
var enterCell = self.World.ChooseRandomEdgeCell();
|
||||
|
||||
var plane = self.World.CreateActor("U2", enterCell, self.Owner);
|
||||
plane.traits.Get<Unit>().Altitude = plane.Info.Traits.Get<PlaneInfo>().CruiseAltitude;
|
||||
plane.traits.Get<Unit>().Facing = Util.GetFacing(order.TargetLocation - enterCell, 0);
|
||||
|
||||
plane.CancelActivity();
|
||||
plane.QueueActivity(new Fly(Util.CenterOfCell(order.TargetLocation)));
|
||||
plane.QueueActivity(new CallFunc(() => plane.World.AddFrameEndTask( w =>
|
||||
{
|
||||
var camera = w.CreateActor("camera", order.TargetLocation, Owner);
|
||||
camera.QueueActivity(new Wait((int)(25 * 60 * (Info as SpyPlanePowerInfo).RevealTime)));
|
||||
camera.QueueActivity(new RemoveSelf());
|
||||
})));
|
||||
plane.QueueActivity(new FlyOffMap { Interruptible = false });
|
||||
plane.QueueActivity(new RemoveSelf());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user