add support for damage cooldown on SelfHealing

This commit is contained in:
Chris Forbes
2012-03-04 12:39:46 +13:00
parent 703d6648d7
commit f4b302e01a

View File

@@ -17,14 +17,15 @@ namespace OpenRA.Mods.RA
public readonly int Step = 5;
public readonly int Ticks = 5;
public readonly float HealIfBelow = .5f;
public readonly int DamageCooldown = 0;
public virtual object Create(ActorInitializer init) { return new SelfHealing(this); }
}
class SelfHealing : ITick, ISync
class SelfHealing : ITick, ISync, INotifyDamage
{
[Sync]
int ticks;
[Sync] int ticks;
[Sync] int damageTicks;
SelfHealingInfo Info;
public SelfHealing(SelfHealingInfo info) { Info = info; }
@@ -37,6 +38,12 @@ namespace OpenRA.Mods.RA
var health = self.Trait<Health>();
if (health.HP >= Info.HealIfBelow*health.MaxHP)
return;
if (damageTicks > 0)
{
--damageTicks;
return;
}
if (--ticks <= 0)
{
@@ -44,5 +51,11 @@ namespace OpenRA.Mods.RA
self.InflictDamage(self, -Info.Step, null);
}
}
public void Damaged (Actor self, AttackInfo e)
{
if (e.Damage > 0)
damageTicks = Info.DamageCooldown;
}
}
}