Class: WolfRpg::CommonEvents::Event

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(coder) ⇒ Event

Returns a new instance of Event.



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# File 'lib/wolfrpg/common_events.rb', line 46

def initialize(coder)
  if (indicator = coder.read_byte) != 0x8E
    raise "CommonEvent header indicator not 0x8E (got 0x#{indicator.to_s(16)})"
  end
  @id = coder.read_int
  @unknown1 = coder.read_int
  @unknown2 = coder.read(7)
  @name = coder.read_string
  @commands = Array.new(coder.read_int)
  @commands.each_index do |i|
    @commands[i] = Command.create(coder)
  end
  @unknown11 = coder.read_string
  @description = coder.read_string
  if (indicator = coder.read_byte) != 0x8F
    raise "CommonEvent data indicator not 0x8F (got 0x#{indicator.to_s(16)})"
  end
  coder.verify(MAGIC_NUMBER)
  @unknown3 = Array.new(10)
  @unknown3.each_index do |i|
    @unknown3[i] = coder.read_string
  end
  coder.verify(MAGIC_NUMBER)
  @unknown4 = Array.new(10)
  @unknown4.each_index do |i|
    @unknown4[i] = coder.read_byte
  end
  coder.verify(MAGIC_NUMBER)
  @unknown5 = Array.new(10)
  @unknown5.each_index do |i|
    @unknown5[i] = Array.new(coder.read_int)
    @unknown5[i].each_index do |j|
      @unknown5[i][j] = coder.read_string
    end
  end
  coder.verify(MAGIC_NUMBER)
  @unknown6 = Array.new(10)
  @unknown6.each_index do |i|
    @unknown6[i] = Array.new(coder.read_int)
    @unknown6[i].each_index do |j|
      @unknown6[i][j] = coder.read_int
    end
  end
  @unknown7 = coder.read(0x1D)
  @unknown8 = Array.new(100)
  @unknown8.each_index do |i|
    @unknown8[i] = coder.read_string
  end
  if (indicator = coder.read_byte) != 0x91
    raise "expected 0x91, got 0x#{indicator.to_s(16)}"
  end
  @unknown9 = coder.read_string
  return if (indicator = coder.read_byte) == 0x91
  unless indicator == 0x92
    raise "expected 0x92, got 0x#{indicator.to_s(16)}"
  end
  @unknown10 = coder.read_string
  @unknown12 = coder.read_int
  if (indicator = coder.read_byte) != 0x92
    raise "expected 0x92, got 0x#{indicator.to_s(16)}"
  end
end

Instance Attribute Details

#commandsObject

Returns the value of attribute commands.



44
45
46
# File 'lib/wolfrpg/common_events.rb', line 44

def commands
  @commands
end

#idObject

Returns the value of attribute id.



42
43
44
# File 'lib/wolfrpg/common_events.rb', line 42

def id
  @id
end

#nameObject

Returns the value of attribute name.



43
44
45
# File 'lib/wolfrpg/common_events.rb', line 43

def name
  @name
end

Instance Method Details

#dump(coder) ⇒ Object



109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
# File 'lib/wolfrpg/common_events.rb', line 109

def dump(coder)
  coder.write_byte(0x8E)
  coder.write_int(@id)
  coder.write_int(@unknown1)
  coder.write(@unknown2)
  coder.write_string(@name)
  coder.write_int(@commands.size)
  @commands.each do |cmd|
    cmd.dump(coder)
  end
  coder.write_string(@unknown11)
  coder.write_string(@description)
  coder.write_byte(0x8F)
  coder.write(MAGIC_NUMBER)
  @unknown3.each do |i|
    coder.write_string(i)
  end
  coder.write(MAGIC_NUMBER)
  @unknown4.each do |i|
    coder.write_byte(i)
  end
  coder.write(MAGIC_NUMBER)
  @unknown5.each do |i|
    coder.write_int(i.size)
    i.each do |j|
      coder.write_string(j)
    end
  end
  coder.write(MAGIC_NUMBER)
  @unknown6.each do |i|
    coder.write_int(i.size)
    i.each do |j|
      coder.write_int(j)
    end
  end
  coder.write(@unknown7)
  @unknown8.each do |i|
    coder.write_string(i)
  end
  coder.write_byte(0x91)
  coder.write_string(@unknown9)
  if @unknown10
    coder.write_byte(0x92)
    coder.write_string(@unknown10)
    coder.write_int(@unknown12)
    coder.write_byte(0x92)
  else
    coder.write_byte(0x91)
  end
end

#each_filenameObject



160
161
162
163
164
165
166
# File 'lib/wolfrpg/common_events.rb', line 160

def each_filename
  @commands.each do |command|
    command.each_filename do |fn|
      yield fn
    end
  end
end