The LootWindow now closes when the player moves.

This commit is contained in:
Relintai 2020-08-12 15:54:40 +02:00
parent 8a46084f00
commit 6342dccbf4
3 changed files with 16 additions and 2 deletions

View File

@ -24,6 +24,13 @@ class_name PlayerGD
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
signal player_moved()
func _moved():
._moved()
emit_signal("player_moved")
func _process(delta):
if Input.is_action_just_pressed("sheath"):
get_character_skeleton().toggle_sheath()

View File

@ -59,6 +59,10 @@ func set_player(p_player : Entity) -> void:
player.connect("ctarget_bag_changed", self, "ctarget_bag_changed")
player.connect("onc_open_loot_winow_request", self, "onc_open_loot_winow_request")
func on_player_moved():
if visible:
hide()
func on_visibility_changed():
if visible:
refresh()
@ -66,7 +70,7 @@ func on_visibility_changed():
if target_bag != null:
target_bag.disconnect("item_removed", self, "on_item_removed")
target_bag = null
func on_item_removed(bag: Bag, item: ItemInstance, slot_id: int) -> void:
refresh()
@ -84,3 +88,6 @@ func ctarget_bag_changed(entity: Entity, bag: Bag) -> void:
func onc_open_loot_winow_request() -> void:
show()
if player.has_signal("player_moved") && !player.is_connected("player_moved", self, "on_player_moved"):
player.connect("player_moved", self, "on_player_moved", [], CONNECT_ONESHOT)

View File

@ -45,6 +45,6 @@ size_flags_horizontal = 3
[node name="Button" type="Button" parent="VBoxContainer"]
margin_top = 566.0
margin_right = 1016.0
margin_bottom = 592.269
margin_bottom = 592.57
text = "close"
[connection signal="pressed" from="VBoxContainer/Button" to="." method="hide"]