mirror of
https://github.com/Relintai/broken_seals.git
synced 2024-12-21 13:16:49 +01:00
Same logic for the vendor window.
This commit is contained in:
parent
78af5acc8a
commit
2e15d3f74e
@ -37,12 +37,15 @@ var _prev_button : Button
|
|||||||
var _next_button : Button
|
var _next_button : Button
|
||||||
|
|
||||||
var _player : Entity
|
var _player : Entity
|
||||||
|
var _vendor : Entity
|
||||||
|
|
||||||
var _page : int = 0
|
var _page : int = 0
|
||||||
var _max_pages : int = 0
|
var _max_pages : int = 0
|
||||||
|
|
||||||
var _vendor_item_data : VendorItemData
|
var _vendor_item_data : VendorItemData
|
||||||
|
|
||||||
|
var _timer : float = 0
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
opener_button = get_node_or_null(opener_button_path) as BaseButton
|
opener_button = get_node_or_null(opener_button_path) as BaseButton
|
||||||
|
|
||||||
@ -61,6 +64,25 @@ func _ready() -> void:
|
|||||||
|
|
||||||
connect("visibility_changed", self, "_visibility_changed")
|
connect("visibility_changed", self, "_visibility_changed")
|
||||||
|
|
||||||
|
set_process(false)
|
||||||
|
|
||||||
|
func _process(delta):
|
||||||
|
_timer += delta
|
||||||
|
|
||||||
|
if _timer > 1:
|
||||||
|
_timer = 0
|
||||||
|
|
||||||
|
if _player == null:
|
||||||
|
return
|
||||||
|
|
||||||
|
var target : Entity = _player.getc_target()
|
||||||
|
|
||||||
|
if target != _vendor:
|
||||||
|
hide()
|
||||||
|
|
||||||
|
if (_player.get_body_3d().translation - target.get_body_3d().translation).length_squared() > 16:#INTERACT_RANGE_SQUARED:
|
||||||
|
hide()
|
||||||
|
|
||||||
func inc_page() -> void:
|
func inc_page() -> void:
|
||||||
if _vendor_item_data == null:
|
if _vendor_item_data == null:
|
||||||
return
|
return
|
||||||
@ -138,8 +160,10 @@ func _visibility_changed() -> void:
|
|||||||
|
|
||||||
_page = 0
|
_page = 0
|
||||||
refresh_all()
|
refresh_all()
|
||||||
|
else:
|
||||||
|
_vendor = null
|
||||||
|
|
||||||
|
set_process(visible)
|
||||||
|
|
||||||
func set_player(p_player: Entity) -> void:
|
func set_player(p_player: Entity) -> void:
|
||||||
if _player != null:
|
if _player != null:
|
||||||
@ -155,6 +179,8 @@ func onc_open_winow_request(window_id : int) -> void:
|
|||||||
if window_id != EntityEnums.ENTITY_WINDOW_VENDOR:
|
if window_id != EntityEnums.ENTITY_WINDOW_VENDOR:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
_vendor = _player.getc_target()
|
||||||
|
|
||||||
show()
|
show()
|
||||||
|
|
||||||
# if player.has_signal("player_moved") && !player.is_connected("player_moved", self, "on_player_moved"):
|
# if player.has_signal("player_moved") && !player.is_connected("player_moved", self, "on_player_moved"):
|
||||||
|
Loading…
Reference in New Issue
Block a user