Game.IssueOrder wrapper for OM; moved some more features into mod
This commit is contained in:
@@ -15,7 +15,7 @@ namespace OpenRa
|
||||
public void Toggle()
|
||||
{
|
||||
if (isChatting && typing.Length > 0)
|
||||
Game.orderManager.IssueOrder(Order.Chat(typing));
|
||||
Game.IssueOrder(Order.Chat(typing));
|
||||
|
||||
typing = "";
|
||||
isChatting ^= true;
|
||||
|
||||
@@ -277,7 +277,7 @@ namespace OpenRa
|
||||
AddUiButton(new int2(r.Left + 200, r.Bottom - 40), "OK",
|
||||
_ =>
|
||||
{
|
||||
Game.orderManager.IssueOrder(Order.Chat("/map " + currentMap.Filename));
|
||||
Game.IssueOrder(Order.Chat("/map " + currentMap.Filename));
|
||||
showMapChooser = false;
|
||||
});
|
||||
|
||||
@@ -343,19 +343,19 @@ namespace OpenRa
|
||||
while (!PaletteAvailable(newpalette) && newpalette != (int)Game.world.LocalPlayer.Palette)
|
||||
newpalette = (newpalette + d) % 8;
|
||||
|
||||
Game.orderManager.IssueOrder(
|
||||
Game.IssueOrder(
|
||||
Order.Chat("/pal " + newpalette));
|
||||
}
|
||||
|
||||
void CycleRace(bool left)
|
||||
{
|
||||
Game.orderManager.IssueOrder(
|
||||
Game.IssueOrder(
|
||||
Order.Chat("/race " + (((int)Game.world.LocalPlayer.Race - 1) ^ 1)));
|
||||
}
|
||||
|
||||
void CycleReady(bool left)
|
||||
{
|
||||
Game.orderManager.IssueOrder(
|
||||
Game.IssueOrder(
|
||||
new Order("ToggleReady", Game.world.LocalPlayer.PlayerActor, "") { IsImmediate = true });
|
||||
}
|
||||
|
||||
@@ -580,7 +580,7 @@ namespace OpenRa
|
||||
{
|
||||
var queue = world.LocalPlayer.PlayerActor.traits.Get<Traits.ProductionQueue>();
|
||||
foreach( var item in queue.AllItems( groupName ) )
|
||||
Game.orderManager.IssueOrder(Order.CancelProduction(world.LocalPlayer, item.Item));
|
||||
Game.IssueOrder(Order.CancelProduction(world.LocalPlayer, item.Item));
|
||||
}
|
||||
|
||||
void ChooseAvailableTab( World world )
|
||||
@@ -958,7 +958,7 @@ namespace OpenRa
|
||||
{
|
||||
var unit = Rules.Info[item];
|
||||
Sound.Play(unit.Traits.Contains<BuildingInfo>() ? "abldgin1.aud" : "train1.aud");
|
||||
Game.orderManager.IssueOrder(Order.StartProduction(world.LocalPlayer, item));
|
||||
Game.IssueOrder(Order.StartProduction(world.LocalPlayer, item));
|
||||
}
|
||||
|
||||
void HandleBuildPalette( World world, string item, bool isLmb )
|
||||
@@ -983,7 +983,7 @@ namespace OpenRa
|
||||
|
||||
if (producing.Paused)
|
||||
{
|
||||
Game.orderManager.IssueOrder(Order.PauseProduction(player, item, false));
|
||||
Game.IssueOrder(Order.PauseProduction(player, item, false));
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -998,12 +998,12 @@ namespace OpenRa
|
||||
if (producing.Paused || producing.Done || producing.TotalCost == producing.RemainingCost)
|
||||
{
|
||||
Sound.Play("cancld1.aud");
|
||||
Game.orderManager.IssueOrder(Order.CancelProduction(player, item));
|
||||
Game.IssueOrder(Order.CancelProduction(player, item));
|
||||
}
|
||||
else
|
||||
{
|
||||
Sound.Play("onhold1.aud");
|
||||
Game.orderManager.IssueOrder(Order.PauseProduction(player, item, true));
|
||||
Game.IssueOrder(Order.PauseProduction(player, item, true));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -210,6 +210,8 @@ namespace OpenRa
|
||||
changePending = true;
|
||||
}
|
||||
|
||||
public static void IssueOrder(Order o) { orderManager.IssueOrder(o); } /* avoid exposing the OM to mod code */
|
||||
|
||||
public static void StartGame()
|
||||
{
|
||||
var available = world.Map.SpawnPoints.ToList();
|
||||
|
||||
@@ -226,8 +226,6 @@
|
||||
<Compile Include="Traits\NukePower.cs" />
|
||||
<Compile Include="Traits\Passenger.cs" />
|
||||
<Compile Include="Traits\PlaceBuilding.cs" />
|
||||
<Compile Include="Traits\SonarPulsePower.cs" />
|
||||
<Compile Include="Traits\SpyPlanePower.cs" />
|
||||
<Compile Include="Traits\SupportPower.cs" />
|
||||
<Compile Include="Traits\ProvidesRadar.cs" />
|
||||
<Compile Include="Traits\Repairable.cs" />
|
||||
|
||||
@@ -67,7 +67,7 @@ namespace OpenRa
|
||||
|
||||
Game.chat.AddLine(Color.White, "Debug", "Requesting package: {0}".F(currentPackage));
|
||||
|
||||
Game.orderManager.IssueOrder(
|
||||
Game.IssueOrder(
|
||||
new Order("RequestFile", null, currentPackage) { IsImmediate = true });
|
||||
|
||||
Fraction = 0f;
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using OpenRa.Orders;
|
||||
|
||||
namespace OpenRa.Traits
|
||||
{
|
||||
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.orderManager.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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,68 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using OpenRa.Traits.Activities;
|
||||
|
||||
namespace OpenRa.Traits
|
||||
{
|
||||
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