Support multiple capture traits in order targeter and script plumbing.
This commit is contained in:
@@ -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); }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user