Add plumbing for issuing orders against frozen actors.

This commit is contained in:
Paul Chote
2013-08-08 18:47:54 +12:00
parent 40a9caddc7
commit 3e605b1ee9
9 changed files with 92 additions and 41 deletions

View File

@@ -98,13 +98,12 @@ namespace OpenRA.Mods.RA
{
var canTargetActor = useCaptureCursor(target);
cursor = canTargetActor ? "ability" : "move-blocked";
return canTargetActor;
}
if (canTargetActor)
{
IsQueued = modifiers.HasModifier(TargetModifiers.ForceQueue);
return true;
}
public override bool CanTargetFrozenActor(Actor self, FrozenActor target, TargetModifiers modifiers, ref string cursor)
{
// TODO: Not yet supported
return false;
}
}

View File

@@ -65,13 +65,17 @@ namespace OpenRA.Mods.RA
if (self.Owner.Stances[target.Owner] != Stance.Ally)
return false;
IsQueued = modifiers.HasModifier(TargetModifiers.ForceQueue);
if (target.GetDamageState() == DamageState.Undamaged)
cursor = "goldwrench-blocked";
return true;
}
public override bool CanTargetFrozenActor(Actor self, FrozenActor target, TargetModifiers modifiers, ref string cursor)
{
// TODO: Not yet supported
return false;
}
}
}

View File

@@ -103,6 +103,12 @@ namespace OpenRA.Mods.RA
return true;
}
public override bool CanTargetFrozenActor(Actor self, FrozenActor target, TargetModifiers modifiers, ref string cursor)
{
// TODO: Not yet supported
return false;
}
}
}
}

View File

@@ -104,13 +104,18 @@ namespace OpenRA.Mods.RA
cursor = lowEnoughHealth ? "enter" : "capture";
IsQueued = modifiers.HasModifier(TargetModifiers.ForceQueue);
return true;
}
cursor = "enter-blocked";
return false;
}
public override bool CanTargetFrozenActor(Actor self, FrozenActor target, TargetModifiers modifiers, ref string cursor)
{
// TODO: Not yet supported
return false;
}
}
}
}

View File

@@ -29,15 +29,17 @@ namespace OpenRA.Mods.RA.Orders
public override bool CanTargetActor(Actor self, Actor target, TargetModifiers modifiers, ref string cursor)
{
if (!target.HasTrait<T>())
return false;
if (!canTarget(target))
if (!target.HasTrait<T>() || !canTarget(target))
return false;
cursor = useEnterCursor(target) ? "enter" : "enter-blocked";
IsQueued = modifiers.HasModifier(TargetModifiers.ForceQueue);
return true;
}
public override bool CanTargetFrozenActor(Actor self, FrozenActor target, TargetModifiers modifiers, ref string cursor)
{
// TODO: Not yet supported
return false;
}
}
}

View File

@@ -20,7 +20,7 @@ namespace OpenRA.Mods.RA.Orders
readonly string cursor;
readonly bool targetEnemyUnits, targetAllyUnits;
public UnitOrderTargeter( string order, int priority, string cursor, bool targetEnemyUnits, bool targetAllyUnits )
public UnitOrderTargeter(string order, int priority, string cursor, bool targetEnemyUnits, bool targetAllyUnits)
{
this.OrderID = order;
this.OrderPriority = priority;
@@ -34,23 +34,32 @@ namespace OpenRA.Mods.RA.Orders
public bool? ForceAttack = null;
public abstract bool CanTargetActor(Actor self, Actor target, TargetModifiers modifiers, ref string cursor);
public abstract bool CanTargetFrozenActor(Actor self, FrozenActor target, TargetModifiers modifiers, ref string cursor);
public bool CanTarget(Actor self, Target target, List<Actor> othersAtTarget, TargetModifiers modifiers, ref string cursor)
{
if (target.Type != TargetType.Actor)
var type = target.Type;
if (type != TargetType.Actor && type != TargetType.FrozenActor)
return false;
cursor = this.cursor;
IsQueued = modifiers.HasModifier(TargetModifiers.ForceQueue);
if (ForceAttack != null && modifiers.HasModifier(TargetModifiers.ForceAttack) != ForceAttack) return false;
if (ForceAttack != null && modifiers.HasModifier(TargetModifiers.ForceAttack) != ForceAttack)
return false;
var playerRelationship = self.Owner.Stances[target.Actor.Owner];
var owner = type == TargetType.FrozenActor ? target.FrozenActor.Owner : target.Actor.Owner;
var playerRelationship = self.Owner.Stances[owner];
if (!modifiers.HasModifier(TargetModifiers.ForceAttack) && playerRelationship == Stance.Ally && !targetAllyUnits) return false;
if (!modifiers.HasModifier(TargetModifiers.ForceAttack) && playerRelationship == Stance.Enemy && !targetEnemyUnits) return false;
if (!modifiers.HasModifier(TargetModifiers.ForceAttack) && playerRelationship == Stance.Ally && !targetAllyUnits)
return false;
return CanTargetActor(self, target.Actor, modifiers, ref cursor);
if (!modifiers.HasModifier(TargetModifiers.ForceAttack) && playerRelationship == Stance.Enemy && !targetEnemyUnits)
return false;
return type == TargetType.FrozenActor ?
CanTargetFrozenActor(self, target.FrozenActor, modifiers, ref cursor) :
CanTargetActor(self, target.Actor, modifiers, ref cursor);
}
public virtual bool IsQueued { get; protected set; }
@@ -68,12 +77,12 @@ namespace OpenRA.Mods.RA.Orders
public override bool CanTargetActor(Actor self, Actor target, TargetModifiers modifiers, ref string cursor)
{
if (!target.TraitsImplementing<ITargetable>().Any(t => t.TargetTypes.Contains(targetType)))
return false;
return target.TraitsImplementing<ITargetable>().Any(t => t.TargetTypes.Contains(targetType));
}
IsQueued = modifiers.HasModifier(TargetModifiers.ForceQueue);
return true;
public override bool CanTargetFrozenActor(Actor self, FrozenActor target, TargetModifiers modifiers, ref string cursor)
{
return target.Info.Traits.WithInterface<ITargetableInfo>().Any(t => t.GetTargetTypes().Contains(targetType));
}
}
}

View File

@@ -80,14 +80,18 @@ namespace OpenRA.Mods.RA
if (!modifiers.HasModifier(TargetModifiers.ForceAttack) && damage != DamageState.Dead)
return false;
IsQueued = modifiers.HasModifier(TargetModifiers.ForceQueue);
// Can't repair an undamaged bridge
if (damage == DamageState.Undamaged)
cursor = "goldwrench-blocked";
return true;
}
public override bool CanTargetFrozenActor(Actor self, FrozenActor target, TargetModifiers modifiers, ref string cursor)
{
// TODO: Bridges don't yet support FrozenUnderFog.
return false;
}
}
}
}

View File

@@ -72,14 +72,13 @@ namespace OpenRA.Mods.RA
public override bool CanTargetActor(Actor self, Actor target, TargetModifiers modifiers, ref string cursor)
{
if (target.AppearsHostileTo(self))
return false;
return target.HasTrait<AcceptsSupplies>();
}
if (!target.HasTrait<AcceptsSupplies>())
return false;
IsQueued = modifiers.HasModifier(TargetModifiers.ForceQueue);
return true;
public override bool CanTargetFrozenActor(Actor self, FrozenActor target, TargetModifiers modifiers, ref string cursor)
{
// TODO: Not yet supported
return false;
}
}
}