summaryrefslogtreecommitdiff
path: root/src/tools/world_generator/scripts/walker_head.gd
diff options
context:
space:
mode:
Diffstat (limited to 'src/tools/world_generator/scripts/walker_head.gd')
-rw-r--r--src/tools/world_generator/scripts/walker_head.gd42
1 files changed, 32 insertions, 10 deletions
diff --git a/src/tools/world_generator/scripts/walker_head.gd b/src/tools/world_generator/scripts/walker_head.gd
index dc71db1..2ad9650 100644
--- a/src/tools/world_generator/scripts/walker_head.gd
+++ b/src/tools/world_generator/scripts/walker_head.gd
@@ -2,8 +2,8 @@ extends Node2D
export(NodePath) var TILEMAP_NP: NodePath
export(PackedScene) var WALKER_UNIT_NP: PackedScene
-export(int, 5, 100, 1) var STARTING_UNIT_COUNT: int = 5
-export(int, 3, 10, 1) var INITIAL_SAFE_ZONE_SIZE: int = 3
+export(int, 4, 100, 1) var STARTING_UNIT_COUNT: int = 6
+export(int, 2, 10, 1) var INITIAL_SAFE_ZONE_SIZE: int = 2
onready var tilemap: TileMap = get_node(TILEMAP_NP)
@@ -23,6 +23,15 @@ func _ready() -> void:
_fill_empty_space()
+func get_cells_around(size: int=INITIAL_SAFE_ZONE_SIZE) -> Array:
+ var locations: Array = []
+ for i in range(-size, size):
+ for j in range(-size, size):
+ locations.append(Vector2(i, j))
+
+ return locations
+
+
func _place_safe_zone() -> void:
var size: int = INITIAL_SAFE_ZONE_SIZE
for i in range(-size, size):
@@ -44,27 +53,40 @@ func _spawn_walker_unit(spawn_position: Vector2) -> void:
func _fill_empty_space() -> void:
+ var locations: Array = _get_empty_cells_location()
+ for location in locations:
+ tilemap.set_cellv(location, Global.WORLD_TILE_WALL)
+
+
+func _get_empty_cells_location() -> Array:
+ var locations: Array = []
var rect: Rect2 = tilemap.get_used_rect()
var margin: int = map_margin
for x in range(-margin, rect.size.x + margin):
- for y in range (-margin, rect.size.y + margin ):
- var poses: Vector2= Vector2(rect.position.x + x, rect.position.y + y)
- if tilemap.get_cell(int(poses.x), int(poses.y)) == TileMap.INVALID_CELL:
- tilemap.set_cellv(poses, Global.WORLD_TILE_WALL)
+ for y in range (-margin, rect.size.y + margin):
+ var location: Vector2 = Vector2(rect.position.x + x, rect.position.y + y)
+ if tilemap.get_cell(int(location.x), int(location.y)) == TileMap.INVALID_CELL:
+ locations.append(location)
+
+ return locations
func _on_world_gen_walker_started(id: int) -> void:
- print("Walker unit %s started." % id)
+ # print("Walker unit %s started." % id)
+ pass
func _on_world_gen_walker_finished(id: int) -> void:
- print("Walker unit %s finished." % id)
+ # print("Walker unit %s finished." % id)
+ pass
func _on_world_gen_walker_died(id: int) -> void:
- print("Walker unit %s died." % id)
+ # print("Walker unit %s died." % id)
+ pass
func _on_world_gen_spawn_walker_unit(location: Vector2) -> void:
- print("Spawning new walking unit.")
+ # print("Spawning new walking unit.")
+ pass
_spawn_walker_unit(location)