src/tron/zone/zSelector.h

Go to the documentation of this file.
00001 /*
00002 
00003 *************************************************************************
00004 
00005 ArmageTron -- Just another Tron Lightcycle Game in 3D.
00006 Copyright (C) 2000  Manuel Moos (manuel@moosnet.de)
00007 
00008 **************************************************************************
00009 
00010 This program is free software; you can redistribute it and/or
00011 modify it under the terms of the GNU General Public License
00012 as published by the Free Software Foundation; either version 2
00013 of the License, or (at your option) any later version.
00014 
00015 This program is distributed in the hope that it will be useful,
00016 but WITHOUT ANY WARRANTY; without even the implied warranty of
00017 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018 GNU General Public License for more details.
00019 
00020 You should have received a copy of the GNU General Public License
00021 along with this program; if not, write to the Free Software
00022 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
00023   
00024 ***************************************************************************
00025 
00026 */
00027 
00028 #ifndef ARMAGETRONAD_H_SELECTOR
00029 #define ARMAGETRONAD_H_SELECTOR
00030 
00031 class gCycle;
00032 #include <vector>
00033 #include <boost/shared_ptr.hpp>
00034 #include "gVectorExtra.h"
00035 #include "ePlayer.h"
00036 #include "gCycle.h"
00037 #include "eTeam.h"
00038 #include "zMisc.h"
00039 
00040 class zEffector;
00041 
00042 typedef boost::shared_ptr<zEffector> zEffectorPtr;
00043 typedef std::vector< zEffectorPtr >  zEffectorPtrs;
00044 
00045 enum LivingStatus {
00046     _either, // Any player should be considered
00047     _alive,  // A player that has a working vehicule
00048     _dead    // A player without a working vehicule
00049 };
00050 
00051 class zSelector
00052 {
00053 public:
00054     static zSelector* create();
00055     zSelector(); //<! Constructor
00056     zSelector(zSelector const &other);
00057     void operator=(zSelector const &other); 
00058     virtual zSelector *copy(void) const;
00059     virtual ~zSelector() {};
00060 
00061     void apply(gVectorExtra< nNetObjectID > &owners, gVectorExtra< nNetObjectID > &teamOwners, gCycle * triggerer);
00062     void setCount(int _count) {count = _count;};
00063 
00064     void addEffector(zEffectorPtr newEffector) {effectors.push_back( newEffector );};
00065 protected:
00066     virtual gVectorExtra<ePlayerNetID *> select(gVectorExtra< nNetObjectID > &owners, gVectorExtra< nNetObjectID > &teamOwners, gCycle * triggerer);
00067 protected:
00068     zEffectorPtrs effectors;
00069     int count;
00070 
00071     template <typename T>
00072     T pickOne(std::vector <T> const &sources);
00073 
00074     std::vector <ePlayerNetID *>
00075     getAllValid(std::vector <ePlayerNetID *> &results, std::vector <ePlayerNetID *> const &sources, LivingStatus living);
00076 };
00077 
00078 
00079 /*
00080  *
00081  */
00082 class zSelectorSelf : public zSelector
00083 {
00084 public:
00085     static zSelector* create();
00086     zSelectorSelf(); //<! Constructor
00087     zSelectorSelf(zSelectorSelf const &other);
00088     void operator=(zSelectorSelf const &other); 
00089     virtual zSelectorSelf *copy(void) const;
00090     virtual ~zSelectorSelf() {};
00091 
00092     gVectorExtra<ePlayerNetID *> select(gVectorExtra< nNetObjectID > &owners, gVectorExtra< nNetObjectID > &teamOwners, gCycle * triggerer);
00093 };
00094 
00095 /*
00096  *
00097  */
00098 class zSelectorTeammate : public zSelector
00099 {
00100 public:
00101     static zSelector* create();
00102     zSelectorTeammate(); //<! Constructor
00103     zSelectorTeammate(zSelectorTeammate const &other);
00104     void operator=(zSelectorTeammate const &other); 
00105     virtual zSelectorTeammate *copy(void) const;
00106     virtual ~zSelectorTeammate() {};
00107 
00108     gVectorExtra<ePlayerNetID *> select(gVectorExtra< nNetObjectID > &owners, gVectorExtra< nNetObjectID > &teamOwners, gCycle * triggerer);
00109 };
00110 
00111 /*
00112  *
00113  */
00114 class zSelectorTeam : public zSelector
00115 {
00116 public:
00117     static zSelector* create();
00118     zSelectorTeam(); //<! Constructor
00119     zSelectorTeam(zSelectorTeam const &other);
00120     void operator=(zSelectorTeam const &other); 
00121     virtual zSelectorTeam *copy(void) const;
00122     virtual ~zSelectorTeam() {};
00123 
00124     gVectorExtra<ePlayerNetID *> select(gVectorExtra< nNetObjectID > &owners, gVectorExtra< nNetObjectID > &teamOwners, gCycle * triggerer);
00125 };
00126 
00127 /*
00128  *
00129  */
00130 class zSelectorAll : public zSelector
00131 {
00132 public:
00133     static zSelector* create();
00134     zSelectorAll(); //<! Constructor
00135     zSelectorAll(zSelectorAll const &other);
00136     void operator=(zSelectorAll const &other); 
00137     virtual zSelectorAll *copy(void) const;
00138     virtual ~zSelectorAll() {};
00139 
00140     gVectorExtra<ePlayerNetID *> select(gVectorExtra< nNetObjectID > &owners, gVectorExtra< nNetObjectID > &teamOwners, gCycle * triggerer);
00141 };
00142 
00143 /*
00144  *
00145  */
00146 class zSelectorAllButSelf : public zSelector
00147 {
00148 public:
00149     static zSelector* create();
00150     zSelectorAllButSelf(); //<! Constructor
00151     zSelectorAllButSelf(zSelectorAllButSelf const &other);
00152     void operator=(zSelectorAllButSelf const &other); 
00153     virtual zSelectorAllButSelf *copy(void) const;
00154     virtual ~zSelectorAllButSelf() {};
00155 
00156     gVectorExtra<ePlayerNetID *> select(gVectorExtra< nNetObjectID > &owners, gVectorExtra< nNetObjectID > &teamOwners, gCycle * triggerer);
00157 };
00158 
00159 /*
00160  *
00161  */
00162 /*
00163 class zSelectorAllButTeam : public zSelector
00164 { 
00165  public: 
00166   static zSelector* create();
00167   zSelectorAllButTeam(); //<! Constructor
00168   zSelectorAllButTeam(zSelectorAllButTeam const &other);
00169   void operator=(zSelectorAllButTeam const &other); //!< overloaded assignment operator
00170   virtual zSelectorAllButTeam *copy(void) const;
00171   virtual ~zSelectorAllButTeam() {};
00172 
00173   gVectorExtra<ePlayerNetID *> select(gVectorExtra< nNetObjectID > &owners, gVectorExtra< nNetObjectID > &teamOwners, gCycle * triggerer);
00174 };
00175 */
00176 
00177 /*
00178  *
00179  */
00180 class zSelectorAnother : public zSelector
00181 {
00182 public:
00183     static zSelector* create();
00184     zSelectorAnother(); //<! Constructor
00185     zSelectorAnother(zSelectorAnother const &other);
00186     void operator=(zSelectorAnother const &other); 
00187     virtual zSelectorAnother *copy(void) const;
00188     virtual ~zSelectorAnother() {};
00189 
00190     gVectorExtra<ePlayerNetID *> select(gVectorExtra< nNetObjectID > &owners, gVectorExtra< nNetObjectID > &teamOwners, gCycle * triggerer);
00191 };
00192 
00193 
00194 /*
00195 zSelectorAnotherTeam::create;
00196 zSelectorAnotherTeammate::create;
00197 zSelectorAnotherNotTeammate::create;
00198 */
00199 
00200 /*
00201  *
00202  */
00203 class zSelectorOwner : public zSelector
00204 {
00205 public:
00206     static zSelector* create();
00207     zSelectorOwner(); //<! Constructor
00208     zSelectorOwner(zSelectorOwner const &other);
00209     void operator=(zSelectorOwner const &other); 
00210     virtual zSelectorOwner *copy(void) const;
00211     virtual ~zSelectorOwner() {};
00212 
00213     gVectorExtra<ePlayerNetID *> select(gVectorExtra< nNetObjectID > &owners, gVectorExtra< nNetObjectID > &teamOwners, gCycle * triggerer);
00214 };
00215 
00216 /*
00217  *
00218  */
00219 class zSelectorOwnerTeam : public zSelector
00220 {
00221 public:
00222     static zSelector* create();
00223     zSelectorOwnerTeam(); //<! Constructor
00224     zSelectorOwnerTeam(zSelectorOwnerTeam const &other);
00225     void operator=(zSelectorOwnerTeam const &other); 
00226     virtual zSelectorOwnerTeam *copy(void) const;
00227     virtual ~zSelectorOwnerTeam() {};
00228 
00229     gVectorExtra<ePlayerNetID *> select(gVectorExtra< nNetObjectID > &owners, gVectorExtra< nNetObjectID > &teamOwners, gCycle * triggerer);
00230 };
00231 
00232 
00233 
00234 /*
00235  *
00236  */
00237 
00238 
00239 class zSelectorOwnerTeamTeammate : public zSelector
00240 {
00241 public:
00242     static zSelector* create();
00243     zSelectorOwnerTeamTeammate(); //<! Constructor
00244     zSelectorOwnerTeamTeammate(zSelectorOwnerTeamTeammate const &other);
00245     void operator=(zSelectorOwnerTeamTeammate const &other); 
00246     virtual zSelectorOwnerTeamTeammate *copy(void) const;
00247     virtual ~zSelectorOwnerTeamTeammate() {};
00248 
00249     gVectorExtra<ePlayerNetID *> select(gVectorExtra< nNetObjectID > &owners, gVectorExtra< nNetObjectID > &teamOwners, gCycle * triggerer);
00250 };
00251 
00252 /*
00253  *
00254  */
00255 
00256 class zSelectorAnyDead : public zSelector
00257 {
00258 public:
00259     static zSelector* create();
00260     zSelectorAnyDead(); //<! Constructor
00261     zSelectorAnyDead(zSelectorAnyDead const &other);
00262     void operator=(zSelectorAnyDead const &other); 
00263     virtual zSelectorAnyDead *copy(void) const;
00264     virtual ~zSelectorAnyDead() {};
00265 
00266     gVectorExtra<ePlayerNetID *> select(gVectorExtra< nNetObjectID > &owners, gVectorExtra< nNetObjectID > &teamOwners, gCycle * triggerer);
00267 };
00268 
00269 /*
00270  *
00271  */
00272 
00273 class zSelectorAllDead : public zSelector
00274 {
00275 public:
00276     static zSelector* create();
00277     zSelectorAllDead(); //<! Constructor
00278     zSelectorAllDead(zSelectorAllDead const &other);
00279     void operator=(zSelectorAllDead const &other); 
00280     virtual zSelectorAllDead *copy(void) const;
00281     virtual ~zSelectorAllDead() {};
00282 
00283     gVectorExtra<ePlayerNetID *> select(gVectorExtra< nNetObjectID > &owners, gVectorExtra< nNetObjectID > &teamOwners, gCycle * triggerer);
00284 };
00285 
00286 /*
00287  *
00288  */
00289 
00290 class zSelectorSingleDeadOwner : public zSelector
00291 {
00292 public:
00293     static zSelector* create();
00294     zSelectorSingleDeadOwner(); //<! Constructor
00295     zSelectorSingleDeadOwner(zSelectorSingleDeadOwner const &other);
00296     void operator=(zSelectorSingleDeadOwner const &other); 
00297     virtual zSelectorSingleDeadOwner *copy(void) const;
00298     virtual ~zSelectorSingleDeadOwner() {};
00299 
00300     gVectorExtra<ePlayerNetID *> select(gVectorExtra< nNetObjectID > &owners, gVectorExtra< nNetObjectID > &teamOwners, gCycle * triggerer);
00301 };
00302 
00303 
00304 /*
00305  *
00306  */
00307 
00308 class zSelectorAnotherTeammateDead : public zSelector
00309 {
00310 public:
00311     static zSelector* create();
00312     zSelectorAnotherTeammateDead(); //<! Constructor
00313     zSelectorAnotherTeammateDead(zSelectorAnotherTeammateDead const &other);
00314     void operator=(zSelectorAnotherTeammateDead const &other); 
00315     virtual zSelectorAnotherTeammateDead *copy(void) const;
00316     virtual ~zSelectorAnotherTeammateDead() {};
00317 
00318     gVectorExtra<ePlayerNetID *> select(gVectorExtra< nNetObjectID > &owners, gVectorExtra< nNetObjectID > &teamOwners, gCycle * triggerer);
00319 };
00320 
00321 /*
00322  *
00323  */
00324 
00325 class zSelectorAnotherNotTeammateDead : public zSelector
00326 {
00327 public:
00328     static zSelector* create();
00329     zSelectorAnotherNotTeammateDead(); //<! Constructor
00330     zSelectorAnotherNotTeammateDead(zSelectorAnotherNotTeammateDead const &other);
00331     void operator=(zSelectorAnotherNotTeammateDead const &other); 
00332     virtual zSelectorAnotherNotTeammateDead *copy(void) const;
00333     virtual ~zSelectorAnotherNotTeammateDead() {};
00334 
00335     gVectorExtra<ePlayerNetID *> select(gVectorExtra< nNetObjectID > &owners, gVectorExtra< nNetObjectID > &teamOwners, gCycle * triggerer);
00336 };
00337 
00338 
00339 #include "zone/zEffector.h"
00340 
00341 #endif

Generated on Sat Mar 15 22:56:13 2008 for Armagetron Advanced by  doxygen 1.5.4