Make RejectsOrders upgradable
This commit is contained in:
@@ -15,24 +15,20 @@ using OpenRA.Traits;
|
|||||||
namespace OpenRA.Mods.Common.Traits
|
namespace OpenRA.Mods.Common.Traits
|
||||||
{
|
{
|
||||||
[Desc("Can be used to make a unit partly uncontrollable by the player.")]
|
[Desc("Can be used to make a unit partly uncontrollable by the player.")]
|
||||||
public class RejectsOrdersInfo : ITraitInfo
|
public class RejectsOrdersInfo : UpgradableTraitInfo
|
||||||
{
|
{
|
||||||
[Desc("Possible values include Attack, AttackMove, Guard, Move.")]
|
[Desc("Possible values include Attack, AttackMove, Guard, Move.")]
|
||||||
public readonly HashSet<string> Except = new HashSet<string>();
|
public readonly HashSet<string> Except = new HashSet<string>();
|
||||||
|
|
||||||
public object Create(ActorInitializer init) { return new RejectsOrders(this); }
|
public override object Create(ActorInitializer init) { return new RejectsOrders(this); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class RejectsOrders
|
public class RejectsOrders : UpgradableTrait<RejectsOrdersInfo>
|
||||||
{
|
{
|
||||||
public HashSet<string> Except { get { return info.Except; } }
|
public HashSet<string> Except { get { return Info.Except; } }
|
||||||
|
|
||||||
readonly RejectsOrdersInfo info;
|
|
||||||
|
|
||||||
public RejectsOrders(RejectsOrdersInfo info)
|
public RejectsOrders(RejectsOrdersInfo info)
|
||||||
{
|
: base(info) { }
|
||||||
this.info = info;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class RejectsOrdersExts
|
public static class RejectsOrdersExts
|
||||||
@@ -40,7 +36,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
public static bool AcceptsOrder(this Actor self, string orderString)
|
public static bool AcceptsOrder(this Actor self, string orderString)
|
||||||
{
|
{
|
||||||
var r = self.TraitOrDefault<RejectsOrders>();
|
var r = self.TraitOrDefault<RejectsOrders>();
|
||||||
return r == null || r.Except.Contains(orderString);
|
return r == null || r.IsTraitDisabled || r.Except.Contains(orderString);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user