Remove IPreventsTeleport interface.

MadTank is changed to use conditions instead.
This has a side-benefit of disabling the move
cursor while deployed.
This commit is contained in:
Paul Chote
2018-08-12 21:30:41 +01:00
parent e6d552eee7
commit 6f864b055d
4 changed files with 19 additions and 9 deletions

View File

@@ -19,8 +19,6 @@ using OpenRA.Traits;
namespace OpenRA.Mods.Cnc.Activities
{
public interface IPreventsTeleport { bool PreventsTeleport(Actor self); }
public class Teleport : Activity
{
readonly Actor teleporter;
@@ -50,10 +48,6 @@ namespace OpenRA.Mods.Cnc.Activities
if (teleporter == self && pc != null && !pc.CanTeleport)
return NextActivity;
foreach (var condition in self.TraitsImplementing<IPreventsTeleport>())
if (condition.PreventsTeleport(self))
return NextActivity;
var bestCell = ChooseBestDestinationCell(self, destination);
if (bestCell == null)
return NextActivity;

View File

@@ -50,6 +50,10 @@ namespace OpenRA.Mods.Cnc.Traits
[VoiceReference] public readonly string Voice = "Action";
[GrantedConditionReference]
[Desc("The condition to grant to self while deployed.")]
public readonly string DeployedCondition = null;
public WeaponInfo ThumpDamageWeaponInfo { get; private set; }
public WeaponInfo DetonationWeaponInfo { get; private set; }
@@ -75,12 +79,13 @@ namespace OpenRA.Mods.Cnc.Traits
}
}
class MadTank : IIssueOrder, IResolveOrder, IOrderVoice, ITick, IPreventsTeleport, IIssueDeployOrder
class MadTank : INotifyCreated, IIssueOrder, IResolveOrder, IOrderVoice, ITick, IIssueDeployOrder
{
readonly Actor self;
readonly MadTankInfo info;
readonly WithFacingSpriteBody wfsb;
readonly ScreenShaker screenShaker;
ConditionManager conditionManager;
bool deployed;
int tick;
@@ -92,6 +97,11 @@ namespace OpenRA.Mods.Cnc.Traits
screenShaker = self.World.WorldActor.Trait<ScreenShaker>();
}
void INotifyCreated.Created(Actor self)
{
conditionManager = self.TraitOrDefault<ConditionManager>();
}
void ITick.Tick(Actor self)
{
if (!deployed)
@@ -172,6 +182,9 @@ namespace OpenRA.Mods.Cnc.Traits
if (deployed)
return;
if (conditionManager != null && !string.IsNullOrEmpty(info.DeployedCondition))
conditionManager.GrantCondition(self, info.DeployedCondition);
self.World.AddFrameEndTask(w => EjectDriver());
if (info.ThumpSequence != null)
wfsb.PlayCustomAnimationRepeating(self, info.ThumpSequence);

View File

@@ -87,8 +87,7 @@ namespace OpenRA.Mods.Cnc.Traits
foreach (var t in tiles)
units.UnionWith(Self.World.ActorMap.GetActorsAt(t));
return units.Where(a => a.TraitsImplementing<Chronoshiftable>().Any(cs => !cs.IsTraitDisabled) &&
!a.TraitsImplementing<IPreventsTeleport>().Any(condition => condition.PreventsTeleport(a)));
return units.Where(a => a.TraitsImplementing<Chronoshiftable>().Any(cs => !cs.IsTraitDisabled));
}
public bool SimilarTerrain(CPos xy, CPos sourceLocation)

View File

@@ -769,7 +769,10 @@ QTNK:
Armor:
Type: Heavy
Mobile:
RequiresCondition: !deployed
Speed: 56
Chronoshiftable:
RequiresCondition: !deployed
RevealsShroud:
Range: 6c0
RevealGeneratedShroud: False
@@ -777,6 +780,7 @@ QTNK:
Range: 4c0
SelectionDecorations:
MadTank:
DeployedCondition: deployed
Targetable:
TargetTypes: Ground, MADTank, Repair, Vehicle
Selectable: