Paint brush
This commit is contained in:
parent
6a7d3d0e45
commit
1c20d54651
4 changed files with 21 additions and 21 deletions
|
@ -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:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue