Game.IssueOrder wrapper for OM; moved some more features into mod
This commit is contained in:
@@ -66,7 +66,9 @@
|
||||
<Compile Include="RenderSpy.cs" />
|
||||
<Compile Include="RepairableNear.cs" />
|
||||
<Compile Include="Crate Actions\SpeedUpgrade.cs" />
|
||||
<Compile Include="SonarPulsePower.cs" />
|
||||
<Compile Include="Spy.cs" />
|
||||
<Compile Include="SpyPlanePower.cs" />
|
||||
<Compile Include="Thief.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
||||
34
OpenRa.Mods.RA/SonarPulsePower.cs
Normal file
34
OpenRa.Mods.RA/SonarPulsePower.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
using OpenRa.Traits;
|
||||
|
||||
namespace OpenRa.Mods.RA
|
||||
{
|
||||
public class SonarPulsePowerInfo : SupportPowerInfo
|
||||
{
|
||||
public override object Create(Actor self) { return new SonarPulsePower(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 (order.OrderString == "SonarPulse")
|
||||
{
|
||||
// TODO: Reveal submarines
|
||||
|
||||
// Should this play for all players?
|
||||
Sound.Play("sonpulse.aud");
|
||||
FinishActivate();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
66
OpenRa.Mods.RA/SpyPlanePower.cs
Normal file
66
OpenRa.Mods.RA/SpyPlanePower.cs
Normal file
@@ -0,0 +1,66 @@
|
||||
using System.Collections.Generic;
|
||||
using OpenRa.Traits;
|
||||
using OpenRa.Traits.Activities;
|
||||
|
||||
namespace OpenRa.Mods.RA
|
||||
{
|
||||
class SpyPlanePowerInfo : SupportPowerInfo
|
||||
{
|
||||
public readonly int Range = 10;
|
||||
public override object Create(Actor self) { return new SpyPlanePower(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 SelectTarget();
|
||||
Sound.Play("slcttgt1.aud");
|
||||
}
|
||||
|
||||
public void ResolveOrder(Actor self, Order order)
|
||||
{
|
||||
if (order.OrderString == "SpyPlane")
|
||||
{
|
||||
FinishActivate();
|
||||
|
||||
if (order.Player == Owner.World.LocalPlayer)
|
||||
Game.controller.CancelInputMode();
|
||||
|
||||
var enterCell = self.World.ChooseRandomEdgeCell();
|
||||
var exitCell = self.World.ChooseRandomEdgeCell();
|
||||
|
||||
var plane = self.World.CreateActor("U2", enterCell, self.Owner);
|
||||
plane.CancelActivity();
|
||||
plane.QueueActivity(new Fly(Util.CenterOfCell(order.TargetLocation)));
|
||||
plane.QueueActivity(new CallFunc(
|
||||
() => Owner.Shroud.Explore(Owner.World, order.TargetLocation,
|
||||
(Info as SpyPlanePowerInfo).Range)));
|
||||
plane.QueueActivity(new Fly(Util.CenterOfCell(exitCell)));
|
||||
plane.QueueActivity(new RemoveSelf());
|
||||
}
|
||||
}
|
||||
|
||||
class SelectTarget : IOrderGenerator
|
||||
{
|
||||
public IEnumerable<Order> Order(World world, int2 xy, MouseInput mi)
|
||||
{
|
||||
if (mi.Button == MouseButton.Right)
|
||||
{
|
||||
Game.controller.CancelInputMode();
|
||||
yield break;
|
||||
}
|
||||
|
||||
yield return new Order("SpyPlane", world.LocalPlayer.PlayerActor, xy);
|
||||
}
|
||||
|
||||
public void Tick(World world) {}
|
||||
public void Render(World world) {}
|
||||
|
||||
public Cursor GetCursor(World world, int2 xy, MouseInput mi) { return Cursor.Ability; }
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user