-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
129 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import type { WorldGenerationParams } from "./types"; | ||
import { World } from "../world"; | ||
import { WorldBiome } from "../world/biome"; | ||
import type { WorldConfig } from "../world/types"; | ||
import type { WorldBiomeConfig } from "../world/biome/types"; | ||
export declare class WorldGenerator<T extends object> { | ||
readonly config: WorldConfig; | ||
private biomes; | ||
constructor(config: WorldConfig); | ||
addBiome(config: WorldBiomeConfig, data: T): WorldBiome<T>; | ||
clearBiomes(): void; | ||
getBiomes(): WorldBiome<T>[]; | ||
peakBiome(height: number): WorldBiome<T> | null; | ||
generate(params?: WorldGenerationParams): World<T>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
export type WorldGenerationParams = { | ||
/** | ||
* Generation seed | ||
* Default: Autogenerate | ||
*/ | ||
seed?: number[]; | ||
/** | ||
* Size of seed array | ||
* Default: 512 | ||
*/ | ||
seedSize?: number; | ||
/** | ||
* Generation offset X | ||
* Default: 0 | ||
*/ | ||
offsetX?: number; | ||
/** | ||
* Generation offset Y | ||
* Default: 0 | ||
*/ | ||
offsetY?: number; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
export * from './world-generator'; | ||
export * from './generator'; | ||
export * from './generator/types'; | ||
export * from './world'; | ||
export * from './types'; | ||
export * from './world/types'; | ||
export * from './world/biome'; | ||
export * from './world/biome/types'; | ||
export * from './utils/perlin'; | ||
export * from './utils/seed'; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import type { PerlinParameters } from "./types"; | ||
export declare function generateNoise(parameters: PerlinParameters): number; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import type { WorldConfig } from "../../world/types"; | ||
export type PerlinParameters = { | ||
seed: number[]; | ||
config: WorldConfig; | ||
x: number; | ||
y: number; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export declare function generateSeed(size?: number): number[]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import type { WorldBiomeConfig } from "./types"; | ||
export declare class WorldBiome<T extends object> { | ||
readonly lowerBound: number; | ||
readonly upperBound: number; | ||
readonly data: T; | ||
constructor(config: WorldBiomeConfig, data: T); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
export type WorldBiomeConfig = { | ||
/** | ||
* Lower biome bound | ||
* Default: 0.0 | ||
* Min: 0.0 | ||
*/ | ||
lowerBound?: number; | ||
/** | ||
* Upper biome bound | ||
* Default: 1.0 | ||
* Max: 1.0 | ||
*/ | ||
upperBound?: number; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import type { WorldPoint } from "./types"; | ||
export declare class World<T extends object> { | ||
readonly width: number; | ||
readonly height: number; | ||
readonly seed: number[]; | ||
private matrix; | ||
constructor(matrix: T[][], seed: number[]); | ||
getMatrix(): T[][]; | ||
each(callback: (point: WorldPoint, biome: T) => boolean | void): void; | ||
getAt(point: WorldPoint): T | null; | ||
replaceAt(point: WorldPoint, data: T): void; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
export type WorldConfig = { | ||
/** | ||
* World width | ||
*/ | ||
width: number; | ||
/** | ||
* World height | ||
*/ | ||
height: number; | ||
/** | ||
* Frequency of biomes change | ||
* Default: 0.3 | ||
* Min: 0.0, Max: 1.0 | ||
*/ | ||
frequencyChange?: number; | ||
/** | ||
* Smoothness of biomes borders | ||
* Default: 0.5 | ||
* Min: 0.0, Max: 1.0 | ||
*/ | ||
borderSmoothness?: number; | ||
/** | ||
* Redistribution of biomes height | ||
* Default: 1.0 | ||
* Min: 0.5, Max: 1.5 | ||
*/ | ||
heightRedistribution?: number; | ||
/** | ||
* Averaging of biomes height | ||
* Default: true | ||
*/ | ||
heightAveraging?: boolean; | ||
/** | ||
* Scale of falloff area | ||
* Default: 0.0 | ||
*/ | ||
falloff?: number; | ||
}; | ||
export type WorldPoint = { | ||
x: number; | ||
y: number; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters