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.



149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
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
# File 'lib/wolfrpg/map.rb', line 149

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.



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

def collision_height
  @collision_height
end

#collision_widthObject

Returns the value of attribute collision_width.



146
147
148
# File 'lib/wolfrpg/map.rb', line 146

def collision_width
  @collision_width
end

#commandsObject

Returns the value of attribute commands.



144
145
146
# File 'lib/wolfrpg/map.rb', line 144

def commands
  @commands
end

#conditionsObject

Returns the value of attribute conditions.



139
140
141
# File 'lib/wolfrpg/map.rb', line 139

def conditions
  @conditions
end

#flagsObject

Returns the value of attribute flags.



141
142
143
# File 'lib/wolfrpg/map.rb', line 141

def flags
  @flags
end

#graphic_directionObject

Returns the value of attribute graphic_direction.



135
136
137
# File 'lib/wolfrpg/map.rb', line 135

def graphic_direction
  @graphic_direction
end

#graphic_frameObject

Returns the value of attribute graphic_frame.



136
137
138
# File 'lib/wolfrpg/map.rb', line 136

def graphic_frame
  @graphic_frame
end

#graphic_nameObject

Returns the value of attribute graphic_name.



134
135
136
# File 'lib/wolfrpg/map.rb', line 134

def graphic_name
  @graphic_name
end

#graphic_opacityObject

Returns the value of attribute graphic_opacity.



137
138
139
# File 'lib/wolfrpg/map.rb', line 137

def graphic_opacity
  @graphic_opacity
end

#graphic_render_modeObject

Returns the value of attribute graphic_render_mode.



138
139
140
# File 'lib/wolfrpg/map.rb', line 138

def graphic_render_mode
  @graphic_render_mode
end

#idObject

Returns the value of attribute id.



132
133
134
# File 'lib/wolfrpg/map.rb', line 132

def id
  @id
end

#movementObject

Returns the value of attribute movement.



140
141
142
# File 'lib/wolfrpg/map.rb', line 140

def movement
  @movement
end

#routeObject

Returns the value of attribute route.



143
144
145
# File 'lib/wolfrpg/map.rb', line 143

def route
  @route
end

#route_flagsObject

Returns the value of attribute route_flags.



142
143
144
# File 'lib/wolfrpg/map.rb', line 142

def route_flags
  @route_flags
end

#shadow_graphic_numObject

Returns the value of attribute shadow_graphic_num.



145
146
147
# File 'lib/wolfrpg/map.rb', line 145

def shadow_graphic_num
  @shadow_graphic_num
end

#unknown1Object

Returns the value of attribute unknown1.



133
134
135
# File 'lib/wolfrpg/map.rb', line 133

def unknown1
  @unknown1
end

Instance Method Details

#dump(coder) ⇒ Object



196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
# File 'lib/wolfrpg/map.rb', line 196

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