fix #1105; decloak sound was never used
This commit is contained in:
@@ -28,13 +28,12 @@ namespace OpenRA.Mods.RA
|
|||||||
|
|
||||||
public class Cloak : IRenderModifier, INotifyDamageStateChanged, INotifyAttack, ITick, IVisibilityModifier, IRadarColorModifier, ISync
|
public class Cloak : IRenderModifier, INotifyDamageStateChanged, INotifyAttack, ITick, IVisibilityModifier, IRadarColorModifier, ISync
|
||||||
{
|
{
|
||||||
[Sync]
|
[Sync] int remainingTime;
|
||||||
int remainingTime;
|
[Sync] bool canCloak = true;
|
||||||
[Sync]
|
|
||||||
bool canCloak = true;
|
|
||||||
|
|
||||||
Actor self;
|
Actor self;
|
||||||
CloakInfo info;
|
CloakInfo info;
|
||||||
|
|
||||||
public Cloak(Actor self, CloakInfo info)
|
public Cloak(Actor self, CloakInfo info)
|
||||||
{
|
{
|
||||||
this.info = info;
|
this.info = info;
|
||||||
@@ -43,25 +42,29 @@ namespace OpenRA.Mods.RA
|
|||||||
remainingTime = info.InitialDelay;
|
remainingTime = info.InitialDelay;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DoUncloak()
|
public void Uncloak() { Uncloak(info.CloakDelay); }
|
||||||
{
|
|
||||||
if (remainingTime <= 0)
|
|
||||||
OnCloak();
|
|
||||||
|
|
||||||
remainingTime = Math.Max(remainingTime, info.CloakDelay);
|
public void Uncloak(int time)
|
||||||
|
{
|
||||||
|
if (Cloaked)
|
||||||
|
Sound.Play(info.UncloakSound, self.CenterLocation);
|
||||||
|
|
||||||
|
remainingTime = Math.Max(remainingTime, time);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Attacking(Actor self, Target target) { DoUncloak(); }
|
public void Attacking(Actor self, Target target) { Uncloak(); }
|
||||||
|
|
||||||
|
public bool Cloaked { get { return remainingTime <= 0; } }
|
||||||
|
|
||||||
public void DamageStateChanged(Actor self, AttackInfo e)
|
public void DamageStateChanged(Actor self, AttackInfo e)
|
||||||
{
|
{
|
||||||
canCloak = (e.DamageState < DamageState.Critical);
|
canCloak = (e.DamageState < DamageState.Critical);
|
||||||
if (Cloaked && !canCloak)
|
if (!canCloak) Uncloak();
|
||||||
DoUncloak();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static readonly Renderable[] Nothing = { };
|
static readonly Renderable[] Nothing = { };
|
||||||
public IEnumerable<Renderable>
|
|
||||||
ModifyRender(Actor self, IEnumerable<Renderable> rs)
|
public IEnumerable<Renderable> ModifyRender(Actor self, IEnumerable<Renderable> rs)
|
||||||
{
|
{
|
||||||
if (remainingTime > 0)
|
if (remainingTime > 0)
|
||||||
return rs;
|
return rs;
|
||||||
@@ -76,21 +79,9 @@ namespace OpenRA.Mods.RA
|
|||||||
{
|
{
|
||||||
if (remainingTime > 0 && canCloak)
|
if (remainingTime > 0 && canCloak)
|
||||||
if (--remainingTime <= 0)
|
if (--remainingTime <= 0)
|
||||||
OnCloak();
|
Sound.Play(info.CloakSound, self.CenterLocation);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnUncloak()
|
|
||||||
{
|
|
||||||
Sound.Play(info.UncloakSound, self.CenterLocation);
|
|
||||||
}
|
|
||||||
|
|
||||||
void OnCloak()
|
|
||||||
{
|
|
||||||
Sound.Play(info.CloakSound, self.CenterLocation);
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool Cloaked { get { return remainingTime == 0; } }
|
|
||||||
|
|
||||||
public bool IsVisible(Actor self)
|
public bool IsVisible(Actor self)
|
||||||
{
|
{
|
||||||
if (!Cloaked || self.Owner == self.World.LocalPlayer ||
|
if (!Cloaked || self.Owner == self.World.LocalPlayer ||
|
||||||
@@ -110,11 +101,5 @@ namespace OpenRA.Mods.RA
|
|||||||
c = Color.FromArgb(128, c);
|
c = Color.FromArgb(128, c);
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Decloak(int time)
|
|
||||||
{
|
|
||||||
DoUncloak();
|
|
||||||
remainingTime = Math.Max(remainingTime, time);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user