fix problem with cnc nuke leaking the long idle sequence Tick
and avoid magic numbers
This commit is contained in:
@@ -23,9 +23,12 @@ namespace OpenRA.Graphics
|
|||||||
|
|
||||||
int frame = 0;
|
int frame = 0;
|
||||||
bool backwards = false;
|
bool backwards = false;
|
||||||
bool tickAlways;
|
|
||||||
string name;
|
string name;
|
||||||
|
|
||||||
|
readonly int defaultTick = 40; // 25 fps == 40 ms
|
||||||
|
bool tickAlways;
|
||||||
|
|
||||||
public string Name { get { return name; } }
|
public string Name { get { return name; } }
|
||||||
|
|
||||||
readonly SequenceProvider sequenceProvider;
|
readonly SequenceProvider sequenceProvider;
|
||||||
@@ -66,6 +69,12 @@ namespace OpenRA.Graphics
|
|||||||
return Render(pos, WVec.Zero, 0, palette, 1f);
|
return Render(pos, WVec.Zero, 0, palette, 1f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void Initialize(string sequenceName)
|
||||||
|
{
|
||||||
|
CurrentSequence = sequenceProvider.GetSequence(name, sequenceName);
|
||||||
|
tickAlways = true;
|
||||||
|
}
|
||||||
|
|
||||||
public void Play(string sequenceName)
|
public void Play(string sequenceName)
|
||||||
{
|
{
|
||||||
PlayThen(sequenceName, null);
|
PlayThen(sequenceName, null);
|
||||||
@@ -149,7 +158,7 @@ namespace OpenRA.Graphics
|
|||||||
while (timeUntilNextFrame <= 0)
|
while (timeUntilNextFrame <= 0)
|
||||||
{
|
{
|
||||||
tickFunc();
|
tickFunc();
|
||||||
timeUntilNextFrame += CurrentSequence != null ? CurrentSequence.Tick : 40; // 25 fps == 40 ms
|
timeUntilNextFrame += CurrentSequence != null ? CurrentSequence.Tick : defaultTick;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,7 +49,8 @@ namespace OpenRA.Mods.RA.Render
|
|||||||
this.info = info;
|
this.info = info;
|
||||||
skipMakeAnimation = init.Contains<SkipMakeAnimsInit>();
|
skipMakeAnimation = init.Contains<SkipMakeAnimsInit>();
|
||||||
|
|
||||||
DefaultAnimation.PlayRepeating(NormalizeSequence(self, "idle"));
|
DefaultAnimation.Initialize(NormalizeSequence(self, "idle"));
|
||||||
|
|
||||||
self.Trait<IBodyOrientation>().SetAutodetectedFacings(DefaultAnimation.CurrentSequence.Facings);
|
self.Trait<IBodyOrientation>().SetAutodetectedFacings(DefaultAnimation.CurrentSequence.Facings);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -71,6 +72,8 @@ namespace OpenRA.Mods.RA.Render
|
|||||||
|
|
||||||
public virtual void BuildingComplete(Actor self)
|
public virtual void BuildingComplete(Actor self)
|
||||||
{
|
{
|
||||||
|
DefaultAnimation.PlayRepeating(NormalizeSequence(self, "idle"));
|
||||||
|
|
||||||
if (info.PauseOnLowPower)
|
if (info.PauseOnLowPower)
|
||||||
{
|
{
|
||||||
var disabled = self.TraitsImplementing<IDisable>();
|
var disabled = self.TraitsImplementing<IDisable>();
|
||||||
|
|||||||
Reference in New Issue
Block a user