00001 00008 /* 00009 This file is part of Teapot Colony Wars. 00010 00011 Teapot Colony Wars is free software: you can redistribute it and/or modify 00012 it under the terms of the GNU General Public License as published by 00013 the Free Software Foundation, either version 2 of the License, or 00014 (at your option) any later version. 00015 00016 Teapot Colony Wars is distributed in the hope that it will be useful, 00017 but WITHOUT ANY WARRANTY; without even the implied warranty of 00018 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00019 GNU General Public License for more details. 00020 00021 You should have received a copy of the GNU General Public License 00022 along with Teapot Colony Wars. If not, see <http://www.gnu.org/licenses/>. 00023 */ 00024 00025 #ifndef WORSHIPER_H 00026 #define WORSHIPER_H 00027 00028 #include <GL/glut.h> 00029 #include <list> 00030 00031 #include "Drawable.h" 00032 #include "Constants.h" 00033 #include "MoveCommand.h" 00034 00035 class Colony; 00036 class Behaviour; 00037 class Pheromone; 00038 class VisualContext; 00039 00043 class Worshiper : public Drawable 00044 { 00045 private: 00046 00047 friend class Colony; 00048 00052 move_command _last_command; 00053 00057 Worshiper(Behaviour * behaviourStrategy, Colony * colony, 00058 unsigned int size, unsigned int food); 00059 00060 protected: 00061 00063 Behaviour * _behaviourStrategy; 00064 00066 Colony * _colony; 00067 00069 VisualContext * _visualContext; 00070 00072 unsigned int _size; 00073 00075 unsigned int _food; 00076 00078 GLfloat m_tex_vector[4]; 00079 00083 void compute_tex_vector(); 00084 00085 public: 00086 00090 virtual ~Worshiper(); 00091 00097 inline Behaviour * getBehaviour() { 00098 return _behaviourStrategy; 00099 } 00100 00104 void think(); 00105 00113 move_command getAction(); 00114 00122 std::list<Pheromone*>* getPheromones() const; 00123 00129 inline move_command getLastAction() const { 00130 return _last_command; 00131 } 00132 00138 inline Colony * getColony() const { 00139 return _colony; 00140 } 00141 00145 virtual void draw(); 00146 00152 inline unsigned int getSize() const { 00153 return _size; 00154 } 00155 00161 void setFood(unsigned int new_var); 00162 00168 inline unsigned int getFood() const { 00169 return _food; 00170 } 00171 00177 bool subFood(); 00178 00184 inline unsigned int getCapacity() const { 00185 return (_size * CAPACITY_FACTOR); 00186 } 00187 00193 inline VisualContext* getVisualContext() const { 00194 return _visualContext; 00195 } 00196 00202 void setVisualContext(VisualContext * v); 00203 00207 void destroyVisualContext(); 00208 00214 inline Behaviour * getBehaviour() const { 00215 return _behaviourStrategy; 00216 } 00217 }; 00218 00219 #endif // WORSHIPER_H