RepairBuilding & RepairBridge as Enter subclasses

This commit is contained in:
atlimit8
2014-10-04 15:53:09 -05:00
parent 6d0feb9fbf
commit 41452dcfeb
4 changed files with 29 additions and 26 deletions

View File

@@ -12,25 +12,29 @@ using OpenRA.Traits;
namespace OpenRA.Mods.RA.Activities
{
class RepairBuilding : Activity
class RepairBuilding : Enter
{
Target target;
readonly Actor target;
readonly Health health;
public RepairBuilding(Actor target) { this.target = Target.FromActor(target); }
public override Activity Tick(Actor self)
public RepairBuilding(Actor self, Actor target)
: base(self, target)
{
if (IsCanceled || target.Type != TargetType.Actor)
return NextActivity;
this.target = target;
health = target.Trait<Health>();
}
var health = target.Actor.Trait<Health>();
protected override bool CanReserve(Actor self)
{
return health.DamageState != DamageState.Undamaged;
}
protected override void OnInside(Actor self)
{
if (health.DamageState == DamageState.Undamaged)
return NextActivity;
target.Actor.InflictDamage(self, -health.MaxHP, null);
return;
target.InflictDamage(self, -health.MaxHP, null);
self.Destroy();
return this;
}
}
}