Support multiple capture traits in order targeter and script plumbing.
This commit is contained in:
@@ -40,6 +40,20 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public readonly bool PreventsAutoTarget = true;
|
||||
|
||||
public virtual object Create(ActorInitializer init) { return new CaptureManager(this); }
|
||||
|
||||
public bool CanBeTargetedBy(FrozenActor frozenActor, Actor captor, Captures captures)
|
||||
{
|
||||
if (captures.IsTraitDisabled)
|
||||
return false;
|
||||
|
||||
// TODO: FrozenActors don't yet have a way of caching conditions, so we can't filter disabled traits
|
||||
// This therefore assumes that all Capturable traits are enabled, which is probably wrong.
|
||||
// Actors with FrozenUnderFog should therefore not disable the Capturable trait.
|
||||
var stance = frozenActor.Owner.Stances[captor.Owner];
|
||||
return frozenActor.Info.TraitInfos<CapturableInfo>()
|
||||
.Any(c => c.ValidStances.HasStance(stance) &&
|
||||
captures.Info.CaptureTypes.Overlaps(c.Types));
|
||||
}
|
||||
}
|
||||
|
||||
public class CaptureManager : INotifyCreated, INotifyCapture, ITick, IPreventsAutoTarget
|
||||
|
||||
Reference in New Issue
Block a user