summaryrefslogtreecommitdiff
path: root/packets/friend.gd
diff options
context:
space:
mode:
authorDaniel Weipert <git@mail.dweipert.de>2024-12-12 02:12:52 +0100
committerDaniel Weipert <git@mail.dweipert.de>2024-12-12 02:12:52 +0100
commita22381eff3bf2286ee27f4d15ddf4c431ea063be (patch)
tree965bdcf12e5e0cf63c88cbba1bd5a52ba474f81f /packets/friend.gd
parente3c185e05823e30eccd7728ceda2ee57cc66fd4d (diff)
next commit
Diffstat (limited to 'packets/friend.gd')
-rw-r--r--packets/friend.gd40
1 files changed, 40 insertions, 0 deletions
diff --git a/packets/friend.gd b/packets/friend.gd
new file mode 100644
index 0000000..70120fe
--- /dev/null
+++ b/packets/friend.gd
@@ -0,0 +1,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