From c89f25f59aa493d95bcac8e75ca5cdd57a0403e7 Mon Sep 17 00:00:00 2001 From: Daniel Weipert Date: Thu, 28 Nov 2024 00:45:30 +0100 Subject: initial commit --- character_information.gd | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 character_information.gd (limited to 'character_information.gd') diff --git a/character_information.gd b/character_information.gd new file mode 100644 index 0000000..101f74f --- /dev/null +++ b/character_information.gd @@ -0,0 +1,32 @@ +class_name CharacterInformation + + +## Byte Length: 4 +var character_id: int + +## Byte Length: 8 +var experience: int + +## Byte Length: 4 +var money: int + + +static func from_bytes(bytes: PackedByteArray): + var info = CharacterInformation.new() + + info.character_id = bytes.decode_u32(0) + info.experience = bytes.decode_s64(4) + info.money = bytes.decode_s32(12) + + return info + + +static func array_from_bytes(bytes: PackedByteArray) -> Array: + var array = [] + + var offset = 0 + while offset < bytes.size(): + array.append(from_bytes(bytes.slice(offset))) + offset += 175 + + return array -- cgit v1.2.3