diff --git a/README.md b/README.md index b3d9684..ed13b7c 100644 --- a/README.md +++ b/README.md @@ -29,119 +29,117 @@ npm i gen-biome . ## Generator -#### Create world generator +### Create world generator ```ts -const generator = new WorldGenerator(config) +new WorldGenerator(config: WorldConfig) ``` -* `config {` -* * `width` - Map width -* * `height` - Map height -* * `frequencyChange` - Frequency of biomes change -* * * _Default: 0.3, Min: 0.0, Max: 1.0_ -* * `borderSmoothness` - Smoothness of biomes borders -* * * _Default: 0.5, Min: 0.0, Max: 1.0_ -* * `heightRedistribution` - Redistribution of biomes height -* * * _Default: 1.0, Min: 0.5, Max: 1.5_ -* * `heightAveraging` - Averaging of biomes height -* * * _Default: true_ -* * `falloff` - Scale of falloff area -* * * _Default: 0.0_ -* `}` +[`config`] - _World config_ + +| Prop | Description | Default | Range | +| ---- | ----------- | ------- | ----- | +| width | Map width | | | +| height | Map height | | | +| frequencyChange | Frequency of biomes change | 0.3 | 0.0 - 1.0 | +| borderSmoothness | Smoothness of biomes borders | 0.5 | 0.0 - 1.0 | +| heightRedistribution | Redistribution of biomes height | 1.0 | 0.5 - 1.5 | +| heightAveraging | Averaging of biomes height | true | | +| falloff | Scale of falloff area | 0.0 | | . ## Biomes -#### Add biome to layer +### Add biome ```ts -for (const { params, data } of ...) { - const biome: WorldBiome = generator.addBiome(params, data) -} +generator.addBiome( + config: WorldBiomeConfig, + data: T, +): WorldBiome ``` -* `params {` -* * `lowerBound` - Lower biome bound -* * * _Default: 0.0_ -* * `upperBound` - Upper biome bound -* * * _Default: 1.0_ -* `}` -* `data` - Data of biome - -#### Get layer biomes +[`config`] - _Biome config_ + +| Prop | Description | Default | +| ---- | ----------- | ------- | +| lowerBound | Lower biome bound | 0.0 | +| upperBound | Upper biome bound | 1.0 | + +[`data`] - _Biome data that will be stored in the world matrix_ + +### Get current biomes ```ts -const biomes: WorldBiome[] = layer.getBiomes() +generator.getBiomes(): WorldBiome[] ``` -#### Clear all layer biomes +### Clear all biomes ```ts -layer.clearBiomes() +generator.clearBiomes() ``` . ## Generation -#### Generate world +### Generate world ```ts -const world: World = generator.generate(params?) +generator.generate( + params?: WorldGenerationParams, +): World ``` -* `params {` -* * `seed` - Generation seed -* * * _Default: Autogenerate_ -* * `seedSize` - Size of seed array -* * * _Default: 512_ -* * `offsetX` - Generation offset X -* * * _Default: 0_ -* * `offsetY` - Generation offset Y -* * * _Default: 0_ -* `}` +[`params`] - _Generation params_ (optional) + +| Prop | Description | Default | +| ---- | ----------- | ------- | +| seed | Generation seed | (autogenerated) | +| seedSize | Size of seed array | 512 | +| offsetX | Generation offset X | 0 | +| offsetY | Generation offset Y | 0 | . ## World -#### Get matrix of biomes data +### Get matrix of biomes data ```ts -const matrix: T[][] = world.getMatrix() +world.getMatrix(): T[][] ``` -#### Each all positions +### Each all positions ```ts -world.each(callback) +world.each( + callback: (position: WorldPoint, data: T) => void, +): void ``` -* `callback(` -* * `position` - Position at matrix -* * `data` - Biome data -* `)` +[`callback`] - _Callback with position and biome stored data_ -#### Get biome data at position +### Get biome data at position ```ts -const data: T = world.getAt(position) +world.getAt( + position: WorldPoint, +): T | null ``` -* `position {` -* * `x` - X position at matrix -* * `y` - Y position at matrix -* `}` +[`position`] - _Position at matrix_ -#### Replace biome data at position +### Replace biome data at position ```ts -world.replaceAt(position, data) +world.replaceAt( + position: WorldPoint, + data: T, +): void ``` -* `position {` -* * `x` - X position at matrix -* * `y` - Y position at matrix -* `}` -* `data` - New data of biome +[`position`] - _Position at matrix_ + +[`data`] - _New biome stored data_ -#### Get current world generation seed +### Get current world generation seed ```ts -const seed: number[] = world.seed +world.seed: number[] ``` -#### Get world width +### Get world width ```ts -const width: number = world.width +world.width: number ``` -#### Get world height +### Get world height ```ts -const height: number = world.height +world.height: number ``` .