Paint brush

This commit is contained in:
Rendo 2025-10-15 00:10:51 +05:00
commit 1c20d54651
4 changed files with 21 additions and 21 deletions

View file

@ -2,6 +2,7 @@ extends Node2D
## Currently held structure
var held_construction : Structure
var selected_prototype : Prototype
func _ready() -> void:
GuiEventBus.construction_selected.connect(on_construction_selected)
@ -11,23 +12,25 @@ func _input(event: InputEvent) -> void:
return
if event.is_action_pressed("plc_place"):
var zone = try_get_zone(held_construction.global_position)
if zone == null:
held_construction.queue_free()
else:
if held_construction.try_place(zone):
held_construction = null
if zone != null and held_construction.try_place(zone):
var facing = held_construction.facing
held_construction = selected_prototype.scene.instantiate()
add_child(held_construction)
held_construction.set_facing(facing)
if event.is_action_pressed("plc_rotate_up"):
if held_construction != null:
held_construction.cycle_up_facing()
if event.is_action_pressed("plc_cancel"):
held_construction.queue_free()
selected_prototype = null
func on_construction_selected(constructible : Prototype):
if held_construction:
held_construction.queue_free()
held_construction = constructible.scene.instantiate()
add_child(held_construction)
selected_prototype = constructible
func _process(_delta: float) -> void: