diff options
Diffstat (limited to 'packets/quest.gd')
-rw-r--r-- | packets/quest.gd | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/packets/quest.gd b/packets/quest.gd new file mode 100644 index 0000000..347f5d1 --- /dev/null +++ b/packets/quest.gd @@ -0,0 +1,54 @@ +class_name Quest +extends PacketChunk + + +## 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 "??" + + +static func from_bytes(bytes: PackedByteArray): + var quest = Quest.new() + + quest.quest_id = bytes.slice(0, 4) + quest.active = bytes.decode_u16(4) + quest.remaining_time = bytes.slice(6, 6 + 20).get_string_from_utf8() + quest.expire_time = bytes.decode_u16(26) + quest.objective_count = bytes.decode_u16(28) + quest.objective_details = bytes.slice(32) + + return quest + + +static func array_from_bytes(bytes: PackedByteArray) -> Array: + var array = [] + + var offset = 0 + while offset < bytes.size(): + var chunk = from_bytes(bytes.slice(offset)) + array.append(chunk) + offset += chunk.byte_length + + return array |