00001 /* 00002 This file is part of Advanced Strategic Command; http://www.asc-hq.de 00003 Copyright (C) 1994-2010 Martin Bickel and Marc Schellenberger 00004 00005 This program is free software; you can redistribute it and/or modify 00006 it under the terms of the GNU General Public License as published by 00007 the Free Software Foundation; either version 2 of the License, or 00008 (at your option) any later version. 00009 00010 This program is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 GNU General Public License for more details. 00014 00015 You should have received a copy of the GNU General Public License 00016 along with this program; see the file COPYING. If not, write to the 00017 Free Software Foundation, Inc., 59 Temple Place, Suite 330, 00018 Boston, MA 02111-1307 USA 00019 */ 00020 00021 00022 #ifndef MoveUnitCommandH 00023 #define MoveUnitCommandH 00024 00025 #include <set> 00026 #include <sigc++/sigc++.h> 00027 00028 #include "unitcommand.h" 00029 #include "taskinterface.h" 00030 00031 #include "../typen.h" 00032 #include "../attack.h" 00033 #include "../astar2.h" 00034 00035 00036 class MoveUnitCommand : public UnitCommand, public TaskInterface, public SigC::Object { 00037 00038 public: 00039 static bool avail ( Vehicle* eht ); 00040 static bool ascendAvail ( Vehicle* eht ); 00041 static bool descendAvail ( Vehicle* eht ); 00042 typedef map<MapCoordinate,AttackWeap > FieldList; 00043 00044 private: 00045 MapCoordinate3D destination; 00046 00047 void fieldChecker( const MapCoordinate& pos ); 00048 00049 set<MapCoordinate3D> reachableFields; 00050 set<MapCoordinate3D> reachableFieldsIndirect; 00051 00052 AStar3D::Path path; 00053 00054 int flags; 00055 int verticalDirection; 00056 bool multiTurnMovement; 00057 00058 MoveUnitCommand( GameMap* map ); 00059 template<class Child> friend GameAction* GameActionCreator( GameMap* map); 00060 00061 void changeCoordinates( const MapCoodinateVector& delta ); 00062 00063 protected: 00064 void readData ( tnstream& stream ); 00065 void writeData ( tnstream& stream ) const; 00066 00067 GameActionID getID() const; 00068 ASCString getDescription() const; 00069 00070 ActionResult go ( const Context& context ); 00071 00072 public: 00073 MoveUnitCommand ( Vehicle* unit ); 00074 00075 enum SeachCapabilities { NoInterrupt = 1, 00076 DisableHeightChange = 2, 00077 LimitVerticalDirection = 4, 00078 ShortestHeightChange = 8 00079 }; 00080 00081 void setFlags( int flags ) { this->flags = flags; }; 00082 00083 ActionResult searchFields(int height = -1, int capabilities = 0); 00084 00086 void setVerticalDirection( int dir ); 00087 00088 int getVerticalDirection() const { return verticalDirection; }; 00089 00090 void calcPath(); 00091 const AStar3D::Path& getPath(); 00092 00093 void setDestination( const MapCoordinate& destination ); 00094 void setDestination( const MapCoordinate3D& destination ); 00095 ASCString getCommandString() const; 00096 00108 bool isFieldReachable( const MapCoordinate& pos, bool direct ); 00109 00110 bool isFieldReachable3D( const MapCoordinate3D& pos, bool direct ); 00111 00112 00118 const set<MapCoordinate3D>& getReachableFields() { return reachableFields; }; 00119 const set<MapCoordinate3D>& getReachableFieldsIndirect() { return reachableFieldsIndirect; }; 00120 00121 const Vehicle* getUnit() const { return UnitCommand::getUnit(); }; 00122 Vehicle* getUnit() { return UnitCommand::getUnit(); }; 00123 00124 bool longDistAvailable( const MapCoordinate& pos ); 00125 00126 virtual vector<MapCoordinate> getCoordinates() const; 00127 00128 int getCompletion(); 00129 bool operatable(); 00130 void rearm(); 00131 00132 }; 00133 00134 #endif 00135
1.5.1