From 0a7c80ef6ef81334552df6c7e0204652ec1c136e Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Sun, 24 Apr 2016 15:35:37 +0100 Subject: [PATCH] Prepare short game code for trait-defined lobby options. --- OpenRA.Mods.Common/PlayerExtensions.cs | 3 ++- OpenRA.Mods.Common/Traits/World/MapOptions.cs | 10 +++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/OpenRA.Mods.Common/PlayerExtensions.cs b/OpenRA.Mods.Common/PlayerExtensions.cs index 5438879b60..f45386a330 100644 --- a/OpenRA.Mods.Common/PlayerExtensions.cs +++ b/OpenRA.Mods.Common/PlayerExtensions.cs @@ -18,7 +18,8 @@ namespace OpenRA.Mods.Common { public static bool HasNoRequiredUnits(this Player player) { - if (player.World.LobbyInfo.GlobalSettings.ShortGame) + var mapOptions = player.World.WorldActor.Trait(); + if (mapOptions.ShortGame) return !player.World.ActorsHavingTrait(t => t.Info.RequiredForShortGame).Any(a => a.Owner == player); return !player.World.ActorsHavingTrait().Any(a => a.Owner == player && a.IsInWorld); } diff --git a/OpenRA.Mods.Common/Traits/World/MapOptions.cs b/OpenRA.Mods.Common/Traits/World/MapOptions.cs index a86fc39046..51611e7108 100644 --- a/OpenRA.Mods.Common/Traits/World/MapOptions.cs +++ b/OpenRA.Mods.Common/Traits/World/MapOptions.cs @@ -39,5 +39,13 @@ namespace OpenRA.Mods.Common.Traits public readonly bool DifficultyLocked = false; } - public class MapOptions { } + public class MapOptions : INotifyCreated + { + public bool ShortGame { get; private set; } + + void INotifyCreated.Created(Actor self) + { + ShortGame = self.World.LobbyInfo.GlobalSettings.ShortGame; + } + } }