Add support for disabling IIssueDeployOrders.
This commit is contained in:
@@ -129,6 +129,8 @@ namespace OpenRA.Mods.Cnc.Traits
|
|||||||
return new Order("Detonate", self, false);
|
return new Order("Detonate", self, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool IIssueDeployOrder.CanIssueDeployOrder(Actor self) { return true; }
|
||||||
|
|
||||||
string IOrderVoice.VoicePhraseForOrder(Actor self, Order order)
|
string IOrderVoice.VoicePhraseForOrder(Actor self, Order order)
|
||||||
{
|
{
|
||||||
return info.Voice;
|
return info.Voice;
|
||||||
|
|||||||
@@ -86,6 +86,8 @@ namespace OpenRA.Mods.Cnc.Traits
|
|||||||
return new Order("PlaceMine", self, Target.FromCell(self.World, self.Location), false);
|
return new Order("PlaceMine", self, Target.FromCell(self.World, self.Location), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool IIssueDeployOrder.CanIssueDeployOrder(Actor self) { return true; }
|
||||||
|
|
||||||
void IResolveOrder.ResolveOrder(Actor self, Order order)
|
void IResolveOrder.ResolveOrder(Actor self, Order order)
|
||||||
{
|
{
|
||||||
if (order.OrderString == "BeginMinefield")
|
if (order.OrderString == "BeginMinefield")
|
||||||
|
|||||||
@@ -669,6 +669,8 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
return new Order("ReturnToBase", self, false);
|
return new Order("ReturnToBase", self, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool IIssueDeployOrder.CanIssueDeployOrder(Actor self) { return Info.RearmBuildings.Any(); }
|
||||||
|
|
||||||
public string VoicePhraseForOrder(Actor self, Order order)
|
public string VoicePhraseForOrder(Actor self, Order order)
|
||||||
{
|
{
|
||||||
if (!Info.MoveIntoShroud && !self.Owner.Shroud.IsExplored(order.TargetLocation))
|
if (!Info.MoveIntoShroud && !self.Owner.Shroud.IsExplored(order.TargetLocation))
|
||||||
|
|||||||
@@ -58,6 +58,8 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
return new Order("Detonate", self, false);
|
return new Order("Detonate", self, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool IIssueDeployOrder.CanIssueDeployOrder(Actor self) { return true; }
|
||||||
|
|
||||||
public string VoicePhraseForOrder(Actor self, Order order)
|
public string VoicePhraseForOrder(Actor self, Order order)
|
||||||
{
|
{
|
||||||
return info.Voice;
|
return info.Voice;
|
||||||
|
|||||||
@@ -178,6 +178,8 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
return new Order("Unload", self, false);
|
return new Order("Unload", self, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool IIssueDeployOrder.CanIssueDeployOrder(Actor self) { return true; }
|
||||||
|
|
||||||
public void ResolveOrder(Actor self, Order order)
|
public void ResolveOrder(Actor self, Order order)
|
||||||
{
|
{
|
||||||
if (order.OrderString == "Unload")
|
if (order.OrderString == "Unload")
|
||||||
|
|||||||
@@ -138,6 +138,8 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
return new Order("GrantConditionOnDeploy", self, false);
|
return new Order("GrantConditionOnDeploy", self, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool IIssueDeployOrder.CanIssueDeployOrder(Actor self) { return true; }
|
||||||
|
|
||||||
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)
|
||||||
|
|||||||
@@ -105,6 +105,8 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
return new Order("DeployTransform", self, false);
|
return new Order("DeployTransform", self, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool IIssueDeployOrder.CanIssueDeployOrder(Actor self) { return !IsTraitPaused && !IsTraitDisabled; }
|
||||||
|
|
||||||
public void DeployTransform(bool queued)
|
public void DeployTransform(bool queued)
|
||||||
{
|
{
|
||||||
if (!queued && !CanDeploy())
|
if (!queued && !CanDeploy())
|
||||||
|
|||||||
@@ -323,6 +323,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
public interface IIssueDeployOrder
|
public interface IIssueDeployOrder
|
||||||
{
|
{
|
||||||
Order IssueDeployOrder(Actor self);
|
Order IssueDeployOrder(Actor self);
|
||||||
|
bool CanIssueDeployOrder(Actor self);
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum ActorPreviewType { PlaceBuilding, ColorPicker, MapEditorSidebar }
|
public enum ActorPreviewType { PlaceBuilding, ColorPicker, MapEditorSidebar }
|
||||||
|
|||||||
@@ -155,7 +155,7 @@ namespace OpenRA.Mods.Common.Widgets
|
|||||||
{
|
{
|
||||||
BindButtonIcon(deployButton);
|
BindButtonIcon(deployButton);
|
||||||
|
|
||||||
deployButton.IsDisabled = () => { UpdateStateIfNecessary(); return !selectedDeploys.Any(pair => pair.Trait.IsTraitEnabled()); };
|
deployButton.IsDisabled = () => { UpdateStateIfNecessary(); return !selectedDeploys.Any(pair => pair.Trait.CanIssueDeployOrder(pair.Actor)); };
|
||||||
deployButton.IsHighlighted = () => deployHighlighted > 0;
|
deployButton.IsHighlighted = () => deployHighlighted > 0;
|
||||||
deployButton.OnClick = () =>
|
deployButton.OnClick = () =>
|
||||||
{
|
{
|
||||||
@@ -307,7 +307,7 @@ namespace OpenRA.Mods.Common.Widgets
|
|||||||
UpdateStateIfNecessary();
|
UpdateStateIfNecessary();
|
||||||
|
|
||||||
var orders = selectedDeploys
|
var orders = selectedDeploys
|
||||||
.Where(pair => pair.Trait.IsTraitEnabled())
|
.Where(pair => pair.Trait.CanIssueDeployOrder(pair.Actor))
|
||||||
.Select(d => d.Trait.IssueDeployOrder(d.Actor))
|
.Select(d => d.Trait.IssueDeployOrder(d.Actor))
|
||||||
.Where(d => d != null)
|
.Where(d => d != null)
|
||||||
.ToArray();
|
.ToArray();
|
||||||
|
|||||||
Reference in New Issue
Block a user