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

@@ -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