blob: 70120fe199f204bd52d687a5494931bdfaec058f (
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
|
class_name Friend
extends PacketChunk
const BYTE_LENGTH := 32
## Byte Type: u32
## Byte Length: 4
var account_id: int
## Byte Type: u32
## Byte Length: 4
var character_id: int
## Byte Type: u8
## Byte Length: 24
var name: String
static func from_bytes(bytes: PackedByteArray):
var quest = Friend.new()
quest.account_id = bytes.decode_u32(0)
quest.character_id = bytes.decode_u32(4)
quest.name = bytes.slice(8, 8 + 24).get_string_from_utf8()
return quest
static func array_from_bytes(bytes: PackedByteArray) -> Array[Friend]:
var array: Array[Friend] = []
var offset = 0
while offset < bytes.size():
var chunk = from_bytes(bytes.slice(offset))
array.append(chunk)
offset += chunk.byte_length
return array
|