Browse Source

Cleaing the world before generation

master
Ryan Reed 1 year ago
parent
commit
71e110dac9
1 changed files with 14 additions and 0 deletions
  1. +14
    -0
      world.gd

+ 14
- 0
world.gd View File

@ -91,6 +91,7 @@ func update_generation_ui() -> void:
# Conway Specific
#
func start_conway() -> void:
clear_world()
generate_world()
generation = 1
@ -173,6 +174,15 @@ func toggle_pause() -> void:
else: generation_timer.start()
## Loop over cell_ids and free the resource in the RenderingServer
## Clear cell_ids and cell_states
func clear_world() -> void:
for row in cell_ids:
for id in row:
RenderingServer.free_rid(id)
cell_ids = []
cell_states = []
## Create the cell using the rendering server
## This is only performed on initial world generation
func create_cell(pos: Vector2, visible_cell: bool = true) -> RID:
@ -237,3 +247,7 @@ func _on_start_paused_button_toggled(button_pressed: bool) -> void:
func _on_world_seed_generate_pressed() -> void:
generation_seed.text = str(randi())
func _exit_tree() -> void:
clear_world()

Loading…
Cancel
Save