Implement enter behaviour for Infiltrates plus other cleanups.
This commit is contained in:
@@ -18,19 +18,17 @@ namespace OpenRA.Mods.RA.Activities
|
||||
class Infiltrate : Enter
|
||||
{
|
||||
readonly Actor target;
|
||||
|
||||
readonly Stance validStances;
|
||||
readonly Cloak cloak;
|
||||
readonly string notification;
|
||||
|
||||
readonly Infiltrates infiltrates;
|
||||
|
||||
public Infiltrate(Actor self, Actor target)
|
||||
: base(self, target, EnterBehaviour.Dispose)
|
||||
public Infiltrate(Actor self, Actor target, EnterBehaviour enterBehaviour, Stance validStances, string notification)
|
||||
: base(self, target, enterBehaviour)
|
||||
{
|
||||
this.target = target;
|
||||
|
||||
this.validStances = validStances;
|
||||
this.notification = notification;
|
||||
cloak = self.TraitOrDefault<Cloak>();
|
||||
|
||||
infiltrates = self.TraitOrDefault<Infiltrates>();
|
||||
}
|
||||
|
||||
protected override void OnInside(Actor self)
|
||||
@@ -39,7 +37,7 @@ namespace OpenRA.Mods.RA.Activities
|
||||
return;
|
||||
|
||||
var stance = self.Owner.Stances[target.Owner];
|
||||
if (!infiltrates.Info.ValidStances.HasStance(stance))
|
||||
if (!validStances.HasStance(stance))
|
||||
return;
|
||||
|
||||
if (cloak != null && cloak.Info.UncloakOnInfiltrate)
|
||||
@@ -48,10 +46,9 @@ namespace OpenRA.Mods.RA.Activities
|
||||
foreach (var t in target.TraitsImplementing<INotifyInfiltrated>())
|
||||
t.Infiltrated(target, self);
|
||||
|
||||
self.Dispose();
|
||||
|
||||
if (target.Info.HasTraitInfo<BuildingInfo>())
|
||||
Game.Sound.PlayToPlayer(self.Owner, "bldginf1.aud");
|
||||
if (!string.IsNullOrEmpty(notification))
|
||||
Game.Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Speech",
|
||||
notification, self.Owner.Faction.InternalName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user