Add enter behaviour customisation to C4Demolition.

This commit is contained in:
Paul Chote
2015-11-23 21:23:30 +00:00
parent 3e8df55bcb
commit 6304d72f44
4 changed files with 19 additions and 5 deletions

View File

@@ -20,6 +20,7 @@ namespace OpenRA.Mods.Common.Activities
{ {
readonly Actor target; readonly Actor target;
readonly IDemolishable[] demolishables; readonly IDemolishable[] demolishables;
readonly EnterBehaviour enterBehaviour;
readonly int delay; readonly int delay;
readonly int flashes; readonly int flashes;
readonly int flashesDelay; readonly int flashesDelay;
@@ -28,11 +29,13 @@ namespace OpenRA.Mods.Common.Activities
readonly Cloak cloak; readonly Cloak cloak;
public Demolish(Actor self, Actor target, int delay, int flashes, int flashesDelay, int flashInterval, int flashDuration) public Demolish(Actor self, Actor target, EnterBehaviour enterBehaviour, int delay,
int flashes, int flashesDelay, int flashInterval, int flashDuration)
: base(self, target) : base(self, target)
{ {
this.target = target; this.target = target;
demolishables = target.TraitsImplementing<IDemolishable>().ToArray(); demolishables = target.TraitsImplementing<IDemolishable>().ToArray();
this.enterBehaviour = enterBehaviour;
this.delay = delay; this.delay = delay;
this.flashes = flashes; this.flashes = flashes;
this.flashesDelay = flashesDelay; this.flashesDelay = flashesDelay;
@@ -72,6 +75,11 @@ namespace OpenRA.Mods.Common.Activities
if (Util.ApplyPercentageModifiers(100, modifiers) > 0) if (Util.ApplyPercentageModifiers(100, modifiers) > 0)
demolishables.Do(d => d.Demolish(target, self)); demolishables.Do(d => d.Demolish(target, self));
})); }));
if (enterBehaviour == EnterBehaviour.Suicide)
self.Kill(self);
else if (enterBehaviour == EnterBehaviour.Dispose)
self.Dispose();
}); });
} }
} }

View File

@@ -15,6 +15,8 @@ using OpenRA.Traits;
namespace OpenRA.Mods.Common.Activities namespace OpenRA.Mods.Common.Activities
{ {
public enum EnterBehaviour { Exit, Suicide, Dispose }
public abstract class Enter : Activity public abstract class Enter : Activity
{ {
public enum ReserveStatus { None, TooFar, Pending, Ready } public enum ReserveStatus { None, TooFar, Pending, Ready }

View File

@@ -34,8 +34,8 @@ namespace OpenRA.Mods.Common.Scripting
[Desc("Demolish the target actor.")] [Desc("Demolish the target actor.")]
public void Demolish(Actor target) public void Demolish(Actor target)
{ {
Self.QueueActivity(new Demolish(Self, target, info.C4Delay, info.Flashes, Self.QueueActivity(new Demolish(Self, target, info.EnterBehaviour, info.C4Delay,
info.FlashesDelay, info.FlashInterval, info.FlashDuration)); info.Flashes, info.FlashesDelay, info.FlashInterval, info.FlashDuration));
} }
} }
} }

View File

@@ -35,6 +35,10 @@ namespace OpenRA.Mods.Common.Traits
[Desc("Duration of each flash")] [Desc("Duration of each flash")]
public readonly int FlashDuration = 3; public readonly int FlashDuration = 3;
[Desc("Behaviour when entering the structure.",
"Possible values are Exit, Suicide, Dispose.")]
public readonly EnterBehaviour EnterBehaviour = EnterBehaviour.Exit;
[Desc("Voice string when planting explosive charges.")] [Desc("Voice string when planting explosive charges.")]
[VoiceReference] public readonly string Voice = "Action"; [VoiceReference] public readonly string Voice = "Action";
@@ -83,8 +87,8 @@ namespace OpenRA.Mods.Common.Traits
self.CancelActivity(); self.CancelActivity();
self.SetTargetLine(target, Color.Red); self.SetTargetLine(target, Color.Red);
self.QueueActivity(new Demolish(self, self.QueueActivity(new Demolish(self, target.Actor, info.EnterBehaviour, info.C4Delay,
target.Actor, info.C4Delay, info.Flashes, info.FlashesDelay, info.FlashInterval, info.FlashDuration)); info.Flashes, info.FlashesDelay, info.FlashInterval, info.FlashDuration));
} }
public string VoicePhraseForOrder(Actor self, Order order) public string VoicePhraseForOrder(Actor self, Order order)