Back to index

supertuxkart  0.5+dfsg1
callback_manager.hpp
Go to the documentation of this file.
00001 //  $Id: callback_manager.hpp 796 2006-09-27 07:06:34Z hiker $
00002 //
00003 //  SuperTuxKart - a fun racing game with go-kart
00004 //  Copyright (C) 2006 Joerg Henrichs
00005 //
00006 //  This program is free software; you can redistribute it and/or
00007 //  modify it under the terms of the GNU General Public License
00008 //  as published by the Free Software Foundation; either version 2
00009 //  of the License, or (at your option) any later version.
00010 //
00011 //  This program is distributed in the hope that it will be useful,
00012 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 //  GNU General Public License for more details.
00015 //
00016 //  You should have received a copy of the GNU General Public License
00017 //  along with this program; if not, write to the Free Software
00018 //  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00019 
00020 #ifndef CALLBACK_MANAGER_H
00021 #define CALLBACK_MANAGER_H
00022 
00023 #include <vector>
00024 #include "btBulletDynamicsCommon.h"
00025 #include "callback.hpp"
00026 #include "moving_physics.hpp"
00027 
00028 // It might actually be enough to have only two different values: track (which
00029 // get deleted and loaded more than one), and everything else, which only
00030 // gets loaded once, and deleted at the end (and when switching windows /
00031 // fullscreen). Sinace it's not much overhead, a separate class is provided
00032 // for every model that might contain a callback.
00033 enum CallbackType { CB_COLLECTABLE, CB_ATTACHMENT, CB_EXPLOSION, CB_HERRING,
00034                     CB_KART,        CB_TRACK,      CB_MAX                    };
00035 
00036 class CallbackManager
00037 {
00038     std::vector<Callback*> m_allCallbacks[CB_MAX];
00039 
00040 public:
00041          CallbackManager();
00042         ~CallbackManager();
00043     void update         (float dt) const;
00044     void initAll        () const;
00045     void reset          () const;
00046     void clear          (CallbackType cbType);
00047     void addCallback    (Callback *c, CallbackType t);
00048     void handleExplosion(const btVector3& pos, const MovingPhysics* mo) const;
00049 }
00050 ;   // CallbackManager
00051 
00052 extern CallbackManager *callback_manager;
00053 
00054 #endif
00055 /* EOF */
00056