add support for damage cooldown on SelfHealing
This commit is contained in:
@@ -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; }
|
||||
@@ -38,11 +39,23 @@ namespace OpenRA.Mods.RA
|
||||
if (health.HP >= Info.HealIfBelow*health.MaxHP)
|
||||
return;
|
||||
|
||||
if (damageTicks > 0)
|
||||
{
|
||||
--damageTicks;
|
||||
return;
|
||||
}
|
||||
|
||||
if (--ticks <= 0)
|
||||
{
|
||||
ticks = Info.Ticks;
|
||||
self.InflictDamage(self, -Info.Step, null);
|
||||
}
|
||||
}
|
||||
|
||||
public void Damaged (Actor self, AttackInfo e)
|
||||
{
|
||||
if (e.Damage > 0)
|
||||
damageTicks = Info.DamageCooldown;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user