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:
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user