fix entering buildings from the east or south

This commit is contained in:
Bob
2010-10-22 10:20:34 +13:00
parent 88a8d84153
commit f933e3de3f
3 changed files with 32 additions and 24 deletions

View File

@@ -6,33 +6,34 @@
* as published by the Free Software Foundation. For more information,
* see LICENSE.
*/
#endregion
#endregion
using System.Linq;
using OpenRA.Traits;
namespace OpenRA.Mods.RA.Activities
{
class RepairBuilding : CancelableActivity
{
Target target;
Actor target;
public RepairBuilding(Actor target) { this.target = Target.FromActor(target); }
public RepairBuilding(Actor target) { this.target = target; }
public override IActivity Tick(Actor self)
{
if (IsCanceled) return NextActivity;
if (!target.IsValid) return NextActivity;
if ((target.Actor.Location - self.Location).Length > 1)
return NextActivity;
if (IsCanceled) return NextActivity;
if (target == null || !target.IsInWorld || target.IsDead()) return NextActivity;
if( !target.Trait<IOccupySpace>().OccupiedCells().Any( x => x == self.Location ) )
return NextActivity;
var health = target.Actor.Trait<Health>();
var health = target.Trait<Health>();
if (health.DamageState == DamageState.Undamaged)
return NextActivity;
target.Actor.InflictDamage(self, -health.MaxHP, null);
target.InflictDamage(self, -health.MaxHP, null);
self.Destroy();
return NextActivity;
return this;
}
}
}