fix perf of HackyAI AssignRoles, to some extent

This commit is contained in:
Chris Forbes
2011-05-04 22:53:20 +12:00
parent 9b3e6c5c4a
commit 375eb90a88

View File

@@ -64,6 +64,9 @@ namespace OpenRA.Mods.RA
ret.Add(t.Key, (float)FieldLoader.GetValue("units", typeof(float), t.Value.Value));
return ret;
}
[FieldLoader.Load]
public readonly int AssignRolesInterval = 20;
public object Create(ActorInitializer init) { return new HackyAI(this); }
}
@@ -266,6 +269,8 @@ namespace OpenRA.Mods.RA
return possibleTargets.Any() ? possibleTargets.Random(random) : (int2?)null;
}
int assignRolesTicks = 0;
void AssignRolesToIdleUnits(Actor self)
{
@@ -274,6 +279,11 @@ namespace OpenRA.Mods.RA
activeUnits.RemoveAll(a => a.Destroyed);
unitsHangingAroundTheBase.RemoveAll(a => a.Destroyed);
attackForce.RemoveAll(a => a.Destroyed);
if (--assignRolesTicks > 0)
return;
else
assignRolesTicks = Info.AssignRolesInterval;
// don't select harvesters.
var newUnits = self.World.ActorsWithTrait<IMove>()