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:
@@ -19,8 +19,6 @@ using OpenRA.Traits;
|
|||||||
|
|
||||||
namespace OpenRA.Mods.Cnc.Activities
|
namespace OpenRA.Mods.Cnc.Activities
|
||||||
{
|
{
|
||||||
public interface IPreventsTeleport { bool PreventsTeleport(Actor self); }
|
|
||||||
|
|
||||||
public class Teleport : Activity
|
public class Teleport : Activity
|
||||||
{
|
{
|
||||||
readonly Actor teleporter;
|
readonly Actor teleporter;
|
||||||
@@ -50,10 +48,6 @@ namespace OpenRA.Mods.Cnc.Activities
|
|||||||
if (teleporter == self && pc != null && !pc.CanTeleport)
|
if (teleporter == self && pc != null && !pc.CanTeleport)
|
||||||
return NextActivity;
|
return NextActivity;
|
||||||
|
|
||||||
foreach (var condition in self.TraitsImplementing<IPreventsTeleport>())
|
|
||||||
if (condition.PreventsTeleport(self))
|
|
||||||
return NextActivity;
|
|
||||||
|
|
||||||
var bestCell = ChooseBestDestinationCell(self, destination);
|
var bestCell = ChooseBestDestinationCell(self, destination);
|
||||||
if (bestCell == null)
|
if (bestCell == null)
|
||||||
return NextActivity;
|
return NextActivity;
|
||||||
|
|||||||
@@ -50,6 +50,10 @@ namespace OpenRA.Mods.Cnc.Traits
|
|||||||
|
|
||||||
[VoiceReference] public readonly string Voice = "Action";
|
[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 ThumpDamageWeaponInfo { get; private set; }
|
||||||
public WeaponInfo DetonationWeaponInfo { 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 Actor self;
|
||||||
readonly MadTankInfo info;
|
readonly MadTankInfo info;
|
||||||
readonly WithFacingSpriteBody wfsb;
|
readonly WithFacingSpriteBody wfsb;
|
||||||
readonly ScreenShaker screenShaker;
|
readonly ScreenShaker screenShaker;
|
||||||
|
ConditionManager conditionManager;
|
||||||
bool deployed;
|
bool deployed;
|
||||||
int tick;
|
int tick;
|
||||||
|
|
||||||
@@ -92,6 +97,11 @@ namespace OpenRA.Mods.Cnc.Traits
|
|||||||
screenShaker = self.World.WorldActor.Trait<ScreenShaker>();
|
screenShaker = self.World.WorldActor.Trait<ScreenShaker>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void INotifyCreated.Created(Actor self)
|
||||||
|
{
|
||||||
|
conditionManager = self.TraitOrDefault<ConditionManager>();
|
||||||
|
}
|
||||||
|
|
||||||
void ITick.Tick(Actor self)
|
void ITick.Tick(Actor self)
|
||||||
{
|
{
|
||||||
if (!deployed)
|
if (!deployed)
|
||||||
@@ -172,6 +182,9 @@ namespace OpenRA.Mods.Cnc.Traits
|
|||||||
if (deployed)
|
if (deployed)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (conditionManager != null && !string.IsNullOrEmpty(info.DeployedCondition))
|
||||||
|
conditionManager.GrantCondition(self, info.DeployedCondition);
|
||||||
|
|
||||||
self.World.AddFrameEndTask(w => EjectDriver());
|
self.World.AddFrameEndTask(w => EjectDriver());
|
||||||
if (info.ThumpSequence != null)
|
if (info.ThumpSequence != null)
|
||||||
wfsb.PlayCustomAnimationRepeating(self, info.ThumpSequence);
|
wfsb.PlayCustomAnimationRepeating(self, info.ThumpSequence);
|
||||||
|
|||||||
@@ -87,8 +87,7 @@ namespace OpenRA.Mods.Cnc.Traits
|
|||||||
foreach (var t in tiles)
|
foreach (var t in tiles)
|
||||||
units.UnionWith(Self.World.ActorMap.GetActorsAt(t));
|
units.UnionWith(Self.World.ActorMap.GetActorsAt(t));
|
||||||
|
|
||||||
return units.Where(a => a.TraitsImplementing<Chronoshiftable>().Any(cs => !cs.IsTraitDisabled) &&
|
return units.Where(a => a.TraitsImplementing<Chronoshiftable>().Any(cs => !cs.IsTraitDisabled));
|
||||||
!a.TraitsImplementing<IPreventsTeleport>().Any(condition => condition.PreventsTeleport(a)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool SimilarTerrain(CPos xy, CPos sourceLocation)
|
public bool SimilarTerrain(CPos xy, CPos sourceLocation)
|
||||||
|
|||||||
@@ -769,7 +769,10 @@ QTNK:
|
|||||||
Armor:
|
Armor:
|
||||||
Type: Heavy
|
Type: Heavy
|
||||||
Mobile:
|
Mobile:
|
||||||
|
RequiresCondition: !deployed
|
||||||
Speed: 56
|
Speed: 56
|
||||||
|
Chronoshiftable:
|
||||||
|
RequiresCondition: !deployed
|
||||||
RevealsShroud:
|
RevealsShroud:
|
||||||
Range: 6c0
|
Range: 6c0
|
||||||
RevealGeneratedShroud: False
|
RevealGeneratedShroud: False
|
||||||
@@ -777,6 +780,7 @@ QTNK:
|
|||||||
Range: 4c0
|
Range: 4c0
|
||||||
SelectionDecorations:
|
SelectionDecorations:
|
||||||
MadTank:
|
MadTank:
|
||||||
|
DeployedCondition: deployed
|
||||||
Targetable:
|
Targetable:
|
||||||
TargetTypes: Ground, MADTank, Repair, Vehicle
|
TargetTypes: Ground, MADTank, Repair, Vehicle
|
||||||
Selectable:
|
Selectable:
|
||||||
|
|||||||
Reference in New Issue
Block a user