summaryrefslogtreecommitdiff
path: root/Game/States/Build/BuilderElement.gd
diff options
context:
space:
mode:
Diffstat (limited to 'Game/States/Build/BuilderElement.gd')
-rw-r--r--Game/States/Build/BuilderElement.gd16
1 files changed, 13 insertions, 3 deletions
diff --git a/Game/States/Build/BuilderElement.gd b/Game/States/Build/BuilderElement.gd
index c698f07..eb5ae12 100644
--- a/Game/States/Build/BuilderElement.gd
+++ b/Game/States/Build/BuilderElement.gd
@@ -25,7 +25,7 @@ func _ready():
var element_collision_shape = instance.get_node("CollisionShape2D").duplicate() as CollisionShape2D
collision_shape = element_collision_shape.shape
- var tile_size = Client.stage.map.tile_set.tile_size
+ var tile_size = Client.current_stage.map.tile_set.tile_size
var snapped_size = collision_shape.size.snapped(tile_size)
for x in (snapped_size.x / tile_size.x):
for y in (snapped_size.y / tile_size.y):
@@ -39,9 +39,15 @@ func _ready():
collision_visibility_area.set_collision_mask_value(1, true)
collision_visibility_area.set_collision_mask_value(2, true)
collision_visibility_area.set_collision_mask_value(3, true)
+ collision_visibility_area.set_collision_mask_value(4, true)
+ collision_visibility_area.set_collision_mask_value(8, true)
collision_visibility_area.colliding_color = Color(1, 0, 0, 0.5)
collision_visibility_area.not_colliding_color = Color(0, 1, 0, 0.25)
+ if Client.current_stage.has_method("get_builder_collision_masks"):
+ for idx in Client.current_stage.get_builder_collision_masks():
+ collision_visibility_area.set_collision_mask_value(idx, true)
+
var shape = RectangleShape2D.new()
shape.size = Vector2(tile_size - Vector2i(1, 1))
var cshape = CollisionShape2D.new()
@@ -56,7 +62,7 @@ func _ready():
func _draw():
draw_circle(
- Client.stage.map.tile_set.tile_size,
+ Client.current_stage.map.tile_set.tile_size,
8 + instance.attack_range,
Color(1, 1, 1, 0.75),
false,
@@ -66,7 +72,7 @@ func _draw():
func _process(_delta):
previous_position = global_position
- global_position = get_global_mouse_position().snapped(Client.stage.map.tile_set.tile_size) - Vector2(16,16)
+ global_position = get_global_mouse_position().snapped(Client.current_stage.map.tile_set.tile_size) - Vector2(16,16)
if global_position != previous_position:
queue_redraw()
@@ -82,6 +88,10 @@ func can_build():
if area.get_overlapping_bodies().size() > 0:
return false
+
+
+ if Client.current_stage.has_method("can_build"):
+ return Client.current_stage.can_build()
return true