Reduce allocations in the main game loop.
- Cache the shroud projection even for flat maps to avoid allocating single element arrays. - Avoid LINQ in shroud and map projection queries to avoid enumerator allocations. - Avoid LINQ in calculation of sync values. - Cache enumerables in ProductionQueue. - Cache delegate in HackyAI.
This commit is contained in:
@@ -58,7 +58,16 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public ReadOnlyList<MissionObjective> Objectives;
|
||||
|
||||
[Sync]
|
||||
public int ObjectivesHash { get { return Objectives.Aggregate(0, (code, objective) => code ^ Sync.Hash(objective.State)); } }
|
||||
public int ObjectivesHash
|
||||
{
|
||||
get
|
||||
{
|
||||
var hash = 0;
|
||||
foreach (var objective in objectives)
|
||||
hash ^= Sync.Hash(objective.State);
|
||||
return hash;
|
||||
}
|
||||
}
|
||||
|
||||
// This property is used as a flag in 'Cooperative' games to mark that the player has completed all his objectives.
|
||||
// The player's WinState is only updated when his allies have all completed their objective as well.
|
||||
|
||||
Reference in New Issue
Block a user