(External)Capturable are now conditional

This commit is contained in:
Forcecore
2017-10-21 16:34:24 +00:00
committed by Pavel Penev
parent a7620c97f0
commit c762453607
6 changed files with 58 additions and 18 deletions

View File

@@ -101,7 +101,7 @@ namespace OpenRA.Mods.Common.Traits
public override bool CanTargetActor(Actor self, Actor target, TargetModifiers modifiers, ref string cursor)
{
var c = target.Info.TraitInfoOrDefault<CapturableInfo>();
var c = target.TraitOrDefault<Capturable>();
if (c == null || !c.CanBeTargetedBy(self, target.Owner))
{
cursor = capturesInfo.EnterBlockedCursor;
@@ -109,15 +109,18 @@ namespace OpenRA.Mods.Common.Traits
}
var health = target.Trait<Health>();
var lowEnoughHealth = health.HP <= c.CaptureThreshold * health.MaxHP / 100;
var lowEnoughHealth = health.HP <= c.Info.CaptureThreshold * health.MaxHP / 100;
cursor = !capturesInfo.Sabotage || lowEnoughHealth || target.Owner.NonCombatant
? capturesInfo.EnterCursor : capturesInfo.SabotageCursor;
return true;
}
public override bool CanTargetFrozenActor(Actor self, FrozenActor target, TargetModifiers modifiers, ref string cursor)
{
// TODO: This doesn't account for disabled traits.
// Actors with FrozenUnderFog should not disable the Capturable trait.
var c = target.Info.TraitInfoOrDefault<CapturableInfo>();
if (c == null || !c.CanBeTargetedBy(self, target.Owner))
{