I noticed that right clicking items will trigger the _deconstruct function, but _finish_construct actually never gets called. I've tried it on the sample project version 2 and 3 as well and it doesn't work.
EDIT: I now realize that you have to hold right click for it to work. Can someone help explain why holding works, when the event is just a "right click"
It works like this:
- When the player right-clicks, we start deconstructing by calling the _deconstruct() function
- This function starts a timer which triggers a call to _finish_deconstruct on timeout
- Inside the _unhandled_input callback, we have an extra line that calls _abort_deconstruct if the player presses another mouse button or releases the right mouse click
func _unhandled_input(event: InputEvent) -> void:
if event is InputEventMouseButton:
Correct. It works on a signal.
func _deconstruct(event_position: Vector2, cellv: Vector2) -> void:
"timeout", self, "_finish_deconstruct", [cellv], CONNECT_ONESHOT
This helps prevent situations where the user accidentally right clicks on an item and poof, down the entity goes, possibly ruining some ongoing smelting job or breaking the base's electricity network.