Remove Map requirement from IMapGeneratorInfo.GetSettings.
This commit is contained in:
committed by
Gustas Kažukauskas
parent
23b7b56c28
commit
e022744b0a
@@ -89,9 +89,9 @@ namespace OpenRA.Mods.Common.MapGenerator
|
||||
}
|
||||
|
||||
/// <summary>Check whether this choice is permitted for this map.</summary>
|
||||
public bool Allowed(Map map)
|
||||
public bool Allowed(ITerrainInfo terrainInfo)
|
||||
{
|
||||
if (Tileset != null && !Tileset.Contains(map.Tileset))
|
||||
if (Tileset != null && !Tileset.Contains(terrainInfo.Id))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
@@ -144,7 +144,7 @@ namespace OpenRA.Mods.Common.MapGenerator
|
||||
/// <summary>Settings layering priority. Higher overrides lower.</summary>
|
||||
public readonly int Priority = 0;
|
||||
|
||||
public Option(string id, MiniYaml my, Map map)
|
||||
public Option(string id, MiniYaml my, ITerrainInfo terrainInfo)
|
||||
{
|
||||
Id = id;
|
||||
FieldLoader.Load(this, my);
|
||||
@@ -214,7 +214,7 @@ namespace OpenRA.Mods.Common.MapGenerator
|
||||
if (split.Length >= 2)
|
||||
choiceId = split[1];
|
||||
var choice = new Choice(choiceId, node.Value);
|
||||
if (choice.Allowed(map))
|
||||
if (choice.Allowed(terrainInfo))
|
||||
choices.Add(choice);
|
||||
}
|
||||
}
|
||||
@@ -334,7 +334,7 @@ namespace OpenRA.Mods.Common.MapGenerator
|
||||
/// <summary>
|
||||
/// Parse settings from a MiniYaml definition. Returns null if the map isn't compatible.
|
||||
/// </summary>
|
||||
public static MapGeneratorSettings LoadSettings(MiniYaml my, Map map)
|
||||
public static MapGeneratorSettings LoadSettings(MiniYaml my, ITerrainInfo terrainInfo)
|
||||
{
|
||||
var options = new List<Option>();
|
||||
|
||||
@@ -346,7 +346,7 @@ namespace OpenRA.Mods.Common.MapGenerator
|
||||
string id = null;
|
||||
if (split.Length >= 2)
|
||||
id = split[1];
|
||||
var option = new Option(id, node.Value, map);
|
||||
var option = new Option(id, node.Value, terrainInfo);
|
||||
if (option.Choices.Count == 0)
|
||||
return null;
|
||||
options.Add(option);
|
||||
|
||||
@@ -54,9 +54,9 @@ namespace OpenRA.Mods.Common.Traits
|
||||
return MapGeneratorSettings.DumpFluent(my.NodeWithKey("Settings").Value);
|
||||
}
|
||||
|
||||
public MapGeneratorSettings GetSettings(Map map)
|
||||
public MapGeneratorSettings GetSettings(ITerrainInfo terrainInfo)
|
||||
{
|
||||
return MapGeneratorSettings.LoadSettings(Settings, map);
|
||||
return MapGeneratorSettings.LoadSettings(Settings, terrainInfo);
|
||||
}
|
||||
|
||||
public void Generate(Map map, MiniYaml settings)
|
||||
|
||||
@@ -481,9 +481,9 @@ namespace OpenRA.Mods.Common.Traits
|
||||
}
|
||||
}
|
||||
|
||||
public MapGeneratorSettings GetSettings(Map map)
|
||||
public MapGeneratorSettings GetSettings(ITerrainInfo terrainInfo)
|
||||
{
|
||||
return MapGeneratorSettings.LoadSettings(Settings, map);
|
||||
return MapGeneratorSettings.LoadSettings(Settings, terrainInfo);
|
||||
}
|
||||
|
||||
public void Generate(Map map, MiniYaml settings)
|
||||
|
||||
@@ -975,10 +975,10 @@ namespace OpenRA.Mods.Common.Traits
|
||||
string Name { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Get the generator settings available for this map.
|
||||
/// Returns null if not compatible with the given map.
|
||||
/// Get the generator settings available for this tileset.
|
||||
/// Returns null if not compatible with the given tileset.
|
||||
/// </summary>
|
||||
MapGeneratorSettings GetSettings(Map map);
|
||||
MapGeneratorSettings GetSettings(ITerrainInfo terrainInfo);
|
||||
|
||||
/// <summary>
|
||||
/// Generate or manipulate a supplied map in-place.
|
||||
|
||||
@@ -269,7 +269,7 @@ namespace OpenRA.Mods.Common.UtilityCommands
|
||||
var br = new PPos(size[0], size[1] + maxTerrainHeight);
|
||||
map.SetBounds(tl, br);
|
||||
|
||||
var settings = generator.GetSettings(map);
|
||||
var settings = generator.GetSettings(tileset);
|
||||
var choices = settings.DefaultChoices();
|
||||
foreach (var option in choices.Keys)
|
||||
if (iterationChoices.TryGetValue(option.Id, out var choice))
|
||||
|
||||
@@ -64,11 +64,13 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
generatorsToSettingsChoices = new Dictionary<IMapGeneratorInfo, Dictionary<MapGeneratorSettings.Option, MapGeneratorSettings.Choice>>();
|
||||
|
||||
var mapGenerators = new List<IMapGeneratorInfo>();
|
||||
var terrainInfo = modData.DefaultTerrainInfo[world.Map.Tileset];
|
||||
foreach (var generator in world.Map.Rules.Actors[SystemActors.EditorWorld].TraitInfos<IMapGeneratorInfo>())
|
||||
{
|
||||
var settings = generator.GetSettings(world.Map);
|
||||
var settings = generator.GetSettings(terrainInfo);
|
||||
if (settings == null)
|
||||
continue;
|
||||
|
||||
var choices = settings.DefaultChoices();
|
||||
mapGenerators.Add(generator);
|
||||
generatorsToSettingsChoices.Add(generator, choices);
|
||||
|
||||
Reference in New Issue
Block a user