Add smart deploy

This commit is contained in:
Gustas
2025-01-03 17:23:58 +02:00
committed by Matthias Mailänder
parent 288d839456
commit 7779d0c27c
5 changed files with 29 additions and 1 deletions

View File

@@ -37,6 +37,9 @@ namespace OpenRA.Mods.Common.Traits
[Desc("Can this actor deploy on slopes?")]
public readonly bool CanDeployOnRamps = false;
[Desc("Does this actor need to synchronize its deployment with other actors?")]
public readonly bool SmartDeploy = false;
[CursorReference]
[Desc("Cursor to display when able to (un)deploy the actor.")]
public readonly string DeployCursor = "deploy";
@@ -183,7 +186,26 @@ namespace OpenRA.Mods.Common.Traits
return new Order("GrantConditionOnDeploy", self, queued);
}
bool IIssueDeployOrder.CanIssueDeployOrder(Actor self, bool queued) { return !IsTraitPaused && !IsTraitDisabled; }
bool IIssueDeployOrder.CanIssueDeployOrder(Actor self, bool queued)
{
if (IsTraitPaused || IsTraitDisabled || self.IsDead || self.Disposed)
return false;
if (queued || !Info.SmartDeploy || DeployState == DeployState.Undeployed || DeployState == DeployState.Undeploying)
return true;
foreach (var actor in self.World.Selection.Actors)
{
if (actor == self || actor.IsDead || !actor.IsInWorld)
continue;
if (actor.TraitsImplementing<GrantConditionOnDeploy>()
.Any(d => !d.IsTraitPaused && !d.IsTraitDisabled && (d.DeployState == DeployState.Undeployed || d.DeployState == DeployState.Undeploying)))
return false;
}
return true;
}
public void ResolveOrder(Actor self, Order order)
{

View File

@@ -135,6 +135,7 @@ thumper:
UndeployOnMove: true
Facing: 512
AllowedTerrainTypes: Sand, Spice, Dune, SpiceSand
SmartDeploy: true
Encyclopedia:
Description: actor-thumper.encyclopedia
Order: 40

View File

@@ -371,6 +371,7 @@ JUGG:
DeploySounds: place2.aud
UndeploySounds: clicky1.aud
Voice: Move
SmartDeploy: true
EntersTunnels:
RequireForceMoveCondition: !undeployed
Repairable:

View File

@@ -140,6 +140,7 @@ TTNK:
DeploySounds: place2.aud
UndeploySounds: clicky1.aud
Voice: Move
SmartDeploy: true
EntersTunnels:
RequireForceMoveCondition: !undeployed
Repairable:
@@ -252,6 +253,7 @@ ART2:
DeploySounds: place2.aud
UndeploySounds: clicky1.aud
Voice: Move
SmartDeploy: true
EntersTunnels:
RequireForceMoveCondition: !undeployed
Repairable:
@@ -605,6 +607,7 @@ SGEN:
DeploySounds: place2.aud
UndeploySounds: clicky1.aud
Voice: Move
SmartDeploy: true
EntersTunnels:
RequireForceMoveCondition: !undeployed
Repairable:

View File

@@ -169,6 +169,7 @@ LPST:
DeploySounds: place2.aud
UndeploySounds: clicky1.aud
Voice: Move
SmartDeploy: true
EntersTunnels:
RequireForceMoveCondition: !undeployed
Repairable: