00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #if !defined(__INCLUDE_TankPositionh_INCLUDE__)
00022 #define __INCLUDE_TankPositionh_INCLUDE__
00023
00024 #include <net/NetBuffer.h>
00025 #include <vector>
00026
00027 class Tank;
00028 class ScorchedContext;
00029 class TankPosition
00030 {
00031 public:
00032
00033 struct ShotEntry
00034 {
00035 ShotEntry(fixed p = 0, fixed r = 0, fixed e = 0) :
00036 power(p), rot(r), ele(e) { }
00037
00038 fixed power;
00039 fixed rot;
00040 fixed ele;
00041 bool current;
00042 };
00043
00044 TankPosition(ScorchedContext &context);
00045 virtual ~TankPosition();
00046
00047 void setTank(Tank *tank) { tank_ = tank; }
00048
00049
00050 void clientNewGame();
00051 void madeShot();
00052 void newGame();
00053
00054
00055 fixed getRotationXYDiff();
00056 fixed getRotationYZDiff();
00057 fixed getPowerDiff();
00058 void revertSettings(unsigned int index = 0);
00059 void undo();
00060 std::vector<ShotEntry> &getOldShots();
00061
00062
00063 fixed rotateGunXY(fixed angle, bool diff=true);
00064 fixed rotateGunYZ(fixed angle, bool diff=true);
00065 fixed getRotationGunXY() { return turretRotXY_; }
00066 fixed getRotationGunYZ() { return turretRotYZ_; }
00067
00068
00069 int getSelectPositionX() { return selectPositionX_; }
00070 int getSelectPositionY() { return selectPositionY_; }
00071 void setSelectPosition(int x, int y) {
00072 selectPositionX_ = x; selectPositionY_ = y; }
00073
00074
00075 fixed getPower() { return power_; }
00076 fixed changePower(fixed power, bool diff=true);
00077
00078 fixed getMaxPower() { return maxPower_; }
00079 void setMaxPower(fixed power) { maxPower_ = power; }
00080
00081
00082 FixedVector &getVelocityVector();
00083 FixedVector &getTankPosition();
00084 FixedVector &getTankTurretPosition();
00085 FixedVector &getTankGunPosition();
00086
00087 const char *getRotationString();
00088 const char *getElevationString();
00089 const char *getPowerString();
00090
00091
00092 bool writeMessage(NetBuffer &buffer);
00093 bool readMessage(NetBufferReader &reader);
00094
00095 protected:
00096 ScorchedContext &context_;
00097 Tank *tank_;
00098
00099
00100 std::vector<ShotEntry> oldShots_;
00101 fixed turretRotXY_, turretRotYZ_, power_;
00102 fixed oldTurretRotXY_, oldTurretRotYZ_, oldPower_;
00103 fixed maxPower_;
00104 int selectPositionX_, selectPositionY_;
00105 };
00106
00107 #endif
00108