equipable item row with working inventory #2

Merged
hux0192 merged 2 commits from equipable-item-rows into depot 2026-11-12 20:39:13 +01:00
Contributor
No description provided.
@ -65,0 +106,4 @@
var high_level_cat := row.category
row.items_categories.append(EquipableItemCategory.new(item, high_level_cat))
Owner

duplicating the whole inventory

duplicating the whole inventory
@ -10,3 +10,3 @@
var key_amount := 0
var high_level_categories: Array[Variant] = [
var high_level_categories: Array[Script] = [
Owner

missing multiple other categories so add_item will silently fail:

AccessoryRes
GlovesRes
LegsRes

missing multiple other categories so add_item will silently fail: AccessoryRes GlovesRes LegsRes
@ -89,0 +153,4 @@
func get_active_index_by_category(category: Script) -> int:
return find_row_by_category(category).active_index
Owner

null reference exception

null reference exception
@ -15,0 +25,4 @@
slot_buttons[i].item_slot_texture.texture = textures[i]
func set_visible_res() -> void:
Owner

multiple issues; row can be null and will return a null reference. row items categories can be null, also a null reference exception. the item_cat's themselves can also be null reference, causing another exception crash

multiple issues; row can be null and will return a null reference. row items categories can be null, also a null reference exception. the item_cat's themselves can also be null reference, causing another exception crash
@ -0,0 +11,4 @@
return get_items().find(item)
func get_items() -> Array[ItemInstance]:
Owner

this allocates memory for a new array, iterates through the entire category collection and copies it then does another linear search

items.find(item) is faster and more direct

this allocates memory for a new array, iterates through the entire category collection and copies it then does another linear search items.find(item) is faster and more direct
hux0192 left a comment

Bad practices; double allocation and slower iteration over arrays adding onto the O(n) complexity

Bad practices; double allocation and slower iteration over arrays adding onto the O(n) complexity
hux0192 merged commit f9cfc41402 into depot 2026-11-12 20:39:13 +01:00
Sign in to join this conversation.
No reviewers
No labels
programming
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
DuckTalk-Games/tower!2
No description provided.