blob: 212b34161f2bb1840b12bf9c2ed1718f67b11263 (
plain)
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
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
|