Class: Table

Inherits:
Object
  • Object
show all
Defined in:
lib/R3EXS/RGSS3.rb

Overview

RPG Maker VX Ace Table 类

Table 是一个多维数组,每个元素都是带符号的两字节整数(int16_t), 也就是 -32,768~32,767 之间的整数

Ruby Array 类在处理大量信息时效率很差,因此使用了此类。

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#dataObject

Returns the value of attribute data.



84
85
86
# File 'lib/R3EXS/RGSS3.rb', line 84

def data
  @data
end

#dimObject

Returns the value of attribute dim.



84
85
86
# File 'lib/R3EXS/RGSS3.rb', line 84

def dim
  @dim
end

#xsizeObject

Returns the value of attribute xsize.



84
85
86
# File 'lib/R3EXS/RGSS3.rb', line 84

def xsize
  @xsize
end

#ysizeObject

Returns the value of attribute ysize.



84
85
86
# File 'lib/R3EXS/RGSS3.rb', line 84

def ysize
  @ysize
end

#zsizeObject

Returns the value of attribute zsize.



84
85
86
# File 'lib/R3EXS/RGSS3.rb', line 84

def zsize
  @zsize
end

Class Method Details

._load(obj) ⇒ Table

反序列化 Table 对象

Parameters:

  • obj (String)

    序列化后的字符串

Returns:



103
104
105
106
107
108
109
110
111
112
# File 'lib/R3EXS/RGSS3.rb', line 103

def self._load(obj)
  dim, xsize, ysize, zsize, total_size, *data = obj.unpack('L5s*')
  instance = allocate
  instance.dim = dim
  instance.xsize = xsize
  instance.ysize = ysize
  instance.zsize = zsize
  instance.data = data.first(total_size)
  instance
end

Instance Method Details

#_dump(_level) ⇒ String

序列化 Table 对象

Returns:



93
94
95
96
# File 'lib/R3EXS/RGSS3.rb', line 93

def _dump(_level)
  total = @xsize * @ysize * @zsize
  [@dim, @xsize, @ysize, @zsize, total].pack('L5') + @data.pack('s*')
end