Support multiple capture traits in order targeter and script plumbing.

This commit is contained in:
Paul Chote
2018-11-02 22:35:23 +00:00
committed by abcdefg30
parent 346e670563
commit 3d6b170ec3
4 changed files with 25 additions and 37 deletions

View File

@@ -14,7 +14,8 @@ using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits
{
[Desc("This actor can be captured by a unit with Captures: trait.")]
[Desc("This actor can be captured by a unit with Captures: trait.",
"This trait should not be disabled if the actor also uses FrozenUnderFog.")]
public class CapturableInfo : ConditionalTraitInfo, Requires<CaptureManagerInfo>
{
[FieldLoader.Require]
@@ -27,22 +28,6 @@ namespace OpenRA.Mods.Common.Traits
public readonly bool CancelActivity = false;
public override object Create(ActorInitializer init) { return new Capturable(init.Self, this); }
public bool CanBeTargetedBy(Actor captor, Player owner)
{
var c = captor.Info.TraitInfoOrDefault<CapturesInfo>();
if (c == null)
return false;
var stance = owner.Stances[captor.Owner];
if (!ValidStances.HasStance(stance))
return false;
if (!c.CaptureTypes.Overlaps(Types))
return false;
return true;
}
}
public class Capturable : ConditionalTrait<CapturableInfo>, INotifyCapture
@@ -65,14 +50,6 @@ namespace OpenRA.Mods.Common.Traits
}
}
public bool CanBeTargetedBy(Actor captor, Player owner)
{
if (IsTraitDisabled)
return false;
return Info.CanBeTargetedBy(captor, owner);
}
protected override void TraitEnabled(Actor self) { captureManager.RefreshCapturable(self); }
protected override void TraitDisabled(Actor self) { captureManager.RefreshCapturable(self); }
}