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
00029 #ifndef ArmageTron_gWALL_H
00030 #define ArmageTron_gWALL_H
00031
00032 #define HUD_MAP
00033
00034 #include "eAdvWall.h"
00035 #include "nNetObject.h"
00036 #include "gExplosion.h"
00037 #include "rDisplayList.h"
00038
00039 class gExplosion;
00040 class gCycle;
00041 class gCycleMovement;
00042 class gNetPlayerWall;
00043 class eTempEdge;
00044
00045 class gWallRim:public eWallRim{
00046 public:
00047 gWallRim(eGrid *grid, REAL h=10000);
00048 gWallRim(eGrid *grid, REAL tBeg, REAL tEnd, REAL h=10000);
00049 virtual ~gWallRim();
00050
00051 virtual bool Splittable() const;
00052
00053 virtual void Split(eWall *& w1,eWall *& w2,REAL a);
00054 virtual bool RunsParallelPassive( eWall * newWall );
00055
00056 #ifndef DEDICATED
00057 void RenderReal(const eCamera *cam);
00058 protected:
00059 virtual void OnBlocksCamera( eCamera * cam, REAL height ) const;
00060 #endif
00061 virtual REAL Height();
00062 virtual REAL SeeHeight();
00063
00064 private:
00065 mutable REAL renderHeight_;
00066 mutable REAL lastUpdate_;
00067
00068 REAL tBeg_, tEnd_;
00069 };
00070
00073 class gPlayerWallCoord{
00074 public:
00075 REAL Pos;
00076 REAL Time;
00077 bool IsDangerous;
00078 tJUST_CONTROLLED_PTR< gExplosion > holer;
00079 };
00080
00081 class gPlayerWall:public eWall{
00082 public:
00083 friend class gNetPlayerWall;
00084
00085 gPlayerWall(gNetPlayerWall*w, gCycle *p);
00086 virtual ~gPlayerWall();
00087
00088
00089
00090 virtual void Flip();
00091 virtual void SplitByActive( eWall* oldWall );
00092 virtual bool RunsParallelActive( eWall* oldWall );
00093
00094 virtual bool Splittable() const;
00095 virtual bool Deletable() const;
00096
00097 virtual void Split(eWall *& w1,eWall *& w2,REAL a);
00098
00099 #ifndef DEDICATED
00100 virtual void Render(const eCamera *cam);
00101 void RenderList(bool list);
00102 #endif
00103
00104 virtual REAL BlockHeight() const;
00105 virtual REAL SeeHeight() const;
00106
00107 int WindingNumber() const {return windingNumber_;}
00108
00109 REAL LocalToGlobal( REAL a ) const;
00110 REAL GlobalToLocal( REAL a ) const;
00111
00112 REAL Time(REAL a) const;
00113 REAL Pos(REAL a) const;
00114 REAL Alpha(REAL pos) const;
00115 bool IsDangerousAnywhere( REAL time ) const;
00116 bool IsDangerous( REAL a, REAL time ) const;
00117 gExplosion * Holer( REAL a, REAL time ) const;
00118
00119 void BlowHole ( REAL dbeg, REAL dend, gExplosion * holer );
00120
00121 REAL BegPos() const;
00122 REAL EndPos() const;
00123 REAL BegTime() const;
00124 REAL EndTime() const;
00125
00126 gCycle *Cycle() const;
00127 gCycleMovement *CycleMovement() const;
00128 gNetPlayerWall* NetWall() const;
00129
00130 void Insert();
00131
00132
00133
00134
00135 private:
00136 void Check() const;
00137 tCONTROLLED_PTR(gCycle) cycle_;
00138 tCONTROLLED_PTR(gNetPlayerWall) netWall_;
00139
00140
00141
00142 int windingNumber_;
00143
00144 REAL begDist_, endDist_;
00145
00146 gPlayerWall();
00147 };
00148
00149
00150
00151 class gNetPlayerWall: public tListItem< gNetPlayerWall >, public nNetObject{
00152 friend class gCycle;
00153 int id,griddedid;
00154
00155 tCONTROLLED_PTR(gCycle) cycle_;
00156 tCONTROLLED_PTR(eTempEdge) edge_;
00157 gPlayerWall * lastWall_;
00158
00159 eCoord dir;
00160 REAL dbegin;
00161 eCoord beg,end;
00162 REAL tBeg,tEnd;
00163
00164 unsigned short inGrid;
00165 REAL gridding;
00166 bool preliminary:1;
00167 REAL obsoleted_;
00168
00169
00170 void CreateEdge();
00171 void InitArray();
00172 void MyInitAfterCreation();
00173 void real_CopyIntoGrid(eGrid *grid);
00174 void PartialCopyIntoGrid(eGrid *grid);
00175 void real_Update(REAL tEnd,const eCoord &pend, bool force );
00176 public:
00177 virtual void InitAfterCreation();
00178 gNetPlayerWall(gCycle *c,
00179 const eCoord &beg,const eCoord &dir,
00180 REAL tBeg, REAL dbeg);
00181
00182
00183 void Update(REAL tEnd,const eCoord &pend);
00184 void CopyIntoGrid(eGrid *grid,bool force=false);
00185 static void s_CopyIntoGrid();
00186 void RealWallReceived( gNetPlayerWall* realwall );
00187 void Checkpoint();
00188
00189 gNetPlayerWall(nMessage &m);
00190
00191
00192 eCoord Vec();
00193 #ifdef HUD_MAP
00194 tArray<gPlayerWallCoord> &Coords() { return coords_; }
00195 #endif
00196 protected:
00197 virtual ~gNetPlayerWall();
00198 void ReleaseData();
00199 public:
00200 void SetEndTime(REAL et);
00201 void SetEndPos(REAL ep);
00202
00203 int IndexAlpha(REAL a) const;
00204 int IndexPos(REAL d) const;
00205 REAL Time(REAL a) const;
00206 REAL Pos(REAL a) const;
00207 REAL Alpha(REAL pos) const;
00208 bool IsDangerousAnywhere( REAL time ) const;
00209 bool IsDangerousApartFromHoles( REAL a, REAL time ) const;
00210 bool IsDangerous( REAL a, REAL time ) const;
00211 gExplosion * Holer( REAL a, REAL time ) const;
00212
00213 void BlowHole ( REAL dbeg, REAL dend, gExplosion * holer );
00214
00215 REAL BegPos() const;
00216 REAL EndPos() const;
00217 REAL BegTime() const;
00218 REAL EndTime() const;
00219
00220 const eCoord& EndPoint(int i) const
00221 {
00222 switch ( i )
00223 {
00224 case 0:
00225 return beg;
00226 case 1:
00227 default:
00228 return end;
00229 }
00230 }
00231
00232
00233 #ifndef DEDICATED
00236 enum gWallRenderMode
00237 {
00238 gWallRenderMode_Lines = 1,
00239 gWallRenderMode_Quads = 2,
00240 gWallRenderMode_All = 3
00241 };
00242
00243 virtual void Render(const eCamera *cam);
00244 void RenderList(bool list, gWallRenderMode mode = gWallRenderMode_All );
00245 virtual void RenderNormal(const eCoord &x1,const eCoord &x2,REAL ta,REAL te,REAL r,REAL g,REAL b,REAL a, gWallRenderMode mode );
00246 virtual void RenderBegin(const eCoord &x1,const eCoord &x2,REAL ta,REAL te,REAL ra,REAL rb,REAL r,REAL g,REAL b,REAL a);
00247 #endif
00248
00249 virtual bool ActionOnQuit();
00250
00251 virtual bool ClearToTransmit(int user) const;
00252
00253 virtual void WriteSync(nMessage &m);
00254 virtual void ReadSync(nMessage &m);
00255
00256 virtual void WriteCreate(nMessage &m);
00257 virtual nDescriptor &CreatorDescriptor() const;
00258 virtual void PrintName(tString &s) const;
00259
00260 virtual bool SyncIsNew(nMessage &m);
00261
00262
00263 eTempEdge *Edge(){return this->edge_;}
00264 gPlayerWall *Wall();
00265 gCycle *Cycle() const {return this->cycle_;}
00266 gCycleMovement *CycleMovement() const;
00267
00268 bool Preliminary()const{return preliminary;}
00269 bool InGrid()const{return inGrid;}
00270
00271 static void Clear();
00272
00273 void Check() const;
00274
00275 bool HasDisplayList()
00276 {
00277 return displayList_.IsSet();
00278 }
00279
00280 bool CanHaveDisplayList()
00281 {
00282 return !displayList_.IsInhibited();
00283 }
00284
00286 void ClearDisplayList( int inhibitThis = 2, int inhibitCycle = 0 );
00287 private:
00288 tArray<gPlayerWallCoord> coords_;
00289
00290 rDisplayList displayList_;
00291 };
00292
00293 extern tList<gNetPlayerWall> sg_netPlayerWalls;
00294 extern tList<gNetPlayerWall> sg_netPlayerWallsGridded;
00295
00296 #endif