Let cloaked units optionally uncloak when unloading
This commit is contained in:
@@ -22,6 +22,7 @@ namespace OpenRA.Mods.RA
|
||||
public readonly int InitialDelay = 10; // Ticks
|
||||
public readonly int CloakDelay = 30; // Ticks
|
||||
public readonly bool UncloakOnMove = false;
|
||||
public readonly bool UncloakOnUnload = false;
|
||||
public readonly bool RequiresCrate = false;
|
||||
|
||||
public readonly string CloakSound = null;
|
||||
@@ -38,24 +39,24 @@ namespace OpenRA.Mods.RA
|
||||
[Sync] bool crateDisabled;
|
||||
|
||||
Actor self;
|
||||
CloakInfo info;
|
||||
public readonly CloakInfo Info;
|
||||
CPos? lastPos;
|
||||
|
||||
public Cloak(Actor self, CloakInfo info)
|
||||
{
|
||||
this.info = info;
|
||||
this.self = self;
|
||||
Info = info;
|
||||
|
||||
remainingTime = info.InitialDelay;
|
||||
crateDisabled = info.RequiresCrate;
|
||||
}
|
||||
|
||||
public void Uncloak() { Uncloak(info.CloakDelay); }
|
||||
public void Uncloak() { Uncloak(Info.CloakDelay); }
|
||||
|
||||
public void Uncloak(int time)
|
||||
{
|
||||
if (Cloaked)
|
||||
Sound.Play(info.UncloakSound, self.CenterPosition);
|
||||
Sound.Play(Info.UncloakSound, self.CenterPosition);
|
||||
|
||||
remainingTime = Math.Max(remainingTime, time);
|
||||
}
|
||||
@@ -77,10 +78,10 @@ namespace OpenRA.Mods.RA
|
||||
return r;
|
||||
|
||||
if (Cloaked && IsVisible(self, self.World.RenderPlayer))
|
||||
if (string.IsNullOrEmpty(info.Palette))
|
||||
if (string.IsNullOrEmpty(Info.Palette))
|
||||
return r;
|
||||
else
|
||||
return r.Select(a => a.WithPalette(wr.Palette(info.Palette)));
|
||||
return r.Select(a => a.WithPalette(wr.Palette(Info.Palette)));
|
||||
else
|
||||
return SpriteRenderable.None;
|
||||
}
|
||||
@@ -90,13 +91,13 @@ namespace OpenRA.Mods.RA
|
||||
if (remainingTime > 0 && !crateDisabled && !damageDisabled && --remainingTime <= 0)
|
||||
{
|
||||
self.Generation++;
|
||||
Sound.Play(info.CloakSound, self.CenterPosition);
|
||||
Sound.Play(Info.CloakSound, self.CenterPosition);
|
||||
}
|
||||
|
||||
if (self.IsDisabled())
|
||||
Uncloak();
|
||||
|
||||
if (info.UncloakOnMove && (lastPos == null || lastPos.Value != self.Location))
|
||||
if (Info.UncloakOnMove && (lastPos == null || lastPos.Value != self.Location))
|
||||
{
|
||||
Uncloak();
|
||||
lastPos = self.Location;
|
||||
@@ -121,7 +122,7 @@ namespace OpenRA.Mods.RA
|
||||
return c;
|
||||
}
|
||||
|
||||
public bool AcceptsCloakCrate { get { return info.RequiresCrate && crateDisabled; } }
|
||||
public bool AcceptsCloakCrate { get { return Info.RequiresCrate && crateDisabled; } }
|
||||
|
||||
public void ReceivedCloakCrate(Actor self)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user