Drive planets from definitions
This commit is contained in:
parent
2f68515f33
commit
02643c76c4
22 changed files with 183 additions and 82 deletions
|
|
@ -27,8 +27,7 @@ func _process(delta: float) -> bool:
|
|||
return _fail("nearby gas giant chunk does not contain a planet")
|
||||
if WorldGen.biome_at_chunk(nearby_chunk) != WorldGen.Biome.SPACE:
|
||||
return _fail("nearby gas giant is not in the normal space biome")
|
||||
if String(nearby_data.get("planet_type", "")) != "gas_giant" \
|
||||
or String(nearby_data.get("resource_type", "")) != "gas":
|
||||
if String(nearby_data.get("definition_id", "")) != "gas_giant":
|
||||
return _fail("nearby guaranteed planet is not a gas source")
|
||||
if nearby_position.length() > WorldGen.CHUNK_SIZE * 2.0:
|
||||
return _fail("nearby gas giant spawned too far away: %s" % nearby_position)
|
||||
|
|
@ -36,8 +35,7 @@ func _process(delta: float) -> bool:
|
|||
# Gas surfaces have vents only: no deferred ore pickups, and the vent
|
||||
# emission advances continuously so the source visibly looks active.
|
||||
game_state.planet_name = "Gas Test"
|
||||
game_state.planet_type = "gas_giant"
|
||||
game_state.surface_profile_id = "gas"
|
||||
game_state.planet_definition_id = "gas_giant"
|
||||
var surface: Node = load("res://PlanetSurface.tscn").instantiate()
|
||||
root.add_child(surface)
|
||||
var gas_field: Node = surface.get_node("SurfaceFeatures/ResourceProvider")
|
||||
|
|
@ -53,7 +51,7 @@ func _process(delta: float) -> bool:
|
|||
return _fail("gas-source emission animation did not advance")
|
||||
surface.free()
|
||||
|
||||
game_state.surface_profile_id = "rocky"
|
||||
game_state.planet_definition_id = "rocky"
|
||||
var rocky_surface: Node = load("res://PlanetSurface.tscn").instantiate()
|
||||
root.add_child(rocky_surface)
|
||||
var rocky_features: Node = rocky_surface.get_node("SurfaceFeatures/ResourceProvider")
|
||||
|
|
@ -69,16 +67,17 @@ func _process(delta: float) -> bool:
|
|||
for x in range(-12, 13):
|
||||
for y in range(-12, 13):
|
||||
var data: Dictionary = WorldGen.planet_data_at_chunk(Vector2i(x, y))
|
||||
if String(data.get("planet_type", "")) == "gas_giant":
|
||||
found_giant = String(data.get("resource_type", "")) == "gas"
|
||||
if String(data.get("definition_id", "")) == "gas_giant":
|
||||
found_giant = true
|
||||
break
|
||||
if found_giant:
|
||||
break
|
||||
if not found_giant:
|
||||
return _fail("world generation produced no deterministic gas giant")
|
||||
var giant: Node2D = load("res://Planet.tscn").instantiate()
|
||||
giant.planet_type = "gas_giant"
|
||||
giant._process(0.5)
|
||||
giant.definition_id = "gas_giant"
|
||||
root.add_child(giant)
|
||||
giant.visual._process(0.5)
|
||||
if giant.gas_phase <= 0.0:
|
||||
return _fail("gas giant animation did not advance")
|
||||
giant.free()
|
||||
|
|
|
|||
Loading…
Reference in a new issue