Back to index

supertuxkart  0.5+dfsg1
herring_manager.hpp
Go to the documentation of this file.
00001 //  $Id: herring_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_HERRINGMANAGER_H
00021 #define HEADER_HERRINGMANAGER_H
00022 
00023 
00024 #include <vector>
00025 #include <map>
00026 #include "herring.hpp"
00027 #include "lisp/lisp.hpp"
00028 
00029 class Kart;
00030 class ssgEntity;
00031 
00032 class HerringManager
00033 {
00034 
00035 private:
00036     // The vector of all herrings of the current track
00037     typedef std::vector<Herring*> AllHerringType;
00038     AllHerringType m_all_herrings;
00039 
00040     // This stores all herring models defined in the models/herring
00041     // subdirectory.
00042     ssgEntity *m_herring_model[HE_SILVER+1];
00043 
00044     // This is the active model. It gets determined by first loading the
00045     // default, then track models, user models, cup models. This means, that
00046     // a herring style specified in a track overwrites a command line option.
00047     std::map<std::string,ssgEntity*> m_all_models;
00048 
00049     std::string m_user_filename;
00050     void CreateDefaultHerring(sgVec3 colour, std::string name);
00051     void setDefaultHerringStyle();
00052     void setHerring(const lisp::Lisp *herring_node, const char *colour,
00053                     herringType type);
00054 
00055 public:
00056     HerringManager();
00057     ~HerringManager();
00058     void        loadDefaultHerrings();
00059     void        loadHerringStyle(const std::string filename);
00060     Herring*    newHerring      (herringType type, sgVec3* xyz);
00061     void        update          (float delta);
00062     void        hitHerring      (Kart* kart);
00063     void        cleanup         ();
00064     void        reset           ();
00065     void        removeTextures  ();
00066     void        setUserFilename (char *s) {m_user_filename=s;}
00067     ssgEntity*  getHerringModel (herringType type)
00068                                 {return m_herring_model[type];}
00069 };
00070 
00071 extern HerringManager* herring_manager;
00072 
00073 
00074 #endif