Journal no longer contains duplicates
Added some documentation to grid.gd
This commit is contained in:
parent
930d9e6d8e
commit
808ffb337e
2 changed files with 12 additions and 7 deletions
|
|
@ -1,20 +1,24 @@
|
||||||
extends Control
|
extends Control
|
||||||
|
|
||||||
@onready var item_list : ItemList = $ItemList
|
@onready var item_list : ItemList = $ItemList
|
||||||
|
var item_list_no_dupes = []
|
||||||
|
|
||||||
# Add items from each pool to journal. TODO: Deal with multiplicities.
|
# Add items from each pool to journal.
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
await get_tree().create_timer(0.3).timeout
|
|
||||||
for item_scene in ItemSpawn.item_pool.common:
|
for item_scene in ItemSpawn.item_pool.common:
|
||||||
add_item_to_journal(item_scene.instantiate())
|
add_item_to_journal(item_scene)
|
||||||
for item_scene in ItemSpawn.item_pool.rare:
|
for item_scene in ItemSpawn.item_pool.rare:
|
||||||
add_item_to_journal(item_scene.instantiate())
|
add_item_to_journal(item_scene)
|
||||||
for item_scene in ItemSpawn.item_pool.unique:
|
for item_scene in ItemSpawn.item_pool.unique:
|
||||||
add_item_to_journal(item_scene.instantiate())
|
add_item_to_journal(item_scene)
|
||||||
|
|
||||||
func _process(_delta: float) -> void:
|
func _process(_delta: float) -> void:
|
||||||
if Input.is_action_just_pressed("journal"):
|
if Input.is_action_just_pressed("journal"):
|
||||||
visible = not visible
|
visible = not visible
|
||||||
|
|
||||||
func add_item_to_journal(item: Item):
|
# Adds an item to the journal if it was not yet added
|
||||||
|
func add_item_to_journal(item_scene):
|
||||||
|
if not item_list_no_dupes.has(item_scene):
|
||||||
|
item_list_no_dupes.append(item_scene)
|
||||||
|
var item = item_scene.instantiate()
|
||||||
item_list.add_item(item.item_name, item.icon)
|
item_list.add_item(item.item_name, item.icon)
|
||||||
|
|
|
||||||
|
|
@ -45,6 +45,7 @@ func add_building_to_collumn(building : Building, collumn : int):
|
||||||
add_child(building)
|
add_child(building)
|
||||||
return true
|
return true
|
||||||
|
|
||||||
|
# Adds children of given node to the grid and their building.
|
||||||
func place_object_list(obj_list : Node2D, building):
|
func place_object_list(obj_list : Node2D, building):
|
||||||
obj_list.reparent(self, false)
|
obj_list.reparent(self, false)
|
||||||
var objects_to_be_placed = obj_list.get_children()
|
var objects_to_be_placed = obj_list.get_children()
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue