fix: early return for mouse_in_shape
This commit is contained in:
committed by
Julian Murgia
parent
e9dcf8d93f
commit
f21ec15560
@@ -283,22 +283,7 @@ func _unhandled_input(event: InputEvent) -> void:
|
|||||||
escoria.logger.info("Game state doesn't accept interactions")
|
escoria.logger.info("Game state doesn't accept interactions")
|
||||||
return
|
return
|
||||||
var p = get_global_mouse_position()
|
var p = get_global_mouse_position()
|
||||||
var mouse_in_shape: bool = false
|
if _is_in_shape(p):
|
||||||
var colliders = get_world_2d().direct_space_state.intersect_point(
|
|
||||||
p,
|
|
||||||
32,
|
|
||||||
[],
|
|
||||||
2147483647,
|
|
||||||
true,
|
|
||||||
true
|
|
||||||
)
|
|
||||||
for _owner in get_shape_owners():
|
|
||||||
for _shape_id in range(0, shape_owner_get_shape_count(_owner)):
|
|
||||||
for _collider in colliders:
|
|
||||||
if _collider.collider == self and\
|
|
||||||
_collider.shape == _shape_id:
|
|
||||||
mouse_in_shape = true
|
|
||||||
if mouse_in_shape:
|
|
||||||
if event.doubleclick and event.button_index == BUTTON_LEFT:
|
if event.doubleclick and event.button_index == BUTTON_LEFT:
|
||||||
emit_signal("mouse_double_left_clicked_item", self, event)
|
emit_signal("mouse_double_left_clicked_item", self, event)
|
||||||
get_tree().set_input_as_handled()
|
get_tree().set_input_as_handled()
|
||||||
@@ -310,6 +295,25 @@ func _unhandled_input(event: InputEvent) -> void:
|
|||||||
get_tree().set_input_as_handled()
|
get_tree().set_input_as_handled()
|
||||||
|
|
||||||
|
|
||||||
|
func _is_in_shape(position: Vector2) -> bool:
|
||||||
|
var colliders = get_world_2d().direct_space_state.intersect_point(
|
||||||
|
position,
|
||||||
|
32,
|
||||||
|
[],
|
||||||
|
2147483647,
|
||||||
|
true,
|
||||||
|
true
|
||||||
|
)
|
||||||
|
for _owner in get_shape_owners():
|
||||||
|
for _shape_id in range(0, shape_owner_get_shape_count(_owner)):
|
||||||
|
for _collider in colliders:
|
||||||
|
if _collider.collider == self and _collider.shape == _shape_id:
|
||||||
|
return true
|
||||||
|
return false
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Return the animation player node
|
# Return the animation player node
|
||||||
func get_animation_player() -> Node:
|
func get_animation_player() -> Node:
|
||||||
if _animation_player == null:
|
if _animation_player == null:
|
||||||
|
|||||||
Reference in New Issue
Block a user