From a14e88ff4d0d87841a44254e2bff1784da6e8b48 Mon Sep 17 00:00:00 2001 From: Daniel Weipert Date: Sun, 15 Dec 2024 14:23:25 +0100 Subject: next commit --- byte_stream.gd | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'byte_stream.gd') 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 -- cgit v1.2.3