Make Cloak PausableConditional
If disabled now it CloakDelay resets to InitialCloakDelay when reenabled, if paused it continues with CloakDelay when resumed.
This commit is contained in:
committed by
Paul Chote
parent
a7279415dc
commit
dd92ec4d02
@@ -39,7 +39,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public class CloakType { }
|
||||
|
||||
[Desc("This unit can cloak and uncloak in specific situations.")]
|
||||
public class CloakInfo : ConditionalTraitInfo
|
||||
public class CloakInfo : PausableConditionalTraitInfo
|
||||
{
|
||||
[Desc("Measured in game ticks.")]
|
||||
public readonly int InitialDelay = 10;
|
||||
@@ -66,7 +66,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public override object Create(ActorInitializer init) { return new Cloak(this); }
|
||||
}
|
||||
|
||||
public class Cloak : ConditionalTrait<CloakInfo>, IRenderModifier, INotifyDamage, INotifyUnload, INotifyDemolition, INotifyInfiltration,
|
||||
public class Cloak : PausableConditionalTrait<CloakInfo>, IRenderModifier, INotifyDamage, INotifyUnload, INotifyDemolition, INotifyInfiltration,
|
||||
INotifyAttack, ITick, IVisibilityModifier, IRadarColorModifier, INotifyCreated, INotifyHarvesterAction
|
||||
{
|
||||
[Sync] int remainingTime;
|
||||
@@ -102,7 +102,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
base.Created(self);
|
||||
}
|
||||
|
||||
public bool Cloaked { get { return !IsTraitDisabled && remainingTime <= 0; } }
|
||||
public bool Cloaked { get { return !IsTraitDisabled && !IsTraitPaused && remainingTime <= 0; } }
|
||||
|
||||
public void Uncloak() { Uncloak(Info.CloakDelay); }
|
||||
|
||||
@@ -126,7 +126,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
IEnumerable<IRenderable> IRenderModifier.ModifyRender(Actor self, WorldRenderer wr, IEnumerable<IRenderable> r)
|
||||
{
|
||||
if (remainingTime > 0 || IsTraitDisabled)
|
||||
if (remainingTime > 0 || IsTraitDisabled || IsTraitPaused)
|
||||
return r;
|
||||
|
||||
if (Cloaked && IsVisible(self, self.World.RenderPlayer))
|
||||
@@ -148,7 +148,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
void ITick.Tick(Actor self)
|
||||
{
|
||||
if (!IsTraitDisabled)
|
||||
if (!IsTraitDisabled && !IsTraitPaused)
|
||||
{
|
||||
if (remainingTime > 0 && !isDocking)
|
||||
remainingTime--;
|
||||
@@ -183,6 +183,11 @@ namespace OpenRA.Mods.Common.Traits
|
||||
firstTick = false;
|
||||
}
|
||||
|
||||
protected override void TraitEnabled(Actor self)
|
||||
{
|
||||
remainingTime = Info.InitialDelay;
|
||||
}
|
||||
|
||||
protected override void TraitDisabled(Actor self) { Uncloak(); }
|
||||
|
||||
public bool IsVisible(Actor self, Player viewer)
|
||||
|
||||
Reference in New Issue
Block a user