MovementMap.h

Go to the documentation of this file.
00001 ////////////////////////////////////////////////////////////////////////////////
00002 //    Scorched3D (c) 2000-2009
00003 //
00004 //    This file is part of Scorched3D.
00005 //
00006 //    Scorched3D is free software; you can redistribute it and/or modify
00007 //    it under the terms of the GNU General Public License as published by
00008 //    the Free Software Foundation; either version 2 of the License, or
00009 //    (at your option) any later version.
00010 //
00011 //    Scorched3D is distributed in the hope that it will be useful,
00012 //    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 //    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 //    GNU General Public License for more details.
00015 //
00016 //    You should have received a copy of the GNU General Public License
00017 //    along with Scorched3D; if not, write to the Free Software
00018 //    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
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         // Create landscape textures that show where the tank can move to
00074         void movementTexture();
00075         static void limitTexture(FixedVector &center, int limit);
00076         fixed getFuel(WeaponMoveTank *weapon);
00077 
00078         // Functions returns true if a tank can move into the give position,
00079         // false otherwise.  Shields and obstacles my prevent a tank moving.
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

Generated on Mon Feb 16 15:14:50 2009 for Scorched3D by  doxygen 1.5.3