Merge pull request #3687 from pchote/mapoptions

Lobby map option improvements.
This commit is contained in:
Matthias Mailänder
2013-08-17 02:42:23 -07:00
35 changed files with 749 additions and 162 deletions

View File

@@ -16,10 +16,42 @@ using System.Linq;
using System.Security.Cryptography;
using System.Text;
using OpenRA.FileFormats;
using OpenRA.Network;
using OpenRA.Traits;
namespace OpenRA
{
public class MapOptions
{
public bool? Cheats;
public bool? Crates;
public bool? Fog;
public bool? Shroud;
public bool? AllyBuildRadius;
public bool? FragileAlliances;
public int? StartingCash;
public bool ConfigurableStartingUnits = true;
public string[] Difficulties = { };
public void UpdateServerSettings(Session.Global settings)
{
if (Cheats.HasValue)
settings.AllowCheats = Cheats.Value;
if (Crates.HasValue)
settings.Crates = Crates.Value;
if (Fog.HasValue)
settings.Fog = Fog.Value;
if (Shroud.HasValue)
settings.Shroud = Shroud.Value;
if (AllyBuildRadius.HasValue)
settings.AllyBuildRadius = AllyBuildRadius.Value;
if (StartingCash.HasValue)
settings.StartingCash = StartingCash.Value;
if (FragileAlliances.HasValue)
settings.FragileAlliances = FragileAlliances.Value;
}
}
public class Map
{
[FieldLoader.Ignore] IFolder container;
@@ -37,9 +69,20 @@ namespace OpenRA
public string Description;
public string Author;
public string Tileset;
public string[] Difficulties;
public bool AllowStartUnitConfig = true;
[FieldLoader.LoadUsing("LoadOptions")]
public MapOptions Options;
static object LoadOptions(MiniYaml y)
{
var options = new MapOptions();
if (y.NodesDict.ContainsKey("Options"))
FieldLoader.Load(options, y.NodesDict["Options"]);
return options;
}
[FieldLoader.Ignore] public Lazy<Dictionary<string, ActorReference>> Actors;
public int PlayerCount { get { return Players.Count(p => p.Value.Playable); } }
@@ -177,7 +220,7 @@ namespace OpenRA
"Description",
"Author",
"Tileset",
"Difficulties",
"Options",
"MapSize",
"Bounds",
"UseAsShellmap",

View File

@@ -94,6 +94,8 @@ namespace OpenRA.Network
public bool Crates = true;
public bool Shroud = true;
public bool Fog = true;
public bool AllyBuildRadius = true;
public int StartingCash = 5000;
public string StartingUnitsClass = "none";
public bool AllowVersionMismatch;
}

View File

@@ -16,8 +16,8 @@ namespace OpenRA.Traits
{
public class PlayerResourcesInfo : ITraitInfo
{
public readonly int InitialCash = 10000;
public readonly int InitialOre = 0;
public readonly int[] SelectableCash = { 2500, 5000, 10000, 20000 };
public readonly int DefaultCash = 5000;
public readonly int AdviceInterval = 250;
public object Create(ActorInitializer init) { return new PlayerResources(init.self, this); }
@@ -34,8 +34,7 @@ namespace OpenRA.Traits
{
Owner = self.Owner;
Cash = info.InitialCash;
Ore = info.InitialOre;
Cash = self.World.LobbyInfo.GlobalSettings.StartingCash;
AdviceInterval = info.AdviceInterval;
}