src/tron/zone/zZone.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 ArmageTron_Zone_H
00029 #define ArmageTron_Zone_H
00030 
00031 #include "eNetGameObject.h"
00032 
00033 #include "gCycle.h"
00034 #include "rColor.h"
00035 #include <boost/shared_ptr.hpp>
00036 #include "zone/zEffectGroup.h"
00037 #include "tFunction.h"
00038 #include <set>
00039 #include <vector>
00040 #include "zone/zShape.hpp"
00041 
00042 /*
00043 class zZone: public eNetGameObject
00044 {
00045     zZone(eGrid *grid); //!< local constructor
00046     zZone(nMessage &m);                    //!< network constructor
00047     ~zZone();                              //!< destructor
00048 
00049     void SetReferenceTime();               //!< sets the reference time to the current time
00050 
00051  protected:
00052     virtual bool Timestep(REAL currentTime);     //!< simulates behaviour up to currentTime
00053     virtual void OnVanish();                     //!< called when the zone vanishes
00054 private:
00055     virtual void WriteCreate(nMessage &m); //!< writes data for network constructor
00056     virtual void WriteSync(nMessage &m);   //!< writes sync data
00057     virtual void ReadSync(nMessage &m);    //!< reads sync data
00058 
00059     virtual void InteractWith( eGameObject *target,REAL time,int recursion=1 ); //!< looks for objects inzide the zone and reacts on them
00060     virtual nDescriptor& CreatorDescriptor() const; //!< returns the descriptor to recreate this object over the network
00061 
00062     virtual void Render(const eCamera *cam);  //!< renders the zone
00063 }
00064 */
00065 
00066 class zZone: public eNetGameObject
00067 {
00068 public:
00069     zZone(eGrid *grid); 
00070     zZone(nMessage &m);                    
00071     ~zZone();                              
00072     void RemoveFromGame();                 
00073 
00074     void SetReferenceTime();               
00075 
00076     eCoord          GetPosition         ( void ) const;                 
00077     zZone const &   GetPosition         ( eCoord & position ) const;    
00078     tCoord const    GetRotation         ( void ) const;                 
00079     REAL            GetScale           ( void ) const;                  
00080     rColor const    GetColor( void ) const;     
00081     /*
00082     zZone &         SetPosition         ( eCoord const & position );    //!< Sets the current position
00083     zZone &         SetVelocity         ( eCoord const & velocity );    //!< Sets the current velocity
00084     eCoord          GetVelocity         ( void ) const;                 //!< Gets the current velocity
00085     zZone const &   GetVelocity         ( eCoord & velocity ) const;    //!< Gets the current velocity
00086     zZone &         SetScale           ( REAL scale );              //!< Sets the current scale
00087     REAL            GetScale           ( void ) const;                  //!< Gets the current scale
00088     zZone const &   GetScale           ( REAL & scale ) const;      //!< Gets the current scale
00089     zZone &         SetExpansionSpeed   ( REAL expansionSpeed );            //!< Sets the current expansion speed
00090     REAL            GetExpansionSpeed   ( void ) const;                 //!< Gets the current expansion speed
00091     zZone const &   GetExpansionSpeed   ( REAL & expansionSpeed ) const;//!< Gets the current expansion speed
00092     zZone &         SetRotationSpeed    ( REAL rotationSpeed );         //!< Sets the current rotation speed
00093     REAL            GetRotationSpeed    ( void ) const;                 //!< Gets the current rotation speed
00094     tCoord const &  GetRotation         ( void ) const;                 //!< Gets the current rotation state
00095     zZone const &   GetRotationSpeed    ( REAL & rotationSpeed ) const; //!< Gets the current rotation speed
00096     zZone &         SetRotationAcceleration( REAL rotationAcceleration );               //!< Sets the current acceleration of the rotation
00097     REAL            GetRotationAcceleration( void ) const;                              //!< Gets the current acceleration of the rotation
00098     zZone const &   GetRotationAcceleration( REAL & rotationAcceleration ) const;       //!< Gets the current acceleration of the rotation
00099     rColor const &  GetColor( void ) const;     //!< Gets the current color
00100     void            SetColor( rColor const & color ); //!< Sets the current color
00101     */
00102 
00103     void addEffectGroupEnter  (zEffectGroupPtr anEffectGroup) {effectGroupEnter.push_back  (anEffectGroup);};
00104     void addEffectGroupInside (zEffectGroupPtr anEffectGroup) {effectGroupInside.push_back (anEffectGroup);};
00105     void addEffectGroupLeave  (zEffectGroupPtr anEffectGroup) {effectGroupLeave.push_back  (anEffectGroup);};
00106     void addEffectGroupOutside(zEffectGroupPtr anEffectGroup) {effectGroupOutside.push_back(anEffectGroup);};
00107 
00108     void setShape (zShapePtr aShape) { shape = aShape; };
00109     zShapePtr getShape() { return shape; };
00110 
00111     // HACK
00112     // Enables fortress described in maps from format 1 to be assigned to a team according to the old behavior
00113     void setOldFortressAutomaticAssignmentBehavior(bool oldFortressAutomaticAssignmentBehavior)
00114     {
00115         oldFortressAutomaticAssignmentBehavior_ = oldFortressAutomaticAssignmentBehavior;
00116     };
00117     bool getOldFortressAutomaticAssignmentBehavior() { return oldFortressAutomaticAssignmentBehavior_; };
00118 
00119     void setName(string name) {name_ = name;};
00120     string getName() { return name_; };
00121 
00122 protected:
00123     //    rColor color_;           //!< the zone's color
00124     REAL createTime_;            
00125     zShapePtr shape; 
00126 
00127     REAL referenceTime_;         
00128     /*
00129     tFunction posx_;             //!< time dependence of x component of position
00130     tFunction posy_;             //!< time dependence of y component of position
00131     tFunction scale_;           //!< time dependence of scale
00132     tFunction rotationSpeed_;    //!< the zone's rotation speed
00133     eCoord    rotation_;         //!< the current rotation state
00134     */
00135 
00136     virtual bool Timestep(REAL currentTime);     
00137     virtual void OnVanish();                     
00138 
00139     zEffectGroupPtrs effectGroupEnter;
00140     zEffectGroupPtrs effectGroupInside;
00141     zEffectGroupPtrs effectGroupLeave;
00142     zEffectGroupPtrs effectGroupOutside;
00143 
00144     std::set<ePlayerNetID *> playersInside; 
00145     std::set<ePlayerNetID *> playersOutside; 
00146 
00147 private:
00148     virtual void WriteCreate(nMessage &m); 
00149     virtual void WriteSync(nMessage &m);   
00150     virtual void ReadSync(nMessage &m);    
00151 
00152     virtual void InteractWith( eGameObject *target,REAL time,int recursion=1 ); 
00153 
00154     void OnEnter( gCycle *target, REAL time ); 
00155     void OnLeave( gCycle *target, REAL time ); 
00156     void OnInside( gCycle *target, REAL time ); 
00157     void OnOutside( gCycle *target, REAL time ); 
00158 
00159     virtual nDescriptor& CreatorDescriptor() const; 
00160 
00161     //    REAL Scale() const;           //!< returns the current scale
00162 
00163     virtual void Render(const eCamera *cam);  
00164     virtual void Render2D(tCoord scale) const;  
00165 
00166     inline REAL EvaluateFunctionNow( tFunction const & f ) const;  
00167     inline void SetFunctionNow( tFunction & f, REAL value ) const; 
00168 
00169     void RemoveFromZoneList(void); 
00170 
00171     bool oldFortressAutomaticAssignmentBehavior_;
00172 
00173     string name_;
00174 
00175 };
00176 
00177 #endif

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