Cannot cloak if critical health
This commit is contained in:
@@ -37,10 +37,12 @@ namespace OpenRA.Mods.RA
|
|||||||
public object Create(ActorInitializer init) { return new Cloak(init.self, this); }
|
public object Create(ActorInitializer init) { return new Cloak(init.self, this); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class Cloak : IRenderModifier, INotifyAttack, ITick, INotifyDamage, IVisibilityModifier, IRadarColorModifier
|
public class Cloak : IRenderModifier, INotifyDamage, INotifyAttack, ITick, IVisibilityModifier, IRadarColorModifier
|
||||||
{
|
{
|
||||||
[Sync]
|
[Sync]
|
||||||
int remainingTime;
|
int remainingTime;
|
||||||
|
[Sync]
|
||||||
|
bool canCloak = true;
|
||||||
|
|
||||||
Actor self;
|
Actor self;
|
||||||
CloakInfo info;
|
CloakInfo info;
|
||||||
@@ -52,16 +54,21 @@ namespace OpenRA.Mods.RA
|
|||||||
remainingTime = (int)(info.InitialDelay * 25);
|
remainingTime = (int)(info.InitialDelay * 25);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DoSurface()
|
void DoUncloak()
|
||||||
{
|
{
|
||||||
if (remainingTime <= 0)
|
if (remainingTime <= 0)
|
||||||
OnSurface();
|
OnCloak();
|
||||||
|
|
||||||
remainingTime = Math.Max(remainingTime, (int)(info.CloakDelay * 25));
|
remainingTime = Math.Max(remainingTime, (int)(info.CloakDelay * 25));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Attacking(Actor self) { DoSurface(); }
|
public void Attacking(Actor self) { DoUncloak(); }
|
||||||
public void Damaged(Actor self, AttackInfo e) { DoSurface(); }
|
public void Damaged(Actor self, AttackInfo e)
|
||||||
|
{
|
||||||
|
canCloak = (e.DamageState < DamageState.Critical);
|
||||||
|
if (Cloaked && !canCloak)
|
||||||
|
DoUncloak();
|
||||||
|
}
|
||||||
|
|
||||||
public IEnumerable<Renderable>
|
public IEnumerable<Renderable>
|
||||||
ModifyRender(Actor self, IEnumerable<Renderable> rs)
|
ModifyRender(Actor self, IEnumerable<Renderable> rs)
|
||||||
@@ -77,17 +84,17 @@ namespace OpenRA.Mods.RA
|
|||||||
|
|
||||||
public void Tick(Actor self)
|
public void Tick(Actor self)
|
||||||
{
|
{
|
||||||
if (remainingTime > 0)
|
if (remainingTime > 0 && canCloak)
|
||||||
if (--remainingTime <= 0)
|
if (--remainingTime <= 0)
|
||||||
OnDive();
|
OnCloak();
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnSurface()
|
void OnUncloak()
|
||||||
{
|
{
|
||||||
Sound.Play(info.UncloakSound, self.CenterLocation);
|
Sound.Play(info.UncloakSound, self.CenterLocation);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnDive()
|
void OnCloak()
|
||||||
{
|
{
|
||||||
Sound.Play(info.CloakSound, self.CenterLocation);
|
Sound.Play(info.CloakSound, self.CenterLocation);
|
||||||
}
|
}
|
||||||
@@ -117,7 +124,7 @@ namespace OpenRA.Mods.RA
|
|||||||
|
|
||||||
public void Decloak(int time)
|
public void Decloak(int time)
|
||||||
{
|
{
|
||||||
DoSurface();
|
DoUncloak();
|
||||||
remainingTime = Math.Max(remainingTime, time);
|
remainingTime = Math.Max(remainingTime, time);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user