forked from ProfAndreaPollini/godot-rl-2022
-
Notifications
You must be signed in to change notification settings - Fork 0
/
InventoryLayer.gd
36 lines (25 loc) · 880 Bytes
/
InventoryLayer.gd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
extends CanvasLayer
# Declare member variables here. Examples:
# var a = 2
# var b = "text"
onready var slots = [$slot0,$slot1]
# Called when the node enters the scene tree for the first time.
func _ready():
set_process_input(false)
EventBus.connect("open_inventory",self,"on_open_inventory")
EventBus.connect("close_inventory",self,"on_close_inventory")
EventBus.connect("inventory_modified",self, "on_inventory_modified")
func on_inventory_modified(inventory):
print("UI: on_inventory_modified ({0})".format({0:inventory.get_child_count()}))
var pos = 0
for obj in inventory.get_children():
slots[pos].texture = obj.icon_texture
pos += 1
func on_open_inventory():
set_process_input(true)
visible = true
func on_close_inventory():
set_process_input(false)
visible = false
func _on_TextureButton_button_down():
EventBus.emit_signal("close_inventory")