Dimensions for constructibles

This commit is contained in:
Rendo 2025-10-11 12:58:36 +05:00
commit 6f56fffb59
18 changed files with 135 additions and 25 deletions

View file

@ -13,7 +13,7 @@ func _input(event: InputEvent) -> void:
if zone == null:
held_construction.queue_free()
else:
if zone.get_parent().get_node("EntityHolder").add_construction(held_construction):
if held_construction.try_place(zone):
held_construction = null
if event.is_action_pressed("plc_cancel"):
@ -27,13 +27,14 @@ func on_construction_selected(constructible : Constructible):
func _process(_delta: float) -> void:
if held_construction != null:
var mouse_pos = get_global_mouse_position()
var zone = try_get_zone(mouse_pos)
if zone:
global_position = zone.get_placement_position(mouse_pos)
else:
global_position = mouse_pos
if held_construction == null:
return
var mouse_pos = get_global_mouse_position()
var zone = try_get_zone(mouse_pos)
if zone and held_construction.can_be_placed(zone):
global_position = zone.get_placement_position(mouse_pos)
else:
global_position = mouse_pos
func try_get_zone(point : Vector2) -> BuildZone:
for zone in Registry.build_zones: