Back to index

supertuxkart  0.5+dfsg1
collectable_manager.hpp
Go to the documentation of this file.
00001 //  $Id: collectable_manager.hpp 2111 2008-05-31 07:04:30Z cosmosninja $
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 HEADER_COLLECTABLEMANAGER_H
00021 #define HEADER_COLLECTABLEMANAGER_H
00022 
00023 #include "lisp/parser.hpp"
00024 #include "lisp/lisp.hpp"
00025 #include "btBulletDynamicsCommon.h"
00026 
00027 class Material;
00028 class ssgEntity;
00029 
00030 // The anvil and parachute must be at the end of the enum, and the
00031 // zipper just before them (see collectable::hitRedHerring).
00032 enum CollectableType {COLLECT_NOTHING,
00033                       COLLECT_MISSILE, COLLECT_HOMING,
00034                       COLLECT_SPARK, COLLECT_ZIPPER,
00035                       COLLECT_PARACHUTE, COLLECT_ANVIL,
00036                       COLLECT_MAX};
00037 
00038 class CollectableManager
00039 {
00040 protected:
00041     Material*    m_all_icons [COLLECT_MAX];
00042     float        m_all_max_distance[COLLECT_MAX];    // if a target is closer than this
00043     float        m_all_force_to_target[COLLECT_MAX]; // apply this force to move towards
00044                                                      // the target
00045     float        m_all_max_turn_angle[COLLECT_MAX];  // maximum turn angle for homing
00046     ssgEntity*   m_all_models[COLLECT_MAX];
00047     btVector3    m_all_extends[COLLECT_MAX];
00048     void         LoadNode       (const lisp::Lisp* lisp, int collectType);
00049 public:
00050     CollectableManager           ();
00051     void         loadCollectables();
00052     void         removeTextures  ();
00053     void         Load            (int collectType, const char* filename);
00054     Material*    getIcon         (int type) const {return m_all_icons [type];      }
00055     ssgEntity*   getModel        (int type) const {return m_all_models[type];      }
00056     float        getForceToTarget(int type) const {return m_all_force_to_target[type]; }
00057     float        getMaxDistance  (int type) const {return m_all_max_distance[type];}
00058     float        getMaxTurnAngle (int type) const {return m_all_max_turn_angle[type];}
00059     const btVector3& getExtend   (int type) const {return m_all_extends[type];     }
00060 };
00061 
00062 extern CollectableManager* collectable_manager;
00063 
00064 #endif