Class: WolfRpg::Map::Event
- Inherits:
-
Object
- Object
- WolfRpg::Map::Event
- Defined in:
- lib/wolfrpg/map.rb
Defined Under Namespace
Classes: Page
Instance Attribute Summary collapse
-
#id ⇒ Object
Returns the value of attribute id.
-
#name ⇒ Object
Returns the value of attribute name.
-
#pages ⇒ Object
Returns the value of attribute pages.
-
#x ⇒ Object
Returns the value of attribute x.
-
#y ⇒ Object
Returns the value of attribute y.
Instance Method Summary collapse
- #dump(coder) ⇒ Object
- #each_filename ⇒ Object
-
#initialize(coder) ⇒ Event
constructor
A new instance of Event.
Constructor Details
#initialize(coder) ⇒ Event
Returns a new instance of Event.
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 |
# File 'lib/wolfrpg/map.rb', line 101 def initialize(coder) coder.verify(MAGIC_NUMBER1) @id = coder.read_int @name = coder.read_string @x = coder.read_int @y = coder.read_int @pages = Array.new(coder.read_int) coder.verify(MAGIC_NUMBER2) # Read pages page_id = 0 while (indicator = coder.read_byte) == 0x79 page = Page.new(coder, page_id) @pages[page_id] = page page_id += 1 end if indicator != 0x70 raise "unexpected event page indicator: #{indicator.to_s(16)}" end end |
Instance Attribute Details
#id ⇒ Object
Returns the value of attribute id.
95 96 97 |
# File 'lib/wolfrpg/map.rb', line 95 def id @id end |
#name ⇒ Object
Returns the value of attribute name.
96 97 98 |
# File 'lib/wolfrpg/map.rb', line 96 def name @name end |
#pages ⇒ Object
Returns the value of attribute pages.
99 100 101 |
# File 'lib/wolfrpg/map.rb', line 99 def pages @pages end |
#x ⇒ Object
Returns the value of attribute x.
97 98 99 |
# File 'lib/wolfrpg/map.rb', line 97 def x @x end |
#y ⇒ Object
Returns the value of attribute y.
98 99 100 |
# File 'lib/wolfrpg/map.rb', line 98 def y @y end |
Instance Method Details
#dump(coder) ⇒ Object
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 |
# File 'lib/wolfrpg/map.rb', line 122 def dump(coder) coder.write(MAGIC_NUMBER1) coder.write_int(@id) coder.write_string(@name) coder.write_int(@x) coder.write_int(@y) coder.write_int(@pages.size) coder.write(MAGIC_NUMBER2) # Write pages @pages.each do |page| coder.write_byte(0x79) page.dump(coder) end coder.write_byte(0x70) end |
#each_filename ⇒ Object
139 140 141 142 143 144 145 |
# File 'lib/wolfrpg/map.rb', line 139 def each_filename @pages.each do |page| page.each_filename do |fn| yield fn end end end |