Class: WolfRpg::Map::Event::Page

Inherits:
Object
  • Object
show all
Defined in:
lib/wolfrpg/map.rb

Constant Summary collapse

COMMANDS_TERMINATOR =
[
  0x03, 0x00, 0x00, 0x00,
].pack('C*')

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(coder, id) ⇒ Page

Returns a new instance of Page.



165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
# File 'lib/wolfrpg/map.rb', line 165

def initialize(coder, id)
  @id = id

  #TODO ???
  @unknown1 = coder.read_int

  #TODO further abstract graphics options
  @graphic_name = coder.read_string
  @graphic_direction = coder.read_byte
  @graphic_frame = coder.read_byte
  @graphic_opacity = coder.read_byte
  @graphic_render_mode = coder.read_byte

  #TODO parse conditions later
  @conditions = coder.read(1 + 4 + 4*4 + 4*4)
  #TODO parse movement options later
  @movement = coder.read(4)

  #TODO further abstract flags
  @flags = coder.read_byte

  #TODO further abstract flags
  @route_flags = coder.read_byte

  # Parse move route
  @route = Array.new(coder.read_int)
  @route.each_index do |i|
    @route[i] = RouteCommand.create(coder)
  end

  # Parse commands
  @commands = Array.new(coder.read_int)
  @commands.each_index do |i|
    @commands[i] = Command.create(coder)
  end
  coder.verify(COMMANDS_TERMINATOR)

  #TODO abstract these options later
  @shadow_graphic_num = coder.read_byte
  @collision_width = coder.read_byte
  @collision_height = coder.read_byte

  if (terminator = coder.read_byte) != 0x7A
    raise "page terminator not 7A (found #{terminator.to_s(16)})"
  end
end

Instance Attribute Details

#collision_heightObject

Returns the value of attribute collision_height.



163
164
165
# File 'lib/wolfrpg/map.rb', line 163

def collision_height
  @collision_height
end

#collision_widthObject

Returns the value of attribute collision_width.



162
163
164
# File 'lib/wolfrpg/map.rb', line 162

def collision_width
  @collision_width
end

#commandsObject

Returns the value of attribute commands.



160
161
162
# File 'lib/wolfrpg/map.rb', line 160

def commands
  @commands
end

#conditionsObject

Returns the value of attribute conditions.



155
156
157
# File 'lib/wolfrpg/map.rb', line 155

def conditions
  @conditions
end

#flagsObject

Returns the value of attribute flags.



157
158
159
# File 'lib/wolfrpg/map.rb', line 157

def flags
  @flags
end

#graphic_directionObject

Returns the value of attribute graphic_direction.



151
152
153
# File 'lib/wolfrpg/map.rb', line 151

def graphic_direction
  @graphic_direction
end

#graphic_frameObject

Returns the value of attribute graphic_frame.



152
153
154
# File 'lib/wolfrpg/map.rb', line 152

def graphic_frame
  @graphic_frame
end

#graphic_nameObject

Returns the value of attribute graphic_name.



150
151
152
# File 'lib/wolfrpg/map.rb', line 150

def graphic_name
  @graphic_name
end

#graphic_opacityObject

Returns the value of attribute graphic_opacity.



153
154
155
# File 'lib/wolfrpg/map.rb', line 153

def graphic_opacity
  @graphic_opacity
end

#graphic_render_modeObject

Returns the value of attribute graphic_render_mode.



154
155
156
# File 'lib/wolfrpg/map.rb', line 154

def graphic_render_mode
  @graphic_render_mode
end

#idObject

Returns the value of attribute id.



148
149
150
# File 'lib/wolfrpg/map.rb', line 148

def id
  @id
end

#movementObject

Returns the value of attribute movement.



156
157
158
# File 'lib/wolfrpg/map.rb', line 156

def movement
  @movement
end

#routeObject

Returns the value of attribute route.



159
160
161
# File 'lib/wolfrpg/map.rb', line 159

def route
  @route
end

#route_flagsObject

Returns the value of attribute route_flags.



158
159
160
# File 'lib/wolfrpg/map.rb', line 158

def route_flags
  @route_flags
end

#shadow_graphic_numObject

Returns the value of attribute shadow_graphic_num.



161
162
163
# File 'lib/wolfrpg/map.rb', line 161

def shadow_graphic_num
  @shadow_graphic_num
end

#unknown1Object

Returns the value of attribute unknown1.



149
150
151
# File 'lib/wolfrpg/map.rb', line 149

def unknown1
  @unknown1
end

Instance Method Details

#dump(coder) ⇒ Object



212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
# File 'lib/wolfrpg/map.rb', line 212

def dump(coder)
  coder.write_int(@unknown1)
  coder.write_string(@graphic_name)
  coder.write_byte(@graphic_direction)
  coder.write_byte(@graphic_frame)
  coder.write_byte(@graphic_opacity)
  coder.write_byte(@graphic_render_mode)
  coder.write(@conditions)
  coder.write(@movement)
  coder.write_byte(@flags)
  coder.write_byte(@route_flags)
  coder.write_int(@route.size)
  @route.each do |cmd|
    cmd.dump(coder)
  end
  coder.write_int(@commands.size)
  @commands.each do |cmd|
    cmd.dump(coder)
  end
  coder.write(COMMANDS_TERMINATOR)
  coder.write_byte(@shadow_graphic_num)
  coder.write_byte(@collision_width)
  coder.write_byte(@collision_height)
  coder.write_byte(0x7A)
end

#each_filename {|@graphic_name.gsub('\\', '/')| ... } ⇒ Object

Yields:



238
239
240
241
242
243
244
245
# File 'lib/wolfrpg/map.rb', line 238

def each_filename
  yield @graphic_name.gsub('\\', '/') unless @graphic_name.empty?
  @commands.each do |command|
    command.each_filename do |fn|
      yield fn
    end
  end
end