summaryrefslogtreecommitdiff
path: root/byte_stream.gd
diff options
context:
space:
mode:
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