Move EnterBehaviour behaviour to Enter.
This commit is contained in:
@@ -22,7 +22,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
readonly Health health;
|
||||
|
||||
public CaptureActor(Actor self, Actor target)
|
||||
: base(self, target)
|
||||
: base(self, target, EnterBehaviour.Dispose)
|
||||
{
|
||||
actor = target;
|
||||
building = actor.TraitOrDefault<Building>();
|
||||
|
||||
@@ -20,7 +20,6 @@ namespace OpenRA.Mods.Common.Activities
|
||||
{
|
||||
readonly Actor target;
|
||||
readonly IDemolishable[] demolishables;
|
||||
readonly EnterBehaviour enterBehaviour;
|
||||
readonly int delay;
|
||||
readonly int flashes;
|
||||
readonly int flashesDelay;
|
||||
@@ -31,11 +30,10 @@ namespace OpenRA.Mods.Common.Activities
|
||||
|
||||
public Demolish(Actor self, Actor target, EnterBehaviour enterBehaviour, int delay,
|
||||
int flashes, int flashesDelay, int flashInterval, int flashDuration)
|
||||
: base(self, target)
|
||||
: base(self, target, enterBehaviour)
|
||||
{
|
||||
this.target = target;
|
||||
demolishables = target.TraitsImplementing<IDemolishable>().ToArray();
|
||||
this.enterBehaviour = enterBehaviour;
|
||||
this.delay = delay;
|
||||
this.flashes = flashes;
|
||||
this.flashesDelay = flashesDelay;
|
||||
@@ -75,11 +73,6 @@ namespace OpenRA.Mods.Common.Activities
|
||||
if (Util.ApplyPercentageModifiers(100, modifiers) > 0)
|
||||
demolishables.Do(d => d.Demolish(target, self));
|
||||
}));
|
||||
|
||||
if (enterBehaviour == EnterBehaviour.Suicide)
|
||||
self.Kill(self);
|
||||
else if (enterBehaviour == EnterBehaviour.Dispose)
|
||||
self.Dispose();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
readonly int payload;
|
||||
|
||||
public DonateSupplies(Actor self, Actor target, int payload)
|
||||
: base(self, target)
|
||||
: base(self, target, EnterBehaviour.Dispose)
|
||||
{
|
||||
this.target = target;
|
||||
this.payload = payload;
|
||||
@@ -31,7 +31,6 @@ namespace OpenRA.Mods.Common.Activities
|
||||
return;
|
||||
|
||||
target.Owner.PlayerActor.Trait<PlayerResources>().GiveCash(payload);
|
||||
self.Dispose();
|
||||
|
||||
if (self.Owner.IsAlliedWith(self.World.RenderPlayer))
|
||||
self.World.AddFrameEndTask(w => w.Add(new FloatingText(target.CenterPosition, target.Owner.Color.RGB, FloatingText.FormatCashTick(payload), 30)));
|
||||
|
||||
@@ -24,7 +24,9 @@ namespace OpenRA.Mods.Common.Activities
|
||||
|
||||
readonly IMove move;
|
||||
readonly int maxTries = 0;
|
||||
readonly EnterBehaviour enterBehaviour;
|
||||
readonly bool targetCenter;
|
||||
|
||||
public Target Target { get { return target; } }
|
||||
Target target;
|
||||
State nextState = State.ApproachingOrEntering; // Hint/starting point for next state
|
||||
@@ -33,11 +35,12 @@ namespace OpenRA.Mods.Common.Activities
|
||||
Activity inner;
|
||||
bool firstApproach = true;
|
||||
|
||||
protected Enter(Actor self, Actor target, int maxTries = 1, bool targetCenter = false)
|
||||
protected Enter(Actor self, Actor target, EnterBehaviour enterBehaviour, int maxTries = 1, bool targetCenter = false)
|
||||
{
|
||||
this.move = self.Trait<IMove>();
|
||||
this.target = Target.FromActor(target);
|
||||
this.maxTries = maxTries;
|
||||
this.enterBehaviour = enterBehaviour;
|
||||
this.targetCenter = targetCenter;
|
||||
}
|
||||
|
||||
@@ -215,6 +218,11 @@ namespace OpenRA.Mods.Common.Activities
|
||||
|
||||
OnInside(self);
|
||||
|
||||
if (enterBehaviour == EnterBehaviour.Suicide)
|
||||
self.Kill(self);
|
||||
else if (enterBehaviour == EnterBehaviour.Dispose)
|
||||
self.Dispose();
|
||||
|
||||
// Return if Abort(Actor) or Done(self) was called from OnInside.
|
||||
if (nextState >= State.Exiting)
|
||||
return State.Inside;
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
Cargo cargo;
|
||||
|
||||
public EnterTransport(Actor self, Actor transport, int maxTries = 0, bool targetCenter = false)
|
||||
: base(self, transport, maxTries, targetCenter)
|
||||
: base(self, transport, EnterBehaviour.Exit, maxTries, targetCenter)
|
||||
{
|
||||
this.transport = transport;
|
||||
this.maxTries = maxTries;
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
readonly BridgeHut hut;
|
||||
|
||||
public RepairBridge(Actor self, Actor target)
|
||||
: base(self, target)
|
||||
: base(self, target, EnterBehaviour.Dispose)
|
||||
{
|
||||
hut = target.Trait<BridgeHut>();
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
readonly Health health;
|
||||
|
||||
public RepairBuilding(Actor self, Actor target)
|
||||
: base(self, target)
|
||||
: base(self, target, EnterBehaviour.Dispose)
|
||||
{
|
||||
this.target = target;
|
||||
health = target.Trait<Health>();
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace OpenRA.Mods.RA.Activities
|
||||
readonly Infiltrates infiltrates;
|
||||
|
||||
public Infiltrate(Actor self, Actor target)
|
||||
: base(self, target)
|
||||
: base(self, target, EnterBehaviour.Dispose)
|
||||
{
|
||||
this.target = target;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user