A Bif object encapsulates an open file handle pointing to a .bif file. It’s contents are indexed on first access, not on creation by NWN::Key::Key (to speed up things).
Attributes
Public class methods
new
(key, io)
[show source]
# File lib/nwn/key.rb, line 19 19: def initialize key, io 20: @key = key 21: @io = io 22: 23: @contained = {} 24: 25: @file_type, @file_version, 26: @var_res_count, @fix_res_count, 27: @var_table_offset = 28: io.e_read(4 + 4 + 3 * 4, "header").unpack("a4 a4 V V V") 29: 30: @io.seek(@var_table_offset) 31: data = @io.e_read(@var_res_count * 16, "var res table") 32: i = 0 33: while (x = data[i, 16]) && x.size == 16 34: i += 16 35: id, offset, size, restype = x.unpack("V V V V") 36: id &= 0xfffff 37: @contained[id] = [offset, size, restype] 38: end 39: end
Public instance methods
get_res_id
(id)
[show source]
# File lib/nwn/key.rb, line 45 45: def get_res_id id 46: offset, size, restype = @contained[id] 47: @io.seek(offset) 48: @io.e_read(size, "resource #{id} of type #{restype}") 49: end
has_res_id?
(id)
[show source]
# File lib/nwn/key.rb, line 41 41: def has_res_id? id 42: @contained[id] != nil 43: end