Refactor ExperimentalMapGenerator into reusable methods
This change lifts large portions of ExperimentalMapGenerator's logic into a new "Terraformer" class with highly documented methods that can theoretically be used by alternative map generator classes. Some additional refactoring may occur in future, subject to the practical needs of additional map generators. ClearMapGenerator is also simplified. This is not a pure refactor and contains some algorithmic and behavioral changes, as well as few minor bug fixes. Notably: - The logic for obstructing unreachable water has been somewhat replaced. - In CnC, where water is already unplayable, EMG no longer obstructs water. (RA still does, as water is playable there.) - Mountain (cliff) generation is now somewhat more effective. This increases the number of cliffs seen on many presets. Settings should no longer use "Mountains: 1000". - PlayableSpace logic has been consolidated into Terraformer. - PlayableSpace.Playability no longer exists as PartiallyPlayable became redundant. Its uses have been replaced with a simple boolean. Consequently, some defunct code and configuration has been removed. - Adjust MultiBrush replaceability contract painting behavior to be more intuitive. - Fix off-by-one error in map bounds computation. - Fix some usages of mixed up MersenneTwisters.
This commit is contained in:
committed by
Gustas Kažukauskas
parent
e4f289921c
commit
25571df2b6
@@ -20,9 +20,24 @@ namespace OpenRA.Mods.Common.MapGenerator
|
||||
const int Scale = 1024;
|
||||
const int ScaledSqrt2 = 1448;
|
||||
|
||||
/// <summary>Amplitude is the same for all wavelengths.</summary>
|
||||
public static int WhiteAmplitude(int wavelength) => 1;
|
||||
|
||||
/// <summary>Amplitude proportional to wavelength.</summary>
|
||||
public static int PinkAmplitude(int wavelength) => wavelength;
|
||||
|
||||
/// <summary>
|
||||
/// <code>amplitude = wavelength ** (1 / (2 ** clumpiness))</code>
|
||||
/// Setting clumpiness to 0 is equivalent to pink noise.
|
||||
/// </summary>
|
||||
public static int ClumpinessAmplitude(int wavelength, int clumpiness)
|
||||
{
|
||||
var amplitude = wavelength;
|
||||
for (var i = 0; i < clumpiness; i++)
|
||||
amplitude = Exts.ISqrt(amplitude);
|
||||
return amplitude;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <para>
|
||||
/// Create noise by combining multiple layers of Perlin noise of halving wavelengths.
|
||||
|
||||
Reference in New Issue
Block a user