1285 |
public: |
public: |
1286 |
FartStone() : Stone("st-fart"), state(IDLE) {} |
FartStone() : Stone("st-fart"), state(IDLE) {} |
1287 |
private: |
private: |
1288 |
enum State { IDLE, FARTING, BROKEN }; |
enum State { IDLE, FARTING, BREAKING }; |
1289 |
State state; |
State state; |
1290 |
|
|
1291 |
void fart() { |
void change_state(State newstate) { |
1292 |
if (state == IDLE) { |
if (state == newstate) |
1293 |
Object *ox = world::GetObjectTemplate("st-oxyd"); |
return; |
1294 |
SendMessage(ox, "closeall"); |
|
1295 |
play_sound("fart"); |
switch (newstate) { |
1296 |
set_anim("st-farting"); |
case IDLE: |
1297 |
state = FARTING; |
state = IDLE; |
1298 |
|
init_model(); |
1299 |
|
break; |
1300 |
|
case FARTING: |
1301 |
|
case BREAKING: |
1302 |
|
if (state == IDLE) { |
1303 |
|
Object *ox = world::GetObjectTemplate("st-oxyd"); |
1304 |
|
SendMessage(ox, "closeall"); |
1305 |
|
play_sound("fart"); |
1306 |
|
set_anim(newstate == FARTING ? "st-farting" : "st-fartbreak-anim"); |
1307 |
|
state = newstate; |
1308 |
|
} |
1309 |
|
break; |
1310 |
} |
} |
1311 |
} |
} |
|
void destroy() { |
|
1312 |
|
|
|
} |
|
1313 |
void animcb() { |
void animcb() { |
1314 |
if (state == FARTING) { |
if (state == FARTING) { |
1315 |
state = IDLE; |
change_state(IDLE); |
1316 |
init_model(); |
} |
1317 |
|
else if (state == BREAKING) { |
1318 |
|
KillStone(get_pos()); |
1319 |
} |
} |
1320 |
} |
} |
1321 |
|
|
1322 |
void actor_hit(const StoneContact &sc) { |
void actor_hit(const StoneContact &sc) { |
1323 |
if (wielded_item_is(sc.actor, "it-hammer")) { |
if (wielded_item_is(sc.actor, "it-hammer")) |
1324 |
// ### What we really want is either a broken "fart" |
change_state(BREAKING); |
1325 |
// ### stone or an animation |
else |
1326 |
KillStone(get_pos()); |
change_state(FARTING); |
|
} else { |
|
|
fart(); |
|
|
} |
|
1327 |
} |
} |
1328 |
void message(const string &m, const Value &) { |
void message(const string &m, const Value &) { |
1329 |
if (m=="trigger") |
if (m=="trigger") |
1330 |
fart(); |
change_state(FARTING); |
1331 |
|
else if (m == "ignite" || m == "expl") |
1332 |
|
change_state(BREAKING); |
1333 |
|
} |
1334 |
|
|
1335 |
|
bool on_laserhit(Direction) { |
1336 |
|
change_state(BREAKING); |
1337 |
|
return false; |
1338 |
} |
} |
1339 |
}; |
}; |
1340 |
} |
} |