summaryrefslogtreecommitdiff
path: root/packets/regular_item_information.gd
diff options
context:
space:
mode:
authorDaniel Weipert <git@mail.dweipert.de>2024-12-13 14:53:38 +0100
committerDaniel Weipert <git@mail.dweipert.de>2024-12-13 14:53:38 +0100
commitca4d1945598863d0ce297f4272317e5dd5797f88 (patch)
treec2675b394140a71c7eee04034f087c107dcd7c9c /packets/regular_item_information.gd
parenta22381eff3bf2286ee27f4d15ddf4c431ea063be (diff)
next commit
Diffstat (limited to 'packets/regular_item_information.gd')
-rw-r--r--packets/regular_item_information.gd65
1 files changed, 65 insertions, 0 deletions
diff --git a/packets/regular_item_information.gd b/packets/regular_item_information.gd
new file mode 100644
index 0000000..212b341
--- /dev/null
+++ b/packets/regular_item_information.gd
@@ -0,0 +1,65 @@
+class_name RegularItemInformation
+extends PacketChunk
+
+
+const BYTE_LENGTH := 22
+
+
+## Byte Type: u16
+## Byte Length: 2
+var index: int
+
+## Byte Type: u32
+## Byte Length: 4
+var item_id: int
+
+## Byte Type: u8
+## Byte Length: 1
+var item_type: int
+
+## Byte Type: u16
+## Byte Length: 2
+var amount: int
+
+## Byte Type: u32
+## Byte Length: 4
+var equipped_position: int
+
+## Byte Type: u32
+## Byte Length: 4
+var slot: int
+
+## Byte Type: u32
+## Byte Length: 4
+var hire_expiration_date: int
+
+## Byte Type: u8
+## Byte Length: 1
+var flags: int
+
+
+static func from_bytes(bytes: PackedByteArray):
+ var info = RegularItemInformation.new()
+
+ info.index = bytes.decode_u16(0)
+ info.item_id = bytes.decode_u32(2)
+ info.item_type = bytes.decode_u8(6)
+ info.amount = bytes.decode_u16(7)
+ info.equipped_position = bytes.decode_u32(9)
+ info.slot = bytes.decode_u32(13)
+ info.hire_expiration_date = bytes.decode_u32(17)
+ info.flags = bytes.decode_u8(21)
+
+ return info
+
+
+static func array_from_bytes(bytes: PackedByteArray) -> Array[RegularItemInformation]:
+ var array: Array[RegularItemInformation] = []
+
+ var offset = 0
+ while offset < bytes.size():
+ var chunk = from_bytes(bytes.slice(offset))
+ array.append(chunk)
+ offset += chunk.byte_length
+
+ return array