mirror of
https://github.com/Relintai/broken_seals.git
synced 2024-11-13 20:47:19 +01:00
Now terra chunks are actually properly generated by placing chunks on the world generator's grid.
This commit is contained in:
parent
0cbf540e30
commit
808c8e97d3
@ -68,27 +68,25 @@ func _setup_terra_library(library : TerramanLibrary, pseed : int) -> void:
|
||||
pass
|
||||
|
||||
func generate_terra_chunk(chunk: TerraChunk, pseed : int, spawn_mobs: bool) -> void:
|
||||
generate_terra_chunk_internal(chunk, pseed, spawn_mobs, get_rect())
|
||||
|
||||
func generate_terra_chunk_internal(chunk: TerraChunk, pseed : int, spawn_mobs: bool, world_parent_rect : Rect2) -> void:
|
||||
var wcr : Rect2 = get_rect()
|
||||
wcr.position += world_parent_rect.position
|
||||
|
||||
var p : Vector2 = Vector2(chunk.get_position_x(), chunk.get_position_z())
|
||||
|
||||
var stack : Array = get_hit_stack(p)
|
||||
|
||||
#TODO
|
||||
#if !wcr.has_point(p):
|
||||
# return
|
||||
|
||||
_generate_terra_chunk(chunk, spawn_mobs, spawn_mobs)
|
||||
if stack.size() == 0:
|
||||
_generate_terra_chunk_fallback(chunk, pseed, spawn_mobs)
|
||||
return
|
||||
|
||||
for c in get_content():
|
||||
if c:
|
||||
c.generate_terra_chunk_internal(chunk, pseed, spawn_mobs, wcr)
|
||||
for i in range(stack.size() - 1, -1, -1):
|
||||
stack[i]._generate_terra_chunk(chunk, pseed, spawn_mobs, stack, i)
|
||||
|
||||
func _generate_terra_chunk(chunk: TerraChunk, pseed : int, spawn_mobs: bool) -> void:
|
||||
func _generate_terra_chunk(chunk: TerraChunk, pseed : int, spawn_mobs: bool, stack : Array, stack_index : int) -> void:
|
||||
pass
|
||||
|
||||
func _generate_terra_chunk_fallback(chunk: TerraChunk, pseed : int, spawn_mobs: bool) -> void:
|
||||
chunk.channel_ensure_allocated(TerraChunkDefault.DEFAULT_CHANNEL_TYPE, 1)
|
||||
chunk.channel_ensure_allocated(TerraChunkDefault.DEFAULT_CHANNEL_ISOLEVEL, 1)
|
||||
chunk.set_voxel(1, 0, 0, TerraChunkDefault.DEFAULT_CHANNEL_ISOLEVEL)
|
||||
|
||||
func generate_map(pseed : int) -> Image:
|
||||
var img : Image = Image.new()
|
||||
|
||||
@ -108,6 +106,21 @@ func add_to_map(var img : Image, pseed : int) -> void:
|
||||
func _add_to_map(var img : Image, pseed : int) -> void:
|
||||
pass
|
||||
|
||||
func get_hit_stack(var pos : Vector2) -> Array:
|
||||
var r : Rect2 = get_rect()
|
||||
var local_pos : Vector2 = pos - rect.position
|
||||
|
||||
var result : Array = Array()
|
||||
|
||||
if r.has_point(local_pos):
|
||||
result.append(self)
|
||||
|
||||
for c in get_content():
|
||||
if c:
|
||||
result.append_array(c.get_hit_stack(local_pos))
|
||||
|
||||
return result
|
||||
|
||||
func get_editor_rect_border_color() -> Color:
|
||||
return Color(1, 1, 1, 1)
|
||||
|
||||
|
@ -21,9 +21,6 @@ func _generate_terra_chunk(chunk : TerraChunk, spawn_mobs : bool):
|
||||
|
||||
if chunk.position_x == 0 && chunk.position_z == 0:
|
||||
var pos : Vector3 = Vector3(4 * chunk.voxel_scale, 8 * chunk.voxel_scale, 4 * chunk.voxel_scale)
|
||||
|
||||
ESS.entity_spawner.spawn_mob(trainer.id, 1, pos)
|
||||
|
||||
pos = Vector3(2 * chunk.voxel_scale, 8 * chunk.voxel_scale, 2 * chunk.voxel_scale)
|
||||
|
||||
ESS.entity_spawner.spawn_mob(vendor.id, 1, pos)
|
||||
|
@ -29,7 +29,7 @@ func get_editor_additional_text() -> String:
|
||||
func _setup_terra_library(library : TerramanLibrary, pseed : int) -> void:
|
||||
pass
|
||||
|
||||
func _generate_terra_chunk(chunk: TerraChunk, pseed : int, spawn_mobs: bool) -> void:
|
||||
func _generate_terra_chunk(chunk: TerraChunk, pseed : int, spawn_mobs: bool, stack : Array, stack_index : int) -> void:
|
||||
voxel_scale = chunk.voxel_scale
|
||||
current_seed = pseed
|
||||
|
||||
@ -68,7 +68,7 @@ func _generate_terra_chunk(chunk: TerraChunk, pseed : int, spawn_mobs: bool) ->
|
||||
|
||||
if not Engine.editor_hint and spawn_mobs and rng.randi() % 4 == 0:
|
||||
var level : int = 1
|
||||
|
||||
|
||||
if chunk.get_voxel_world().has_method("get_mob_level"):
|
||||
level = chunk.get_voxel_world().get_mob_level()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user