00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #if !defined(__INCLUDE_MovementMaph_INCLUDE__)
00022 #define __INCLUDE_MovementMaph_INCLUDE__
00023
00024 #include <landscapemap/HeightMap.h>
00025 #include <list>
00026 #include <queue>
00027
00028 class WeaponMoveTank;
00029 class Tank;
00030 class Target;
00031 class ScorchedContext;
00032 class MovementMap
00033 {
00034 public:
00035 enum MovementMapEntryType
00036 {
00037 eNotInitialized = 0,
00038 eNotSeen = 1,
00039 eNoMovement = 2,
00040 eMovement = 3
00041 };
00042 struct MovementMapEntry
00043 {
00044 MovementMapEntry() {}
00045 MovementMapEntry(
00046 MovementMapEntryType t,
00047 fixed d,
00048 unsigned int s,
00049 unsigned int e) : type(t), dist(d), srcEntry(s), epoc(e) {}
00050
00051 MovementMapEntryType type;
00052 fixed dist;
00053 unsigned int srcEntry;
00054 unsigned int epoc;
00055 };
00056 struct QueuePosition
00057 {
00058 fixed distance;
00059 unsigned int square;
00060
00061 bool operator<(const QueuePosition &rhs) const;
00062 };
00063
00064 MovementMap(
00065 Tank *tank,
00066 ScorchedContext &context);
00067 virtual ~MovementMap();
00068
00069 bool calculatePosition(FixedVector &position, fixed fuel);
00070 void calculateAllPositions(fixed fuel);
00071 MovementMapEntry &getEntry(int w, int h);
00072
00073
00074 void movementTexture();
00075 static void limitTexture(FixedVector ¢er, int limit);
00076 fixed getFuel(WeaponMoveTank *weapon);
00077
00078
00079
00080 static bool inShield(Target *target, Tank *tank, FixedVector &position);
00081 static bool movementProof(ScorchedContext &context,
00082 Target *target, Tank *tank);
00083 static bool allowedPosition(ScorchedContext &context,
00084 Tank *tank, FixedVector &position);
00085
00086 protected:
00087 MovementMapEntry *entries_;
00088 int landscapeWidth_, landscapeHeight_;
00089 int arenaX_, arenaY_;
00090 int arenaWidth_, arenaHeight_;
00091 fixed minHeight_;
00092 Tank *tank_;
00093 ScorchedContext &context_;
00094 std::list<Target *> checkTargets_;
00095
00096 unsigned int POINT_TO_UINT(unsigned int x, unsigned int y);
00097 void addPoint(unsigned int x, unsigned int y,
00098 fixed height, fixed dist,
00099 std::list<unsigned int> &edgeList,
00100 unsigned int sourcePt,
00101 unsigned int epoc);
00102 void addPoint(unsigned int x, unsigned int y,
00103 fixed height, fixed dist,
00104 std::priority_queue<QueuePosition,
00105 std::vector<QueuePosition>,
00106 std::less<QueuePosition> > &priorityQueue,
00107 unsigned int sourcePt,
00108 FixedVector &position);
00109
00110 fixed getWaterHeight();
00111 bool tankBurried();
00112 MovementMapEntry &getAndCheckEntry(int w, int h);
00113
00114
00115 };
00116
00117 #endif