blob: 6b2473e3f9f25a0da173836c7cc4342c3282d1e0 (
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
|
class_name Quest
extends PacketChunk
const BYTE_LENGTH := 0
## Byte Type: u32
## Byte Length: 4
var quest_id: int
## Byte Type: u8
## Byte Length: 1
var active: int
## Byte Type: u32
## Byte Length: 4
var remaining_time: int
## Byte Type: u32
## Byte Length: 4
var expire_time: int
## Byte Type: u16
## Byte Length: 2
var objective_count: int
var objective_details: Array
func get_byte_length():
return 15 + objective_count * QuestObjectiveDetails.BYTE_LENGTH
static func from_bytes(bytes: PackedByteArray):
var quest = Quest.new()
quest.quest_id = bytes.decode_u32(0)
quest.active = bytes.decode_u8(4)
quest.remaining_time = bytes.decode_u32(5)
quest.expire_time = bytes.decode_u32(9)
quest.objective_count = bytes.decode_u16(13)
quest.objective_details = QuestObjectiveDetails.array_from_bytes(
bytes.slice(15, 15 + quest.byte_length)
)
return quest
static func array_from_bytes(bytes: PackedByteArray) -> Array[Quest]:
var array: Array[Quest] = []
var offset = 0
while offset < bytes.size():
var chunk = from_bytes(bytes.slice(offset))
array.append(chunk)
offset += chunk.byte_length
return array
|