Add IIssueDeployOrder.

This commit is contained in:
Paul Chote
2017-06-03 15:46:31 +01:00
committed by Curtis Shmyr
parent 533b2f9ad7
commit e8d6d63707
6 changed files with 37 additions and 5 deletions

View File

@@ -116,7 +116,7 @@ namespace OpenRA.Mods.Common.Traits
} }
public class Aircraft : ITick, ISync, IFacing, IPositionable, IMove, IIssueOrder, IResolveOrder, IOrderVoice, IDeathActorInitModifier, public class Aircraft : ITick, ISync, IFacing, IPositionable, IMove, IIssueOrder, IResolveOrder, IOrderVoice, IDeathActorInitModifier,
INotifyCreated, INotifyAddedToWorld, INotifyRemovedFromWorld, INotifyActorDisposing, IActorPreviewInitModifier INotifyCreated, INotifyAddedToWorld, INotifyRemovedFromWorld, INotifyActorDisposing, IActorPreviewInitModifier, IIssueDeployOrder
{ {
static readonly Pair<CPos, SubCell>[] NoCells = { }; static readonly Pair<CPos, SubCell>[] NoCells = { };
@@ -564,6 +564,11 @@ namespace OpenRA.Mods.Common.Traits
return null; return null;
} }
Order IIssueDeployOrder.IssueDeployOrder(Actor self)
{
return new Order("ReturnToBase", self, false);
}
public string VoicePhraseForOrder(Actor self, Order order) public string VoicePhraseForOrder(Actor self, Order order)
{ {
switch (order.OrderString) switch (order.OrderString)

View File

@@ -25,7 +25,7 @@ namespace OpenRA.Mods.Common.Traits
public object Create(ActorInitializer init) { return new AttackSuicides(init.Self, this); } public object Create(ActorInitializer init) { return new AttackSuicides(init.Self, this); }
} }
class AttackSuicides : IIssueOrder, IResolveOrder, IOrderVoice class AttackSuicides : IIssueOrder, IResolveOrder, IOrderVoice, IIssueDeployOrder
{ {
readonly AttackSuicidesInfo info; readonly AttackSuicidesInfo info;
readonly IMove move; readonly IMove move;
@@ -56,6 +56,11 @@ namespace OpenRA.Mods.Common.Traits
return new Order(order.OrderID, self, queued) { TargetActor = target.Actor }; return new Order(order.OrderID, self, queued) { TargetActor = target.Actor };
} }
Order IIssueDeployOrder.IssueDeployOrder(Actor self)
{
return new Order("Detonate", self, false);
}
public string VoicePhraseForOrder(Actor self, Order order) public string VoicePhraseForOrder(Actor self, Order order)
{ {
return info.Voice; return info.Voice;

View File

@@ -75,7 +75,7 @@ namespace OpenRA.Mods.Common.Traits
} }
public class Cargo : IPips, IIssueOrder, IResolveOrder, IOrderVoice, INotifyCreated, INotifyKilled, public class Cargo : IPips, IIssueOrder, IResolveOrder, IOrderVoice, INotifyCreated, INotifyKilled,
INotifyOwnerChanged, INotifyAddedToWorld, ITick, INotifySold, INotifyActorDisposing INotifyOwnerChanged, INotifyAddedToWorld, ITick, INotifySold, INotifyActorDisposing, IIssueDeployOrder
{ {
public readonly CargoInfo Info; public readonly CargoInfo Info;
readonly Actor self; readonly Actor self;
@@ -160,6 +160,11 @@ namespace OpenRA.Mods.Common.Traits
return null; return null;
} }
Order IIssueDeployOrder.IssueDeployOrder(Actor self)
{
return new Order("Unload", self, false);
}
public void ResolveOrder(Actor self, Order order) public void ResolveOrder(Actor self, Order order)
{ {
if (order.OrderString == "Unload") if (order.OrderString == "Unload")

View File

@@ -60,7 +60,7 @@ namespace OpenRA.Mods.Common.Traits
public enum DeployState { Undeployed, Deploying, Deployed, Undeploying } public enum DeployState { Undeployed, Deploying, Deployed, Undeploying }
public class GrantConditionOnDeploy : IResolveOrder, IIssueOrder, INotifyCreated, INotifyDeployComplete public class GrantConditionOnDeploy : IResolveOrder, IIssueOrder, INotifyCreated, INotifyDeployComplete, IIssueDeployOrder
{ {
readonly Actor self; readonly Actor self;
readonly GrantConditionOnDeployInfo info; readonly GrantConditionOnDeployInfo info;
@@ -128,6 +128,11 @@ namespace OpenRA.Mods.Common.Traits
return null; return null;
} }
Order IIssueDeployOrder.IssueDeployOrder(Actor self)
{
return new Order("GrantConditionOnDeploy", self, false);
}
public void ResolveOrder(Actor self, Order order) public void ResolveOrder(Actor self, Order order)
{ {
if (order.OrderString != "GrantConditionOnDeploy" || deployState == DeployState.Deploying || deployState == DeployState.Undeploying) if (order.OrderString != "GrantConditionOnDeploy" || deployState == DeployState.Deploying || deployState == DeployState.Undeploying)

View File

@@ -51,7 +51,7 @@ namespace OpenRA.Mods.Common.Traits
public virtual object Create(ActorInitializer init) { return new Transforms(init, this); } public virtual object Create(ActorInitializer init) { return new Transforms(init, this); }
} }
public class Transforms : IIssueOrder, IResolveOrder, IOrderVoice public class Transforms : IIssueOrder, IResolveOrder, IOrderVoice, IIssueDeployOrder
{ {
readonly Actor self; readonly Actor self;
readonly TransformsInfo info; readonly TransformsInfo info;
@@ -94,6 +94,11 @@ namespace OpenRA.Mods.Common.Traits
return null; return null;
} }
Order IIssueDeployOrder.IssueDeployOrder(Actor self)
{
return new Order("DeployTransform", self, false);
}
public void DeployTransform(bool queued) public void DeployTransform(bool queued)
{ {
if (!queued && !CanDeploy()) if (!queued && !CanDeploy())

View File

@@ -283,4 +283,11 @@ namespace OpenRA.Mods.Common.Traits
byte GetTerrainIndex(CPos cell); byte GetTerrainIndex(CPos cell);
WPos CenterOfCell(CPos cell); WPos CenterOfCell(CPos cell);
} }
// For traits that want to be exposed to the "Deploy" UI button / hotkey
[RequireExplicitImplementation]
public interface IIssueDeployOrder
{
Order IssueDeployOrder(Actor self);
}
} }