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

Diff of /enigma/src/items.cc

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

revision 1.87.2.1 by dheck, Fri Sep 19 17:41:38 2003 UTC revision 1.87.2.2 by dheck, Mon Sep 22 02:46:22 2003 UTC
# Line 492  Hollow::check_if_level_finished() Line 492  Hollow::check_if_level_finished()
492      for (unsigned i=0; i<size; ++i) {      for (unsigned i=0; i<size; ++i) {
493          Hollow *h = static_cast<Hollow*> (instances[i]);          Hollow *h = static_cast<Hollow*> (instances[i]);
494          if (!h->whiteball || SDL_GetTicks() - h->enter_time < MINTIME)          if (!h->whiteball || SDL_GetTicks() - h->enter_time < MINTIME)
495              return;              continue;
496          else          else
497              ++cnt;              ++cnt;
498      }      }
# Line 636  namespace Line 636  namespace
636  }  }
637    
638  Explosion::Explosion(Strength st)  Explosion::Explosion(Strength st)
639      : Item("it-explosion"), strength(st)  : Item("it-explosion"), strength(st)
640  {}  {}
641    
642    
643  void  void Explosion::animcb()
 Explosion::animcb()  
644  {  {
645      switch (strength) {      switch (strength) {
646      case WEAK:      case WEAK:
# Line 656  Explosion::animcb() Line 655  Explosion::animcb()
655          SetItem(get_pos(), MakeItem("it-debris"));          SetItem(get_pos(), MakeItem("it-debris"));
656          break;          break;
657      }      }
   
658  }  }
659    
660    
# Line 915  namespace Line 913  namespace
913      class Trigger : public Item {      class Trigger : public Item {
914          CLONEOBJ(Trigger);          CLONEOBJ(Trigger);
915      public:      public:
916          Trigger() : Item("it-trigger"), objectcnt(0), have_pressure(false) {          Trigger();
             set_attrib("invisible", 0.0);  
         }  
917      private:      private:
918          int  objectcnt;         // number of objects on the trigger          // Variables
919          bool have_pressure;          bool m_pressedp;
920            int m_actorcount;
         bool actor_hit(Actor */*a*/) { return false; }  
921    
922            // Methods
923            void update_state();
924    
925          void init_model() {          // Item interface
926              if (int_attrib("invisible"))          void init_model();
927                  set_model("invisible");          bool actor_hit (Actor *) { return false; }
928              else if (objectcnt > 0)          void actor_enter(Actor *) { m_actorcount += 1; update_state(); }
929                  set_model("it-trigger1");          void actor_leave(Actor *) { m_actorcount -= 1; update_state(); }
930              else          void stone_change(Stone *st) { update_state(); }
931                  set_model("it-trigger");      };
932          }  }
933    
934          void add_object() {  Trigger::Trigger() : Item("it-trigger")
935              if (++objectcnt == 1) {  {
936                  init_model();      m_pressedp = false;
937                  world::PerformAction(this, true);      m_actorcount = 0;
938                  play_sound("it-triggerdown");      set_attrib("invisible", 0.0);
939              }  }
         }  
         void remove_object() {  
             if (--objectcnt == 0) {  
                 init_model();  
                 world::PerformAction(this, false);  
                 play_sound("it-triggerup");  
             }  
         }  
940    
941          void actor_enter(Actor *) {  void Trigger::init_model()
942              add_object();  {
943          }      if (int_attrib("invisible"))
944          void actor_leave(Actor *) {          set_model("invisible");
945              remove_object();      else if (m_pressedp)
946          }          set_model("it-trigger1");
947          void stone_change(Stone *st);      else
948      };          set_model("it-trigger");
949  }  }
950    
951  void  void Trigger::update_state()
 Trigger::stone_change(Stone *st)  
952  {  {
953      bool get_pressure = st && !st->is_floating();      Stone *st = GetStone(get_pos());
954        bool stone_pressure = st && !st->is_floating();
955        bool pressedp = stone_pressure || (m_actorcount > 0);
956    
957      if (get_pressure != have_pressure) {      if (m_pressedp != pressedp) {
958          if (get_pressure)   add_object();          m_pressedp = pressedp;
959          else                remove_object();  
960          have_pressure = get_pressure;          if (m_pressedp) {
961                world::PerformAction(this, true);
962                play_sound("it-triggerdown");
963            } else {
964                world::PerformAction(this, false);
965                play_sound("it-triggerup");
966            }
967            init_model();
968      }      }
969  }  }
970    
971    
972  //----------------------------------------  //----------------------------------------
973  // Seed  // Seed
974  //----------------------------------------  //----------------------------------------
# Line 1570  namespace Line 1568  namespace
1568      public:      public:
1569          Pipe(const char *kind, ItemID id) : Item(kind), m_id(id) {}          Pipe(const char *kind, ItemID id) : Item(kind), m_id(id) {}
1570          int get_id() const { return m_id; }          int get_id() const { return m_id; }
1571    
1572            void message(const string &msg, const Value &/*val*/) {
1573                if (msg == "expl")
1574                    SetItem (get_pos(), MakeItem("it-explosion1"));
1575            }
1576      };      };
1577  }  }
1578    

Legend:
Removed from v.1.87.2.1  
changed lines
  Added in v.1.87.2.2

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