forked from woofmeow/straywild
feat: add persistent inventory storage slots
This commit is contained in:
parent
6db6fbba7f
commit
a88e76848b
13 changed files with 875 additions and 65 deletions
|
|
@ -1,12 +1,20 @@
|
|||
class_name OwnedItem
|
||||
extends Resource
|
||||
|
||||
const MAX_STORAGE_SLOT_INDEX: int = 254
|
||||
|
||||
@export var item_id: StringName
|
||||
@export var quantity: int = 1
|
||||
@export var storage_slot: int = -1
|
||||
|
||||
|
||||
func is_valid() -> bool:
|
||||
return not item_id.is_empty() and quantity > 0
|
||||
return (
|
||||
not item_id.is_empty()
|
||||
and quantity > 0
|
||||
and storage_slot >= -1
|
||||
and storage_slot <= MAX_STORAGE_SLOT_INDEX
|
||||
)
|
||||
|
||||
|
||||
func duplicate_record():
|
||||
|
|
@ -17,4 +25,5 @@ func to_save_dict() -> Dictionary:
|
|||
return {
|
||||
"item_id": String(item_id),
|
||||
"quantity": quantity,
|
||||
"storage_slot": storage_slot,
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue