2162 |
public: |
public: |
2163 |
StoneImpulseStone() : Stone("st-stoneimpulse"), state(IDLE) {} |
StoneImpulseStone() : Stone("st-stoneimpulse"), state(IDLE) {} |
2164 |
private: |
private: |
2165 |
enum State { IDLE, PULSING, BROKEN }; |
enum State { IDLE, PULSING, CLOSING, BROKEN }; |
2166 |
State state; |
State state; |
2167 |
|
|
2168 |
void stoneimpulse() { |
void stoneimpulse() { |
2169 |
if (state == IDLE) { |
if (state == IDLE) { |
2170 |
// sound::PlaySound("stoneimpulse"); |
// sound::PlaySound("stoneimpulse"); |
2171 |
set_anim("st-stoneimpulse-anim"); |
set_anim("st-stoneimpulse-anim1"); |
2172 |
state = PULSING; |
state = PULSING; |
2173 |
MaybeMoveStone( move( get_pos(), NORTH), NORTH); |
GridPos p = get_pos(); |
2174 |
MaybeMoveStone( move( get_pos(), EAST), EAST); |
MaybeMoveStone( move( p, NORTH), NORTH); |
2175 |
MaybeMoveStone( move( get_pos(), SOUTH), SOUTH); |
MaybeMoveStone( move( p, EAST), EAST); |
2176 |
MaybeMoveStone( move( get_pos(), WEST), WEST); |
MaybeMoveStone( move( p, SOUTH), SOUTH); |
2177 |
|
MaybeMoveStone( move( p, WEST), WEST); |
2178 |
} |
} |
2179 |
} |
} |
2180 |
void animcb() { |
void animcb() { |
2181 |
if (state == PULSING) { |
if (state == PULSING) { |
2182 |
|
state = CLOSING; |
2183 |
|
GridPos p = get_pos(); |
2184 |
|
Stone *st; |
2185 |
|
st = GetStone(move(p, NORTH)); |
2186 |
|
if( st) |
2187 |
|
SendMessage(st, "stoneimpulse"); |
2188 |
|
st = GetStone(move(p, EAST)); |
2189 |
|
if( st) |
2190 |
|
SendMessage(st, "stoneimpulse"); |
2191 |
|
st = GetStone(move(p, SOUTH)); |
2192 |
|
if( st) |
2193 |
|
SendMessage(st, "stoneimpulse"); |
2194 |
|
st = GetStone(move(p, WEST)); |
2195 |
|
if( st) |
2196 |
|
SendMessage(st, "stoneimpulse"); |
2197 |
|
set_anim("st-stoneimpulse-anim2"); |
2198 |
|
} else if (state == CLOSING) { |
2199 |
state = IDLE; |
state = IDLE; |
2200 |
init_model(); |
init_model(); |
2201 |
} |
} |
2208 |
void message(const string &m, const Value &) { |
void message(const string &m, const Value &) { |
2209 |
if (m=="trigger") |
if (m=="trigger") |
2210 |
stoneimpulse(); |
stoneimpulse(); |
2211 |
|
if (m=="stoneimpulse") |
2212 |
|
stoneimpulse(); |
2213 |
} |
} |
2214 |
}; |
}; |
2215 |
} |
} |