context menu added

player can find food and eat it
This commit is contained in:
Nikolai Fesenko
2025-08-20 16:45:03 +02:00
parent 9bab0ff0f3
commit a0efc6b9b8
11 changed files with 131 additions and 15 deletions

View File

@@ -11,6 +11,9 @@ signal object_unselected_signal
signal object_over_mouse_selected_signal(object)
signal object_over_mouse_unselected_signal(object)
signal show_context_menu
signal hide_context_menu
var is_context_menu_active: bool = false
var object_selected
var object_over_mouse
@@ -27,27 +30,29 @@ func _ready() -> void:
func _input(event: InputEvent) -> void:
if event.is_action_released("mouse_click"):
if event.is_action_released("mouse_click") and !is_context_menu_active:
if object_over_mouse != null:
object_selected_signal.emit(object_over_mouse)
if event.is_action_released("right_mouse_click"):
if object_selected != object_over_mouse:
else:
object_unselected_signal.emit()
if event.is_action_released("right_mouse_click"):
show_context_menu.emit()
func _on_interact(person, object):
object.start_action(person, object)
func _on_object_selected(object):
if object_selected != null:
if object_selected != null and object != object_selected:
object_unselected_signal.emit()
object_selected = object
object_selected.is_selected = true
print(object_selected)
func _on_object_unselected():
object_selected.is_selected = false
object_selected.disable_outline()
object_selected = null
if object_selected != null:
object_selected.is_selected = false
object_selected.disable_outline()
object_selected = null
func _on_mouse_object_selected(object):
object_over_mouse = object