Rewrite Enter and related activities.
The unit will now path to the nearest adjacent cell, drag inside, do the inner activity, then (if still alive) drag back to its original location. This fixes: - Mismatch in logic between Enter and MoveAdjacentTo, which causes an infinite loop. - Building capturing failing from certain directions. - Being unable to enter buildings on unpathable tiles. - Units being stranded inside a building if the requirements for the inner order aren't met.
This commit is contained in:
@@ -15,22 +15,20 @@ namespace OpenRA.Mods.RA.Activities
|
||||
{
|
||||
class RepairBuilding : Activity
|
||||
{
|
||||
Actor target;
|
||||
Target target;
|
||||
|
||||
public RepairBuilding(Actor target) { this.target = target; }
|
||||
public RepairBuilding(Actor target) { this.target = Target.FromActor(target); }
|
||||
|
||||
public override Activity Tick(Actor self)
|
||||
{
|
||||
if (IsCanceled) return NextActivity;
|
||||
if (target == null || !target.IsInWorld || target.IsDead()) return NextActivity;
|
||||
if( !target.OccupiesSpace.OccupiedCells().Any( x => x.First == self.Location ) )
|
||||
if (IsCanceled || !target.IsValid)
|
||||
return NextActivity;
|
||||
|
||||
var health = target.Trait<Health>();
|
||||
var health = target.Actor.Trait<Health>();
|
||||
if (health.DamageState == DamageState.Undamaged)
|
||||
return NextActivity;
|
||||
|
||||
target.InflictDamage(self, -health.MaxHP, null);
|
||||
target.Actor.InflictDamage(self, -health.MaxHP, null);
|
||||
self.Destroy();
|
||||
|
||||
return this;
|
||||
|
||||
Reference in New Issue
Block a user