#include <zShape.hpp>
Public Member Functions | |
zShape (eGrid *grid, unsigned short idZone) | |
zShape (nMessage &m) | |
virtual | ~zShape () |
virtual void | WriteCreate (nMessage &m) |
virtual void | WriteSync (nMessage &m) |
writes sync data | |
virtual void | ReadSync (nMessage &m) |
reads sync data | |
void | animate (REAL time) |
virtual bool | isInteracting (eGameObject *target) |
virtual void | render (const eCamera *cam) |
virtual void | render2d (tCoord scale) const |
void | setPosX (const tFunction &x) |
void | setPosY (const tFunction &y) |
void | setRotation2 (const tPolynomial< nMessage > &r) |
void | setScale (const tFunction &s) |
void | setColor (const rColor &c) |
void | setColorNow (const rColor &c) |
tFunction | getPosX () |
tFunction | getPosY () |
tFunction | getScale () |
rColor | getColor () |
void | TimeStep (REAL time) |
virtual bool | isEmulatingOldZone () |
void | setReferenceTime (REAL time) |
Protected Member Functions | |
eCoord | Position () |
void | networkRead (nMessage &m) |
void | networkWrite (nMessage &m) |
void | setCreatedTime (REAL time) |
void | joinWithZone () |
Protected Attributes | |
tFunction | posx_ |
position need not be inside the shape. | |
tFunction | posy_ |
positoin need not be inside the shape. | |
tFunction | scale_ |
Used to affect the contour and not the position. | |
tPolynomial< nMessage > | rotation2 |
Rotate the contour around the position at this rate. | |
rColor | color_ |
REAL | createdtime_ |
REAL | referencetime_ |
REAL | lasttime_ |
unsigned short | idZone_ |
bool | newIdZone_ |
Definition at line 13 of file zShape.hpp.
zShape::zShape | ( | eGrid * | grid, | |
unsigned short | idZone | |||
) |
Definition at line 5 of file zShape.cpp.
References joinWithZone().
00006 :eNetGameObject( grid, eCoord(0,0), eCoord(0,0), NULL, true ), 00007 posx_(), 00008 posy_(), 00009 scale_(), 00010 rotation2(), 00011 color_(), 00012 createdtime_(0.0), 00013 referencetime_(0.0), 00014 lasttime_(0.0), 00015 idZone_(idZone), 00016 newIdZone_(false) 00017 { 00018 joinWithZone(); 00019 }
zShape::zShape | ( | nMessage & | m | ) |
Definition at line 21 of file zShape.cpp.
References idZone_, joinWithZone(), networkRead(), newIdZone_, REAL, and setCreatedTime().
00021 :eNetGameObject(m) 00022 { 00023 REAL time; 00024 m >> time; 00025 setCreatedTime(time); 00026 00027 networkRead(m); 00028 00029 unsigned short anIdZone; 00030 m >> anIdZone; 00031 if(anIdZone != idZone_) { 00032 idZone_ = anIdZone; 00033 newIdZone_ = true; 00034 joinWithZone(); 00035 } 00036 }
virtual zShape::~zShape | ( | ) | [inline, virtual] |
void zShape::WriteCreate | ( | nMessage & | m | ) | [virtual] |
Reimplemented from eNetGameObject.
Reimplemented in zShapeCircle, and zShapePolygon.
Definition at line 87 of file zShape.cpp.
References createdtime_, idZone_, networkWrite(), and eNetGameObject::WriteCreate().
Referenced by zShapePolygon::WriteCreate(), and zShapeCircle::WriteCreate().
00088 { 00089 eNetGameObject::WriteCreate(m); 00090 00091 m << createdtime_; 00092 00093 networkWrite(m); 00094 00095 m << idZone_; 00096 }
void zShape::WriteSync | ( | nMessage & | m | ) | [virtual] |
writes sync data
Reimplemented from eNetGameObject.
Reimplemented in zShapeCircle.
Definition at line 98 of file zShape.cpp.
References networkWrite().
Referenced by zShapeCircle::WriteSync().
00099 { 00100 networkWrite(m); 00101 }
void zShape::ReadSync | ( | nMessage & | m | ) | [virtual] |
reads sync data
Reimplemented from eNetGameObject.
Reimplemented in zShapeCircle.
Definition at line 103 of file zShape.cpp.
References networkRead().
Referenced by zShapeCircle::ReadSync().
00104 { 00105 networkRead(m); 00106 }
void zShape::animate | ( | REAL | time | ) |
bool zShape::isInteracting | ( | eGameObject * | target | ) | [virtual] |
void zShape::render | ( | const eCamera * | cam | ) | [virtual] |
void zShape::render2d | ( | tCoord | scale | ) | const [virtual] |
void zShape::setPosX | ( | const tFunction & | x | ) |
void zShape::setPosY | ( | const tFunction & | y | ) |
void zShape::setRotation2 | ( | const tPolynomial< nMessage > & | r | ) |
Definition at line 116 of file zShape.cpp.
References nCLIENT, nNetObject::RequestSync(), rotation2, and sn_GetNetState().
00116 { 00117 if(rotation2 == r) { 00118 // Empty: Nothing to do, no need to send an update 00119 } 00120 else { 00121 rotation2 = r; 00122 if (sn_GetNetState()!=nCLIENT) 00123 RequestSync(); 00124 } 00125 }
void zShape::setScale | ( | const tFunction & | s | ) |
void zShape::setColor | ( | const rColor & | c | ) |
Definition at line 131 of file zShape.cpp.
References color_, nCLIENT, nNetObject::RequestSync(), and sn_GetNetState().
Referenced by setColorNow().
00131 { 00132 if(color_ != c) { 00133 color_ = c; 00134 if (sn_GetNetState()!=nCLIENT) 00135 RequestSync(); 00136 } 00137 }
void zShape::setColorNow | ( | const rColor & | c | ) |
Definition at line 139 of file zShape.cpp.
References setColor().
00139 { 00140 // TODO: make color slide with some fancy tFunc or something. 00141 setColor(c); 00142 }
tFunction zShape::getPosX | ( | ) | [inline] |
tFunction zShape::getPosY | ( | ) | [inline] |
tFunction zShape::getScale | ( | ) | [inline] |
rColor zShape::getColor | ( | ) | [inline] |
void zShape::TimeStep | ( | REAL | time | ) |
Definition at line 148 of file zShape.cpp.
References joinWithZone(), lasttime_, and newIdZone_.
00148 { 00149 lasttime_ = time; 00150 /* 00151 REAL scale = scale_.Evaluate(lasttime_ - referencetime_); 00152 if (scale < -1.0) // Allow shapes to keep existing for a while even though they are not physical 00153 { 00154 // The shape has collapsed and should be removed 00155 } 00156 */ 00157 00158 if(newIdZone_) { 00159 joinWithZone(); 00160 } 00161 00162 }
virtual bool zShape::isEmulatingOldZone | ( | ) | [inline, virtual] |
void zShape::setReferenceTime | ( | REAL | time | ) |
Definition at line 48 of file zShape.cpp.
References referencetime_.
Referenced by networkRead().
00049 { 00050 referencetime_ = time; 00051 // Do not update lasttime_, referencetime_ might be set in the future for ease of equation writing. 00052 }
eCoord zShape::Position | ( | ) | [inline, protected] |
Definition at line 52 of file zShape.hpp.
References eCoord, lasttime_, posx_, posy_, and referencetime_.
Referenced by zShapeCircle::isInteracting().
00052 { return eCoord(posx_(lasttime_ - referencetime_), posy_(lasttime_ - referencetime_) ); };
void zShape::networkRead | ( | nMessage & | m | ) | [protected] |
Definition at line 68 of file zShape.cpp.
References tColor::a_, tColor::b_, color_, tColor::g_, posx_, posy_, tColor::r_, REAL, rotation2, scale_, and setReferenceTime().
Referenced by ReadSync(), and zShape().
00069 { 00070 REAL time; 00071 m >> time; 00072 setReferenceTime(time); 00073 m >> posx_; 00074 m >> posy_; 00075 m >> scale_; 00076 m >> rotation2; 00077 00078 m >> color_.r_; 00079 m >> color_.g_; 00080 m >> color_.b_; 00081 m >> color_.a_; 00082 }
void zShape::networkWrite | ( | nMessage & | m | ) | [protected] |
Definition at line 54 of file zShape.cpp.
References tColor::a_, tColor::b_, color_, tColor::g_, posx_, posy_, tColor::r_, referencetime_, rotation2, and scale_.
Referenced by WriteCreate(), and WriteSync().
00055 { 00056 00057 m << referencetime_; 00058 m << posx_; 00059 m << posy_; 00060 m << scale_; 00061 m << rotation2; 00062 m << color_.r_; 00063 m << color_.g_; 00064 m << color_.b_; 00065 m << color_.a_; 00066 }
void zShape::setCreatedTime | ( | REAL | time | ) | [protected] |
Definition at line 39 of file zShape.cpp.
References createdtime_, and lasttime_.
Referenced by zShape().
00040 { 00041 createdtime_ = time; 00042 00043 // Usefull when the nMessage creates the zone in the middle of a round 00044 if(lasttime_ < createdtime_) 00045 lasttime_ = createdtime_; 00046 }
void zShape::joinWithZone | ( | ) | [protected] |
Definition at line 173 of file zShape.cpp.
References asdf, idZone_, newIdZone_, zZone::setShape(), and sn_netObjects.
Referenced by TimeStep(), and zShape().
00173 { 00174 if(sn_netObjects[idZone_]) { 00175 zZone *asdf = dynamic_cast<zZone*>(&*sn_netObjects[idZone_]); 00176 asdf->setShape(zShapePtr(this)); 00177 newIdZone_ = false; 00178 } 00179 }
tFunction zShape::posx_ [protected] |
position need not be inside the shape.
Definition at line 46 of file zShape.hpp.
Referenced by getPosX(), zShapePolygon::isInside(), networkRead(), networkWrite(), Position(), zShapePolygon::render(), zShapeCircle::render(), zShapePolygon::render2d(), zShapeCircle::render2d(), and setPosX().
tFunction zShape::posy_ [protected] |
positoin need not be inside the shape.
Definition at line 47 of file zShape.hpp.
Referenced by getPosY(), zShapePolygon::isInside(), networkRead(), networkWrite(), Position(), zShapePolygon::render(), zShapeCircle::render(), zShapePolygon::render2d(), zShapeCircle::render2d(), and setPosY().
tFunction zShape::scale_ [protected] |
Used to affect the contour and not the position.
Definition at line 48 of file zShape.hpp.
Referenced by getScale(), zShapePolygon::isInside(), zShapeCircle::isInteracting(), networkRead(), networkWrite(), zShapePolygon::render(), zShapeCircle::render(), zShapePolygon::render2d(), zShapeCircle::render2d(), and setScale().
tPolynomial<nMessage> zShape::rotation2 [protected] |
Rotate the contour around the position at this rate.
Definition at line 49 of file zShape.hpp.
Referenced by zShapePolygon::isInside(), networkRead(), networkWrite(), zShapePolygon::render(), zShapeCircle::render(), zShapePolygon::render2d(), zShapeCircle::render2d(), and setRotation2().
rColor zShape::color_ [protected] |
Definition at line 50 of file zShape.hpp.
Referenced by getColor(), networkRead(), networkWrite(), zShapePolygon::render(), zShapeCircle::render(), zShapePolygon::render2d(), zShapeCircle::render2d(), and setColor().
REAL zShape::createdtime_ [protected] |
REAL zShape::referencetime_ [protected] |
Definition at line 62 of file zShape.hpp.
Referenced by zShapePolygon::isInside(), zShapeCircle::isInteracting(), networkWrite(), Position(), zShapePolygon::render(), zShapeCircle::render(), zShapePolygon::render2d(), zShapeCircle::render2d(), and setReferenceTime().
REAL zShape::lasttime_ [protected] |
Definition at line 63 of file zShape.hpp.
Referenced by zShapePolygon::isInside(), zShapeCircle::isInteracting(), Position(), zShapePolygon::render(), zShapeCircle::render(), zShapePolygon::render2d(), zShapeCircle::render2d(), setCreatedTime(), and TimeStep().
unsigned short zShape::idZone_ [protected] |
Definition at line 65 of file zShape.hpp.
Referenced by joinWithZone(), WriteCreate(), and zShape().
bool zShape::newIdZone_ [protected] |