Add planet scanner and octopus biome
This commit is contained in:
parent
2ecd61de98
commit
8fbcc340ce
21 changed files with 784 additions and 30 deletions
|
|
@ -9,7 +9,7 @@ const PLANET_DEFINITIONS = preload("res://planets/PlanetDefinitions.gd")
|
|||
# revisiting the same chunk always yields the same biome, and biomes form
|
||||
# smooth multi-chunk regions instead of a per-chunk random checkerboard.
|
||||
|
||||
enum Biome { SPACE, ASTEROID_FIELD }
|
||||
enum Biome { SPACE, ASTEROID_FIELD, OCTOPUS }
|
||||
|
||||
const CHUNK_SIZE: float = 1200.0
|
||||
const NOISE_SEED: int = 1337
|
||||
|
|
@ -37,10 +37,18 @@ const BLACK_HOLE_CHANCE: float = 0.05
|
|||
# from 0.08 after playtesting found that rate too scarce for how central
|
||||
# research points had become to progression.
|
||||
const RESEARCH_LAB_CHANCE: float = 0.16
|
||||
# A boss world is rarer than every ordinary discovery. Its roll uses a
|
||||
# separately seeded generator below, so adding it cannot rename or re-roll
|
||||
# any planet in an existing world.
|
||||
const BOSS_PLANET_CHANCE: float = 0.025
|
||||
# The hostile region is authored into procedural space as one finite,
|
||||
# deterministic island. A probability per chunk can only say "rare"; over an
|
||||
# infinite world it inevitably creates infinitely many boss worlds. One
|
||||
# anchor and one shape make the actual rule representable: one multi-chunk
|
||||
# octopus biome, with its boss at the centre.
|
||||
const OCTOPUS_BIOME_CENTER: Vector2i = Vector2i(12, -9)
|
||||
const OCTOPUS_BIOME_OFFSETS: Array[Vector2i] = [
|
||||
Vector2i(0, 0), Vector2i(-1, 0), Vector2i(1, 0),
|
||||
Vector2i(0, -1), Vector2i(0, 1),
|
||||
Vector2i(-1, -1), Vector2i(1, -1),
|
||||
Vector2i(-1, 1), Vector2i(1, 1),
|
||||
]
|
||||
|
||||
# DEV MODE ONLY: one of every planet type, parked in the chunks immediately
|
||||
# around the spawn so all five can be reached in seconds.
|
||||
|
|
@ -113,6 +121,8 @@ static func chunk_origin(chunk: Vector2i) -> Vector2:
|
|||
|
||||
|
||||
static func biome_at_chunk(chunk: Vector2i) -> int:
|
||||
if is_octopus_chunk(chunk):
|
||||
return Biome.OCTOPUS
|
||||
var n: float = _get_noise().get_noise_2d(float(chunk.x), float(chunk.y))
|
||||
if n > ASTEROID_FIELD_THRESHOLD:
|
||||
return Biome.ASTEROID_FIELD
|
||||
|
|
@ -122,6 +132,10 @@ static func biome_at_chunk(chunk: Vector2i) -> int:
|
|||
static func has_planet_at_chunk(chunk: Vector2i) -> bool:
|
||||
if _dev_planets_active() and DEV_PLANET_CHUNKS.has(chunk):
|
||||
return true
|
||||
if chunk == OCTOPUS_BIOME_CENTER:
|
||||
return true
|
||||
if is_octopus_chunk(chunk):
|
||||
return false
|
||||
var n: float = _get_planet_noise().get_noise_2d(float(chunk.x), float(chunk.y))
|
||||
return (biome_at_chunk(chunk) == Biome.ASTEROID_FIELD and n > PLANET_THRESHOLD) or (biome_at_chunk(chunk) == Biome.SPACE and n > GAS_GIANT_THRESHOLD)
|
||||
|
||||
|
|
@ -148,17 +162,12 @@ static func planet_data_at_chunk(chunk: Vector2i) -> Dictionary:
|
|||
var black_hole_roll: float = rng.randf()
|
||||
# Same principle, its own independent roll (#63).
|
||||
var research_lab_roll: float = rng.randf()
|
||||
# Independent from the established generation stream: existing chunks keep
|
||||
# their old names and shapes when this new rare outcome is introduced.
|
||||
var boss_rng := RandomNumberGenerator.new()
|
||||
boss_rng.seed = hash("boss:%d:%d" % [chunk.x, chunk.y])
|
||||
var boss_roll: float = boss_rng.randf()
|
||||
# A stable per-chunk roll makes gas giants persistent landmarks rather
|
||||
# than a different resource whenever the scene reloads.
|
||||
var gas_giant: bool = biome_at_chunk(chunk) == Biome.SPACE
|
||||
var definition_id: String = PLANET_DEFINITIONS.GAS_GIANT_ID if gas_giant else PLANET_DEFINITIONS.ROCKY_ID
|
||||
# Rare authored outcomes, seeded deterministically like everything else.
|
||||
if boss_roll < BOSS_PLANET_CHANCE:
|
||||
if chunk == OCTOPUS_BIOME_CENTER:
|
||||
definition_id = PLANET_DEFINITIONS.BOSS_ID
|
||||
elif black_hole_roll < BLACK_HOLE_CHANCE:
|
||||
definition_id = PLANET_DEFINITIONS.BLACK_HOLE_ID
|
||||
|
|
@ -186,5 +195,26 @@ static func biome_color(biome: int) -> Color:
|
|||
match biome:
|
||||
Biome.ASTEROID_FIELD:
|
||||
return Color(0.55, 0.36, 0.18, 1.0)
|
||||
Biome.OCTOPUS:
|
||||
return Color(0.34, 0.07, 0.24, 1.0)
|
||||
_:
|
||||
return Color(0.10, 0.13, 0.28, 1.0)
|
||||
|
||||
|
||||
static func biome_background_color(biome: int) -> Color:
|
||||
match biome:
|
||||
Biome.OCTOPUS:
|
||||
return Color(0.075, 0.012, 0.065, 1.0)
|
||||
_:
|
||||
return Color(0.02, 0.02, 0.08, 1.0)
|
||||
|
||||
|
||||
static func is_octopus_chunk(chunk: Vector2i) -> bool:
|
||||
return chunk - OCTOPUS_BIOME_CENTER in OCTOPUS_BIOME_OFFSETS
|
||||
|
||||
|
||||
static func octopus_biome_chunks() -> Array[Vector2i]:
|
||||
var chunks: Array[Vector2i] = []
|
||||
for offset in OCTOPUS_BIOME_OFFSETS:
|
||||
chunks.append(OCTOPUS_BIOME_CENTER + offset)
|
||||
return chunks
|
||||
|
|
|
|||
Loading…
Reference in a new issue