Cache map option ShortGame at game load

To reduce MapOptions calls.
This commit is contained in:
reaperrr
2018-03-16 21:59:27 +01:00
committed by Paul Chote
parent 0555ce9321
commit f351f0346f
4 changed files with 11 additions and 6 deletions

View File

@@ -16,10 +16,9 @@ namespace OpenRA.Mods.Common
{
public static class PlayerExtensions
{
public static bool HasNoRequiredUnits(this Player player)
public static bool HasNoRequiredUnits(this Player player, bool shortGame)
{
var mapOptions = player.World.WorldActor.Trait<MapOptions>();
if (mapOptions.ShortGame)
if (shortGame)
return !player.World.ActorsHavingTrait<MustBeDestroyed>(t => t.Info.RequiredForShortGame).Any(a => a.Owner == player);
return !player.World.ActorsHavingTrait<MustBeDestroyed>().Any(a => a.Owner == player && a.IsInWorld);
}