summaryrefslogtreecommitdiff
path: root/byte_stream.gd
diff options
context:
space:
mode:
authorDaniel Weipert <git@mail.dweipert.de>2024-12-15 14:23:25 +0100
committerDaniel Weipert <git@mail.dweipert.de>2024-12-15 14:23:25 +0100
commita14e88ff4d0d87841a44254e2bff1784da6e8b48 (patch)
tree0507cb8117da7943805a6479aef4526edb2db4dd /byte_stream.gd
parentca4d1945598863d0ce297f4272317e5dd5797f88 (diff)
next commit
Diffstat (limited to 'byte_stream.gd')
-rw-r--r--byte_stream.gd13
1 files changed, 9 insertions, 4 deletions
diff --git a/byte_stream.gd b/byte_stream.gd
index fe150fc..e1946ee 100644
--- a/byte_stream.gd
+++ b/byte_stream.gd
@@ -16,21 +16,26 @@ static func from_bytes(bytes: PackedByteArray) -> ByteStream:
@warning_ignore("shadowed_variable")
-func seek(position: int):
+func seek(position: int) -> void:
if position > 0:
assert(position <= bytes.size())
self.position = position
-func advance(jumps: int):
+func advance(jumps: int) -> void:
position += jumps
+func available() -> bool:
+ return position < bytes.size() - 1
+
+
func get_buffer(length: int) -> ByteStream:
- var byte_stream = ByteStream.new()
+ var byte_stream = ByteStream.from_bytes(
+ bytes.slice(position, position + length)
+ )
- byte_stream.bytes = bytes.slice(position, position + length)
seek(position + length)
return byte_stream