/[enigma]/enigma/src/stones_simple.cc
ViewVC logotype

Diff of /enigma/src/stones_simple.cc

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.15 by reallysoft, Fri Jun 20 22:29:19 2003 UTC revision 1.16 by reallysoft, Sat Jun 21 09:55:03 2003 UTC
# Line 1285  namespace Line 1285  namespace
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  }  }

Legend:
Removed from v.1.15  
changed lines
  Added in v.1.16

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26