summaryrefslogtreecommitdiff
path: root/Game/States/Build
diff options
context:
space:
mode:
Diffstat (limited to 'Game/States/Build')
-rw-r--r--Game/States/Build/BuilderElement.gd3
-rw-r--r--Game/States/Build/StateBuild.gd26
2 files changed, 11 insertions, 18 deletions
diff --git a/Game/States/Build/BuilderElement.gd b/Game/States/Build/BuilderElement.gd
index 8315792..bb10b06 100644
--- a/Game/States/Build/BuilderElement.gd
+++ b/Game/States/Build/BuilderElement.gd
@@ -67,6 +67,9 @@ func _process(_delta):
if global_position != previous_position:
queue_redraw()
+
+ # TODO: rpc to other peers
+ # TODO: only as preview not as blocking to build
func can_build():
diff --git a/Game/States/Build/StateBuild.gd b/Game/States/Build/StateBuild.gd
index b92020b..d2fb39d 100644
--- a/Game/States/Build/StateBuild.gd
+++ b/Game/States/Build/StateBuild.gd
@@ -7,19 +7,6 @@ static var current_builder_element: BuilderElement
func _state_enter():
%BuildGrid.visible = true
- var builder_element_scene = preload("res://Game/States/Build/BuilderElement.tscn")
- var builder_element = builder_element_scene.instantiate()
-
- var tower = preload("res://Towers/Tower.tscn").instantiate() as Tower
- tower.attack_range = [
- Client.stage.map.tile_set.tile_size.x * 2,
- Client.stage.map.tile_set.tile_size.x * 3,
- Client.stage.map.tile_set.tile_size.x * 4,
- ].pick_random()
-
- builder_element.element = tower
- get_tree().current_scene.add_child(builder_element)
- current_builder_element = builder_element
func _state_exit():
@@ -28,9 +15,8 @@ func _state_exit():
func _state_input(event: InputEvent):
if event.is_action_pressed("builder_tower_select"):
- get_viewport().set_input_as_handled()
- if current_builder_element.can_build():
+ if current_builder_element and current_builder_element.can_build():
var placed_tower = current_builder_element.element.duplicate() as Tower
Client.place_tower(placed_tower, current_builder_element.global_position)
@@ -42,9 +28,13 @@ func _state_input(event: InputEvent):
if not Input.is_action_pressed("builder_tower_place_keep"):
current_builder_element.queue_free()
- set_state("StateDefault")
+ current_builder_element = null
- if event.is_action_pressed("builder_cancel") or event.is_action_pressed("build_mode_start"):
+ if event.is_action_pressed("build_mode_start"):
get_viewport().set_input_as_handled()
- current_builder_element.queue_free()
+
+ if current_builder_element:
+ current_builder_element.queue_free()
+ current_builder_element = null
+
set_state("StateDefault")