00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef ArmageTron_GAMEOBJECT_H
00029 #define ArmageTron_GAMEOBJECT_H
00030
00031
00032 #include "tList.h"
00033
00034 #include "eCoord.h"
00035 #include "tSafePTR.h"
00036
00037 class eGrid;
00038 class uActionPlayer;
00039 class eTeam;
00040 class eWall;
00041 class eCamera;
00042
00043
00044
00045 class eGameObject{
00046 friend class eFace;
00047 friend class eCamera;
00048 friend class eSensor;
00049 friend class eGrid;
00050 friend class ePlayerNetID;
00051
00052
00053 int id;
00054 #define GO ((eGameObject *)NULL)
00055 #define GO_I ((int *)NULL)
00056
00057
00058 static void TimestepThisWrapper(eGrid * grid, REAL currentTime, eGameObject *t, REAL minTimestep);
00059
00060 protected:
00061
00062
00063 static bool TimestepThis(REAL currentTime,eGameObject *t);
00064
00065
00066 static REAL MaxSimulateAhead();
00067
00068
00069 int interestingID;
00070 int inactiveID;
00071
00072
00073
00074
00075
00076
00077
00078
00079 bool autodelete;
00080 REAL lastTime;
00081 REAL deathTime;
00082
00083 eCoord pos;
00084 eCoord dir;
00085 REAL z;
00086
00087 tJUST_CONTROLLED_PTR< eTeam > team;
00088
00089 tJUST_CONTROLLED_PTR<eFace> currentFace;
00090 tCHECKED_PTR(eGrid) grid;
00091
00092
00093 public:
00095 static REAL GetMaxLazyLag();
00097 static void SetMaxLazyLag( REAL lag );
00098
00099 eTeam* Team() const { return team; }
00100
00101 static uActionPlayer se_turnLeft,se_turnRight;
00102
00103 eGrid* Grid() const { return grid; }
00104 eFace* CurrentFace() const { return currentFace; }
00105
00106 virtual void AddRef() = 0;
00107 virtual void Release() = 0;
00108
00109 void AddToList();
00110 void RemoveFromList();
00111 void RemoveFromListsAll();
00112 void RemoveFromGame();
00113
00114 protected:
00115 virtual void OnRemoveFromGame();
00116 private:
00117 virtual void DoRemoveFromGame();
00118 public:
00119
00120 int GOID() const {return id;}
00121 REAL LastTime() const {return lastTime;}
00122 virtual REAL NextInterestingTime() const {return lastTime;}
00123
00124 eGameObject(eGrid *grid, const eCoord &p,const eCoord &d, eFace *currentface, bool autodelete=1);
00125 virtual ~eGameObject();
00126
00127 virtual eCoord Position()const{return pos;}
00128 virtual eCoord Direction()const{return dir;}
00129 virtual eCoord LastDirection()const{return dir;}
00130 virtual REAL DeathTime()const{return deathTime;}
00131 virtual REAL Speed()const{return 20;}
00132
00133
00134 virtual eCoord PredictPosition() const {return pos;}
00135
00136
00137 virtual void InteractWith( eGameObject *target,REAL time,int recursion=1 );
00138
00139
00140 virtual void PassEdge( const eWall *w,REAL time,REAL a,int recursion=1 );
00141
00142
00143 virtual REAL PathfindingModifier( const eWall *w ) const { return 1 ;}
00144
00145
00146
00147 void Move( const eCoord &dest, REAL startTime, REAL endTime, bool useTempWalls = true );
00148
00149
00150 void FindCurrentFace();
00151
00152
00153 virtual bool Timestep(REAL currentTime);
00154
00155
00156 virtual bool EdgeIsDangerous(const eWall *w, REAL time, REAL a) const{
00157 return w;
00158 }
00159
00162 virtual void OnRoundBegin();
00163
00165 virtual void OnRoundEnd();
00166
00168 virtual void Kill();
00169
00171 virtual bool Alive() const {return false;}
00172
00174 virtual void Render(const eCamera *cam);
00175
00176
00177 virtual void Render2D(tCoord scale) const;
00178
00180 virtual bool RendersAlpha() const;
00181
00182
00183
00184 virtual bool RenderCockpitFixedBefore(bool primary=true);
00185
00186
00187
00188 virtual void RenderCockpitFixedAfter(bool primary=true);
00189
00190
00191 virtual void RenderCockpitVirtual(bool primary=false);
00192
00193
00194
00195
00196
00197
00198 virtual eCoord CamDir() const {return dir;}
00199 virtual REAL CamRise() const {return 0;}
00200 virtual eCoord CamPos() const {return pos;}
00201 virtual REAL CamZ() const {return z;}
00202 virtual eCoord CamTop() const {return eCoord(0,0);}
00203
00204
00205 virtual REAL Lag() const{return 0;}
00206 virtual REAL LagThreshold() const{return 0;}
00207
00208 #ifdef POWERPAK_DEB
00209 virtual void PPDisplay();
00210 #endif
00211
00212
00213 virtual bool Act(uActionPlayer *Act,REAL x);
00214
00215
00216 static void s_Timestep(eGrid *grid, REAL currentTime, REAL minTimestep);
00217
00218
00219 static void RenderAll(eGrid *grid, const eCamera *cam);
00220 static void PPDisplayAll();
00221
00222
00223 static void DeleteAll(eGrid *grid);
00224 };
00225
00226
00227 class eReferencableGameObject: public eGameObject, public tReferencable< eReferencableGameObject >
00228 {
00229 public:
00230 eReferencableGameObject(eGrid *grid, const eCoord &p,const eCoord &d, eFace *currentface, bool autodelete=1);
00231
00232
00233 virtual void AddRef();
00234 virtual void Release();
00235
00236 private:
00237 virtual void DoRemoveFromGame();
00238 };
00239
00240
00241 class eStackGameObject: public eGameObject
00242 {
00243 public:
00244 eStackGameObject(eGrid *grid, const eCoord &p,const eCoord &d, eFace *currentface);
00245
00246
00247 virtual void AddRef();
00248 virtual void Release();
00249
00250 private:
00251 virtual void DoRemoveFromGame();
00252 };
00253
00255 class eDeath
00256 {
00257 public:
00258 eDeath(){};
00259 ~eDeath(){};
00260 };
00261
00262 #endif