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