Add explicit Reject field to RejectsOrders

This commit is contained in:
reaperrr
2017-03-18 18:12:02 +01:00
parent afc1f22c63
commit 225d26bfdb

View File

@@ -17,7 +17,10 @@ namespace OpenRA.Mods.Common.Traits
[Desc("Can be used to make a unit partly uncontrollable by the player.")]
public class RejectsOrdersInfo : ConditionalTraitInfo
{
[Desc("Possible values include Attack, AttackMove, Guard, Move.")]
[Desc("Explicit list of rejected orders. Leave empty to reject all minus those listed under Except.")]
public readonly HashSet<string> Reject = new HashSet<string>();
[Desc("List of orders that should *not* be rejected.")]
public readonly HashSet<string> Except = new HashSet<string>();
public override object Create(ActorInitializer init) { return new RejectsOrders(this); }
@@ -25,6 +28,7 @@ namespace OpenRA.Mods.Common.Traits
public class RejectsOrders : ConditionalTrait<RejectsOrdersInfo>
{
public HashSet<string> Reject { get { return Info.Reject; } }
public HashSet<string> Except { get { return Info.Except; } }
public RejectsOrders(RejectsOrdersInfo info)
@@ -36,7 +40,7 @@ namespace OpenRA.Mods.Common.Traits
public static bool AcceptsOrder(this Actor self, string orderString)
{
var r = self.TraitOrDefault<RejectsOrders>();
return r == null || r.IsTraitDisabled || r.Except.Contains(orderString);
return r == null || r.IsTraitDisabled || (r.Reject.Count > 0 && !r.Reject.Contains(orderString)) || r.Except.Contains(orderString);
}
}
}