Add experimental RA procedural map generator
Add an experimental procedural map generator for the Red Alert mod, along with supporting code that may assist in the development of map generators for other mods. Map generation may be accessed as a tool in the Map Editor. This change does not presently introduce direct lobby options for generated maps. Features: - Terrain with land, water, beaches, cliffs, roads, debris, and trees. - Placement of mpspawns, neutral buildings, and resources. - Rotational and mirror symmetry options. - Various configurable parameters with presets. - Deterministic with configurable seed. - Performant.
This commit is contained in:
@@ -15,6 +15,7 @@ using OpenRA.Activities;
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Mods.Common.Activities;
|
||||
using OpenRA.Mods.Common.Graphics;
|
||||
using OpenRA.Mods.Common.MapGenerator;
|
||||
using OpenRA.Mods.Common.Terrain;
|
||||
using OpenRA.Mods.Common.Widgets;
|
||||
using OpenRA.Primitives;
|
||||
@@ -959,4 +960,40 @@ namespace OpenRA.Mods.Common.Traits
|
||||
/// </remarks>
|
||||
bool PathMightExistForLocomotorBlockedByImmovable(Locomotor locomotor, CPos source, CPos target);
|
||||
}
|
||||
|
||||
public class MapGenerationException : Exception
|
||||
{
|
||||
public MapGenerationException(string message)
|
||||
: base(message) { }
|
||||
public MapGenerationException(string message, Exception inner)
|
||||
: base(message, inner) { }
|
||||
}
|
||||
|
||||
public interface IMapGeneratorInfo : ITraitInfoInterface
|
||||
{
|
||||
string Type { get; }
|
||||
string Name { get; }
|
||||
}
|
||||
|
||||
public interface IMapGenerator
|
||||
{
|
||||
/// <summary>
|
||||
/// Get the generator settings available for this map.
|
||||
/// Returns null if not compatible with the given map.
|
||||
/// </summary>
|
||||
MapGeneratorSettings GetSettings(Map map);
|
||||
|
||||
/// <summary>
|
||||
/// Generate or manipulate a supplied map in-place.
|
||||
/// </summary>
|
||||
/// <exception cref="YamlException">
|
||||
/// May be thrown if the map settings are invalid. Map should be discarded.
|
||||
/// </exception>
|
||||
/// <exception cref="MapGenerationException">
|
||||
/// Thrown if the map could not be generated with the requested configuration. Map should be discarded.
|
||||
/// </exception>
|
||||
void Generate(Map map, MiniYaml settings);
|
||||
|
||||
IMapGeneratorInfo Info { get; }
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user