Minor FlyIdle perf optimization

None of these prerequisites change on the fly,
so cache the result in the activity ctor.
This commit is contained in:
reaperrr
2021-06-18 18:32:00 +02:00
committed by Paul Chote
parent 5ecb3eec16
commit 1262a9c6c9

View File

@@ -22,10 +22,12 @@ namespace OpenRA.Mods.Common.Activities
readonly INotifyIdle[] tickIdles;
readonly bool idleTurn;
int remainingTicks;
bool isIdleTurner;
public FlyIdle(Actor self, int ticks = -1, bool idleTurn = true)
{
aircraft = self.Trait<Aircraft>();
isIdleTurner = aircraft.Info.IdleSpeed > 0 || (!aircraft.Info.CanHover && aircraft.Info.IdleSpeed < 0);
remainingTicks = ticks;
this.idleTurn = idleTurn;
@@ -48,7 +50,7 @@ namespace OpenRA.Mods.Common.Activities
foreach (var tickIdle in tickIdles)
tickIdle.TickIdle(self);
if (aircraft.Info.IdleSpeed > 0 || (!aircraft.Info.CanHover && aircraft.Info.IdleSpeed < 0))
if (isIdleTurner)
{
var speed = aircraft.Info.IdleSpeed < 0 ? aircraft.Info.Speed : aircraft.Info.IdleSpeed;