feat: Fix set_interactive command (#461)
Co-authored-by: Dennis Ploeger <develop@dieploegers.de>
This commit is contained in:
@@ -10,7 +10,7 @@ var global_id: String
|
|||||||
var active: bool = true setget _set_active
|
var active: bool = true setget _set_active
|
||||||
|
|
||||||
# Wether the object is interactive (clickable by the player)
|
# Wether the object is interactive (clickable by the player)
|
||||||
var interactive: bool = true
|
var interactive: bool = true setget _set_interactive, _get_interactive
|
||||||
|
|
||||||
# The state of the object. If the object has a respective animation,
|
# The state of the object. If the object has a respective animation,
|
||||||
# it will be played
|
# it will be played
|
||||||
@@ -60,6 +60,25 @@ func _set_active(value: bool):
|
|||||||
self.node.visible = value
|
self.node.visible = value
|
||||||
|
|
||||||
|
|
||||||
|
# Get the interactive value from the node
|
||||||
|
#
|
||||||
|
# **Returns** Whether the node is interactive or not
|
||||||
|
func _get_interactive() -> bool:
|
||||||
|
if "is_interactive" in self.node:
|
||||||
|
return self.node.is_interactive
|
||||||
|
else:
|
||||||
|
return true
|
||||||
|
|
||||||
|
|
||||||
|
# Set the interactive value in the node
|
||||||
|
#
|
||||||
|
# #### Parameters
|
||||||
|
# - value: Whether the object is interactive or not
|
||||||
|
func _set_interactive(value: bool):
|
||||||
|
if "is_interactive" in self.node:
|
||||||
|
self.node.is_interactive = value
|
||||||
|
|
||||||
|
|
||||||
# Return the data of the object to be inserted in a savegame file.
|
# Return the data of the object to be inserted in a savegame file.
|
||||||
#
|
#
|
||||||
# **Returns**
|
# **Returns**
|
||||||
|
|||||||
@@ -270,9 +270,16 @@ func _ready():
|
|||||||
#
|
#
|
||||||
# - event: Triggered event
|
# - event: Triggered event
|
||||||
func _unhandled_input(event: InputEvent) -> void:
|
func _unhandled_input(event: InputEvent) -> void:
|
||||||
if not escoria.current_state == escoria.GAME_STATE.DEFAULT:
|
|
||||||
return
|
|
||||||
if event is InputEventMouseButton and event.is_pressed():
|
if event is InputEventMouseButton and event.is_pressed():
|
||||||
|
if not escoria.current_state == escoria.GAME_STATE.DEFAULT or \
|
||||||
|
not is_interactive:
|
||||||
|
escoria.logger.info(
|
||||||
|
(
|
||||||
|
"Item %s is not interactive or the game state doesn't " +
|
||||||
|
"accept interactions"
|
||||||
|
) % global_id
|
||||||
|
)
|
||||||
|
return
|
||||||
var p = get_global_mouse_position()
|
var p = get_global_mouse_position()
|
||||||
var mouse_in_shape: bool = false
|
var mouse_in_shape: bool = false
|
||||||
var colliders = get_world_2d().direct_space_state.intersect_point(
|
var colliders = get_world_2d().direct_space_state.intersect_point(
|
||||||
|
|||||||
Reference in New Issue
Block a user