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_CYCLE_H
00029 #define ArmageTron_CYCLE_H
00030
00031
00032
00033 #include "gStuff.h"
00034
00035
00036 #include "eNetGameObject.h"
00037 #include "tList.h"
00038 #include "nObserver.h"
00039 #include "rDisplayList.h"
00040
00041 #include "gCycleMovement.h"
00042
00043 class rModel;
00044 class gTextureCycle;
00045 class gSensor;
00046 class gNetPlayerWall;
00047 class gPlayerWall;
00048 class eTempEdge;
00049 class gJoystick;
00050 struct gPredictPositionData;
00051
00052
00053 extern REAL sg_delayCycle;
00054
00055
00056 extern bool headlights;
00057
00058
00059 extern REAL sg_rubberCycle;
00060
00061
00062
00063
00064
00065 class gCycleMemoryEntry;
00066
00067 class gCycleMemory{
00068 friend class gCycleMemoryEntry;
00069
00070 tList<gCycleMemoryEntry> memory;
00071
00072 public:
00073
00074 gCycleMemoryEntry* Remember(const gCycle *cycle);
00075 int Len() const {return memory.Len();}
00076 gCycleMemoryEntry* operator() (int i) const;
00077 gCycleMemoryEntry* Latest (int side) const;
00078 gCycleMemoryEntry* Earliest (int side) const;
00079
00080 void Clear();
00081
00082 gCycleMemory();
00083 ~gCycleMemory();
00084 };
00085
00086
00087 class gCycleExtrapolator: public gCycleMovement
00088 {
00089 public:
00090 void CopyFrom( const gCycleMovement& other );
00091 void CopyFrom( const SyncData& sync, const gCycle& other );
00092
00093 gCycleExtrapolator(eGrid *grid, const eCoord &pos,const eCoord &dir,ePlayerNetID *p=NULL,bool autodelete=1);
00094
00095 virtual ~gCycleExtrapolator();
00096
00097
00098
00099 virtual bool EdgeIsDangerous(const eWall *w, REAL time, REAL a) const;
00100
00101 virtual void PassEdge(const eWall *w,REAL time,REAL a,int recursion=1);
00102
00103 virtual bool TimestepCore(REAL currentTime, bool calculateAcceleration = true );
00104
00105
00106
00107 REAL trueDistance_;
00108 private:
00109
00110
00111 virtual nDescriptor& CreatorDescriptor() const;
00112
00113 const gCycleMovement* parent_;
00114 };
00115
00116 class gCycleChatBot;
00117
00118 #ifndef DEDICATED
00119 class gCycleWallsDisplayListManager
00120 {
00121 friend class gNetPlayerWall;
00122
00123 public:
00124 gCycleWallsDisplayListManager();
00125
00127 static bool CannotHaveList( REAL distance, gCycle const * cycle );
00128
00129 void RenderAll( eCamera const * camera, gCycle * cycle );
00130 bool Walls() const
00131 {
00132 return wallList_ || wallsWithDisplayList_;
00133 }
00134
00135 void Clear( int inhibit = 0 )
00136 {
00137 displayList_.Clear( inhibit );
00138 }
00139 private:
00140 gNetPlayerWall * wallList_;
00141 gNetPlayerWall * wallsWithDisplayList_;
00142 rDisplayList displayList_;
00143 REAL wallsWithDisplayListMinDistance_;
00144 int wallsInDisplayList_;
00145 };
00146 #endif
00147
00148
00149 class gCycle: public gCycleMovement
00150 {
00151 friend class gPlayerWall;
00152 friend class gNetPlayerWall;
00153 friend class gDestination;
00154 friend class gCycleWallRenderer;
00155
00156 REAL spawnTime_;
00157 REAL lastTimeAnim;
00158
00159 REAL timeCameIntoView;
00160
00161 friend class gCycleChatBot;
00162 std::auto_ptr< gCycleChatBot > chatBot_;
00163
00164 bool dropWallRequested_;
00165 public:
00166 eCoord lastGoodPosition_;
00167
00168 REAL skew,skewDot;
00169
00170 bool mp;
00171
00172 rModel *body,*front,*rear,
00173 *customModel;
00174
00175 gTextureCycle *wheelTex,*bodyTex;
00176 gTextureCycle *customTexture;
00177
00178 eCoord rotationFrontWheel,rotationRearWheel;
00179 REAL heightFrontWheel,heightRearWheel;
00180 public:
00181
00182
00183 static uActionPlayer s_brake;
00184 gCycleMemory memory;
00185
00186 gRealColor color_;
00187 gRealColor trailColor_;
00188
00189
00190
00191
00192 eCoord correctPosSmooth;
00193 eCoord predictPosition_;
00194
00195
00196 REAL correctDistanceSmooth;
00197
00198 private:
00199 void TransferPositionCorrectionToDistanceCorrection();
00200
00201 #ifndef DEDICATED
00202 gCycleWallsDisplayListManager displayList_;
00203 #endif
00204
00205 tCHECKED_PTR(gNetPlayerWall) currentWall;
00206 tCHECKED_PTR(gNetPlayerWall) lastWall;
00207 tCHECKED_PTR(gNetPlayerWall) lastNetWall;
00208
00209
00210 SyncData lastSyncMessage_;
00211 tJUST_CONTROLLED_PTR<gCycleExtrapolator> extrapolator_;
00212 bool resimulate_;
00213
00214 void ResetExtrapolator();
00215 bool Extrapolate( REAL dt );
00216 void SyncFromExtrapolator();
00217
00218 virtual void OnNotifyNewDestination(gDestination *dest);
00219 virtual void OnDropTempWall ( gPlayerWall * wall, eCoord const & position, eCoord const & direction );
00220
00221
00222
00223 nTimeRolling nextSync, nextSyncOwner;
00224
00225 void MyInitAfterCreation();
00226
00227 void SetCurrentWall(gNetPlayerWall *w);
00228
00229 void PreparePredictPosition( gPredictPositionData & data );
00230 REAL CalculatePredictPosition( gPredictPositionData & data );
00231 protected:
00232 virtual ~gCycle();
00233
00234 virtual void OnRemoveFromGame();
00235
00236 virtual void OnRoundEnd();
00237
00238
00239 public:
00240 virtual void Die ( REAL time ) ;
00241 void KillAt( const eCoord& pos );
00242
00243 int WindingNumber() const {return windingNumber_;}
00244
00245 virtual bool Vulnerable () const ;
00246
00247
00248
00249 virtual void InitAfterCreation();
00250 gCycle(eGrid *grid, const eCoord &pos,const eCoord &dir,ePlayerNetID *p=NULL);
00251
00252 static void SetWallsStayUpDelay ( REAL delay );
00253 static void SetWallsLength ( REAL length);
00254 static void SetExplosionRadius ( REAL radius);
00255
00256 static REAL WallsStayUpDelay() { return wallsStayUpDelay; }
00257 static REAL WallsLength() { return wallsLength; }
00258 REAL MaxWallsLength() const;
00259 REAL ThisWallsLength() const;
00260 REAL WallEndSpeed() const;
00261 static REAL ExplosionRadius() { return explosionRadius; }
00262
00263 bool IsMe( eGameObject const * other ) const;
00264
00265
00266 gCycle(nMessage &m);
00267 virtual void WriteCreate(nMessage &m);
00268 virtual void WriteSync(nMessage &m);
00269 virtual void ReadSync(nMessage &m);
00270 virtual void RequestSyncOwner();
00271 virtual void RequestSyncAll();
00272
00273 virtual void SyncEnemy ( const eCoord& begWall );
00274
00275
00276 virtual void ReceiveControl(REAL time,uActionPlayer *Act,REAL x);
00277 virtual void PrintName(tString &s) const;
00278 virtual bool ActionOnQuit();
00279
00280 virtual nDescriptor &CreatorDescriptor() const;
00281 virtual bool SyncIsNew(nMessage &m);
00282
00283
00284 virtual bool Timestep(REAL currentTime);
00285 virtual bool TimestepCore(REAL currentTime,bool calculateAcceleration = true);
00286
00287 virtual void InteractWith(eGameObject *target,REAL time,int recursion=1);
00288
00289 virtual bool EdgeIsDangerous(const eWall *w, REAL time, REAL a) const;
00290
00291 virtual void PassEdge(const eWall *w,REAL time,REAL a,int recursion=1);
00292
00293 virtual REAL PathfindingModifier( const eWall *w ) const;
00294
00295 virtual bool Act(uActionPlayer *Act,REAL x);
00296
00297 virtual bool DoTurn(int dir);
00298 void DropWall( bool buildNew=true );
00299
00300
00301
00302 virtual void Kill();
00303
00304 const eTempEdge* Edge();
00305 const gPlayerWall* CurrentWall();
00306
00307
00308 #ifndef DEDICATED
00309 virtual void Render(const eCamera *cam);
00310 virtual void Render2D(tCoord scale) const;
00311
00312 virtual void RenderName( const eCamera *cam );
00313
00314 virtual bool RenderCockpitFixedBefore(bool primary=true);
00315
00316
00317
00318 #endif
00319
00320 virtual eCoord CamPos() const;
00321 virtual eCoord PredictPosition() const;
00322 virtual eCoord CamTop() const;
00323 virtual eCoord CamDir() const;
00324 virtual eCoord Direction() const;
00325
00326 virtual void RightBeforeDeath( int numTries );
00327
00328 #ifdef POWERPAK_DEB
00329 virtual void PPDisplay();
00330 #endif
00331
00332 static void PrivateSettings();
00333
00334
00335
00336
00337 private:
00338 static REAL wallsStayUpDelay;
00339 static REAL wallsLength;
00340 static REAL explosionRadius;
00341 gJoystick * joystick_;
00342 protected:
00343 virtual bool DoIsDestinationUsed ( const gDestination * dest ) const ;
00344 };
00345
00346 #endif
00347