From ad24a7023536f18f8b95d88f97547328cb441a26 Mon Sep 17 00:00:00 2001 From: atlimit8 Date: Sat, 4 Oct 2014 19:31:35 -0500 Subject: [PATCH] Infiltrate as Enter subclass --- OpenRA.Mods.RA/Activities/Infiltrate.cs | 26 ++++++++++++---------- OpenRA.Mods.RA/Infiltration/Infiltrates.cs | 2 +- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/OpenRA.Mods.RA/Activities/Infiltrate.cs b/OpenRA.Mods.RA/Activities/Infiltrate.cs index 9a6b88f921..f2636f67d4 100644 --- a/OpenRA.Mods.RA/Activities/Infiltrate.cs +++ b/OpenRA.Mods.RA/Activities/Infiltrate.cs @@ -13,25 +13,27 @@ using OpenRA.Traits; namespace OpenRA.Mods.RA.Activities { - class Infiltrate : Activity + class Infiltrate : Enter { - Target target; - public Infiltrate(Actor target) { this.target = Target.FromActor(target); } - - public override Activity Tick(Actor self) + readonly Actor target; + public Infiltrate(Actor self, Actor target) + : base(self, target) { - if (IsCanceled || target.Type != TargetType.Actor || target.Actor.Owner == self.Owner) - return NextActivity; + this.target = target; + } - foreach (var t in target.Actor.TraitsImplementing()) - t.Infiltrated(target.Actor, self); + protected override void OnInside(Actor self) + { + if (target.IsDead() || target.Owner == self.Owner) + return; + + foreach (var t in target.TraitsImplementing()) + t.Infiltrated(target, self); self.Destroy(); - if (target.Actor.HasTrait()) + if (target.HasTrait()) Sound.PlayToPlayer(self.Owner, "bldginf1.aud"); - - return this; } } } diff --git a/OpenRA.Mods.RA/Infiltration/Infiltrates.cs b/OpenRA.Mods.RA/Infiltration/Infiltrates.cs index 78d4b97ee1..4c8d5e8504 100644 --- a/OpenRA.Mods.RA/Infiltration/Infiltrates.cs +++ b/OpenRA.Mods.RA/Infiltration/Infiltrates.cs @@ -96,7 +96,7 @@ namespace OpenRA.Mods.RA.Infiltration self.CancelActivity(); self.SetTargetLine(target, Color.Red); - self.QueueActivity(new Enter(self, target.Actor, new Infiltrate(target.Actor))); + self.QueueActivity(new Infiltrate(self, target.Actor)); } } }