Make AttackSuicides coditional

This commit is contained in:
Mustafa Alperen Seki
2018-01-22 21:19:50 +03:00
committed by BadWolf
parent 9fa37bbb02
commit 065eb78afc

View File

@@ -18,21 +18,20 @@ using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits namespace OpenRA.Mods.Common.Traits
{ {
[Desc("Does a suicide attack where it moves next to the target when used in combination with `Explodes`.")] [Desc("Does a suicide attack where it moves next to the target when used in combination with `Explodes`.")]
class AttackSuicidesInfo : ITraitInfo, Requires<IMoveInfo> class AttackSuicidesInfo : ConditionalTraitInfo, Requires<IMoveInfo>
{ {
[VoiceReference] public readonly string Voice = "Action"; [VoiceReference] public readonly string Voice = "Action";
public object Create(ActorInitializer init) { return new AttackSuicides(init.Self, this); } public override object Create(ActorInitializer init) { return new AttackSuicides(init.Self, this); }
} }
class AttackSuicides : IIssueOrder, IResolveOrder, IOrderVoice, IIssueDeployOrder class AttackSuicides : ConditionalTrait<AttackSuicidesInfo>, IIssueOrder, IResolveOrder, IOrderVoice, IIssueDeployOrder
{ {
readonly AttackSuicidesInfo info;
readonly IMove move; readonly IMove move;
public AttackSuicides(Actor self, AttackSuicidesInfo info) public AttackSuicides(Actor self, AttackSuicidesInfo info)
: base(info)
{ {
this.info = info;
move = self.Trait<IMove>(); move = self.Trait<IMove>();
} }
@@ -40,6 +39,9 @@ namespace OpenRA.Mods.Common.Traits
{ {
get get
{ {
if (IsTraitDisabled)
yield break;
yield return new TargetTypeOrderTargeter(new HashSet<string> { "DetonateAttack" }, "DetonateAttack", 5, "attack", true, false) { ForceAttack = false }; yield return new TargetTypeOrderTargeter(new HashSet<string> { "DetonateAttack" }, "DetonateAttack", 5, "attack", true, false) { ForceAttack = false };
yield return new DeployOrderTargeter("Detonate", 5); yield return new DeployOrderTargeter("Detonate", 5);
} }
@@ -62,7 +64,7 @@ namespace OpenRA.Mods.Common.Traits
public string VoicePhraseForOrder(Actor self, Order order) public string VoicePhraseForOrder(Actor self, Order order)
{ {
return info.Voice; return Info.Voice;
} }
public void ResolveOrder(Actor self, Order order) public void ResolveOrder(Actor self, Order order)