You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

42 lines
908 B
GDScript

2 years ago
var file: FileAccess;
var chunk_size = 0;
func _init(file: FileAccess):
self.file = file;
self.chunk_size = 0;
2 years ago
func has_data_to_read(): return file.get_position() < file.get_length()
func set_chunk_size(size):
chunk_size = size;
2 years ago
func get_8():
chunk_size -= 1;
return file.get_8();
2 years ago
func get_32():
chunk_size -= 4;
return file.get_32();
2 years ago
func get_buffer(length):
chunk_size -= length;
return file.get_buffer(length);
2 years ago
func read_remaining():
get_buffer(chunk_size);
chunk_size = 0;
2 years ago
func get_string(length):
return get_buffer(length).get_string_from_ascii()
2 years ago
func get_vox_string():
var length = get_32();
return get_string(length);
2 years ago
func get_vox_dict():
var result = {};
var pairs = get_32();
for _p in range(pairs):
var key = get_vox_string();
var value = get_vox_string();
result[key] = value;
return result;