3
*************************************************************************
5
ArmageTron -- Just another Tron Lightcycle Game in 3D.
6
Copyright (C) 2000 Manuel Moos (manuel@moosnet.de)
9
**************************************************************************
11
This program is free software; you can redistribute it and/or
12
modify it under the terms of the GNU General Public License
13
as published by the Free Software Foundation; either version 2
14
of the License, or (at your option) any later version.
16
This program is distributed in the hope that it will be useful,
17
but WITHOUT ANY WARRANTY; without even the implied warranty of
18
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
GNU General Public License for more details.
21
You should have received a copy of the GNU General Public License
22
along with this program; if not, write to the Free Software
23
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
25
***************************************************************************
29
#ifndef ArmageTron_gWALL_H
30
#define ArmageTron_gWALL_H
33
#include "nNetObject.h"
34
//#include "nObserver.h"
40
class gWallRim:public eWallRim{
42
gWallRim(eGrid *grid, REAL h=10000);
43
gWallRim(eGrid *grid, REAL tBeg, REAL tEnd, REAL h=10000);
46
virtual bool Splittable() const;
48
virtual void Split(eWall *& w1,eWall *& w2,REAL a);
49
virtual bool RunsParallelPassive( eWall * newWall );
52
void RenderReal(const eCamera *cam);
54
virtual void OnBlocksCamera( eCamera * cam, REAL height ) const; //!< called by the camera code when this wall is between the cycle and the camera
56
virtual REAL Height();
57
virtual REAL SeeHeight();
60
mutable REAL renderHeight_; //!< the height with which this wall is really rendered
61
mutable REAL lastUpdate_; //!< time of the last render height update
63
REAL tBeg_, tEnd_; //!< begin and end texture coordinates
66
class gPlayerWallCoord{
73
class gPlayerWall:public eWall{
75
gPlayerWall(gNetPlayerWall*w, gCycle *p);
76
virtual ~gPlayerWall();
78
// virtual ArmageTron_eWalltype type();
81
virtual void SplitByActive( eWall* oldWall );
82
virtual bool RunsParallelActive( eWall* oldWall );
84
virtual bool Splittable() const;
85
virtual bool Deletable() const;
87
virtual void Split(eWall *& w1,eWall *& w2,REAL a);
90
virtual void Render(const eCamera *cam);
91
void RenderList(bool list);
94
virtual REAL BlockHeight() const;
95
virtual REAL SeeHeight() const;
97
int WindingNumber() const {return windingNumber_;}
99
REAL LocalToGlobal( REAL a ) const;
100
REAL GlobalToLocal( REAL a ) const;
102
REAL Time(REAL a) const;
103
REAL Pos(REAL a) const;
104
REAL Alpha(REAL pos) const;
105
bool IsDangerousAnywhere( REAL time ) const;
106
bool IsDangerous( REAL a, REAL time ) const;
108
void BlowHole ( REAL dbeg, REAL dend ); // blow a hole into the wall form distance dbeg to dend
112
REAL BegTime() const;
113
REAL EndTime() const;
115
gCycle *Cycle() const;
116
gCycleMovement *CycleMovement() const;
117
gNetPlayerWall* NetWall() const;
121
// void SetNetWall( const gNetPlayerWall* netWall );
122
// void SetCoords( const tArray< gPlayerWallCoord >& coords );
123
// const tArray< gPlayerWallCoord >& GetCoords() const;
126
tCONTROLLED_PTR(gCycle) cycle_;
127
tCONTROLLED_PTR(gNetPlayerWall) netWall_;
129
// nObserverPtr< gNetPlayerWall > netWall_;
132
REAL begAlpha_, endAlpha_; // relative position i gNetPlayerWall
138
// the sn_netObjects that represents eWalls across the network.
139
class gNetPlayerWall: public nNetObject{
143
tCONTROLLED_PTR(gCycle) cycle_; // our cycle
144
tCONTROLLED_PTR(eTempEdge) edge_; // the eEdge we are representing
146
eCoord dir; // the direction from start to end
147
REAL dbegin; // the start position
148
eCoord beg,end; // start and end points
149
REAL tBeg,tEnd; // start and end time
151
unsigned short inGrid; // are we planned to be insite the grid?
152
REAL gridding; // when are we going to enter the grid?
154
bool preliminary:1; // is it a eWall preliminary installed?
155
REAL obsoleted_; // the game time this preliminary wall got obsoleted by a final wall (negative if it is not yet obsolete)
156
// by the client while it is waiting for the real eWall from the server?
160
void MyInitAfterCreation();
161
void real_CopyIntoGrid(eGrid *grid);
162
void real_Update(REAL tEnd,const eCoord &pend, bool force );
164
virtual void InitAfterCreation();
165
gNetPlayerWall(gCycle *c,
166
const eCoord &beg,const eCoord &dir,
167
REAL tBeg, REAL dbeg);
169
// void Update(REAL tEnd,REAL dend);
170
void Update(REAL tEnd,const eCoord &pend);
171
void CopyIntoGrid(eGrid *grid,bool force=false);
172
static void s_CopyIntoGrid();
173
void RealWallReceived( gNetPlayerWall* realwall );
175
gNetPlayerWall(nMessage &m);
177
//eCoord Vec(){return w->Vec();}
178
eCoord Vec(); //!< returns the vector from the beginning to the end of the wall
180
virtual ~gNetPlayerWall();
181
void ReleaseData(); // release all references
183
void SetEndTime(REAL et);
184
void SetEndPos(REAL ep);
186
int IndexAlpha(REAL a) const;
187
int IndexPos(REAL d) const;
188
REAL Time(REAL a) const;
189
REAL Pos(REAL a) const;
190
REAL Alpha(REAL pos) const;
191
bool IsDangerousAnywhere( REAL time ) const;
192
bool IsDangerous( REAL a, REAL time ) const;
194
void BlowHole ( REAL dbeg, REAL dend ); // blow a hole into the wall form distance dbeg to dend
198
REAL BegTime() const;
199
REAL EndTime() const;
201
const eCoord& EndPoint(int i) const
215
virtual void Render(const eCamera *cam);
216
void RenderList(bool list);
217
virtual void RenderNormal(const eCoord &x1,const eCoord &x2,REAL ta,REAL te,REAL r,REAL g,REAL b,REAL a);
218
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);
221
virtual bool ActionOnQuit();
223
virtual bool ClearToTransmit(int user) const;
225
virtual void WriteSync(nMessage &m);
226
virtual void ReadSync(nMessage &m);
228
virtual void WriteCreate(nMessage &m);
229
virtual nDescriptor &CreatorDescriptor() const;
230
virtual void PrintName(tString &s) const;
232
virtual bool SyncIsNew(nMessage &m);
235
eTempEdge *Edge(){return this->edge_;}
237
gCycle *Cycle() const {return this->cycle_;}
238
gCycleMovement *CycleMovement() const;
240
bool Preliminary()const{return preliminary;}
241
bool InGrid()const{return inGrid;}
243
static void Clear(); // delete all sg_netPlayerWalls.
247
tArray<gPlayerWallCoord> coords_;
249
unsigned int displayList_;
252
extern tList<gNetPlayerWall> sg_netPlayerWalls;