Advanced Strategic Command
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Friends | List of all members
MoveUnitCommand Class Reference

#include <moveunitcommand.h>

Inheritance diagram for MoveUnitCommand:
Inheritance graph
[legend]

Public Types

enum  SeachCapabilities { NoInterrupt = 1, DisableHeightChange = 2, LimitVerticalDirection = 4, ShortestHeightChange = 8 }
 
typedef map< MapCoordinate,
AttackWeap
FieldList
 
- Public Types inherited from Command
enum  State {
  Planned, Evaluated, SetUp, Run,
  Finished, Failed
}
 

Public Member Functions

 MoveUnitCommand (Vehicle *unit)
 
void setFlags (int flags)
 
ActionResult searchFields (int height=-1, int capabilities=0)
 
void setVerticalDirection (int dir)
 defines whether we want to end up either at the same level of height (0), lower(<0), or heigher(>0) More...
 
int getVerticalDirection () const
 
void calcPath ()
 
void calcPath (AStar3D *const astar)
 
const AStar3D::PathgetPath ()
 
void setDestination (const MapCoordinate &destination)
 
void setDestination (const MapCoordinate3D &destination)
 
ASCString getCommandString () const
 
bool isFieldReachable (const MapCoordinate &pos, bool direct)
 checks if the field can be reached by the unit this turn Precondition: searchFields(int,int) was called More...
 
const set< MapCoordinate3D > & getReachableFields ()
 this will return a 2D representation of the reachable fields. More...
 
const set< MapCoordinate3D > & getReachableFieldsIndirect ()
 
const VehiclegetUnit () const
 
VehiclegetUnit ()
 
bool longDistAvailable (const MapCoordinate &pos)
 
virtual vector< MapCoordinategetCoordinates () const
 this is for informational purposes, so the player can see where a Command has taken place when reviewing it More...
 
int getCompletion ()
 
bool operatable ()
 checks if the task can still be operated. More...
 
void rearm ()
 
 ~MoveUnitCommand ()
 
- Public Member Functions inherited from UnitCommand
int getUnitTypeID () const
 
- Public Member Functions inherited from Command
State getState () const
 
ActionResult redo (const Context &context)
 
- Public Member Functions inherited from GameAction
ActionResult execute (const Context &context)
 
ActionResult undo (const Context &context)
 
void read (tnstream &stream)
 
void write (tnstream &stream) const
 
void write (tnstream &stream, bool persistChildren) const
 
virtual ~GameAction ()
 
- Public Member Functions inherited from TaskInterface
virtual ~TaskInterface ()
 

Static Public Member Functions

static bool avail (Vehicle *eht)
 
static bool ascendAvail (Vehicle *eht)
 
static bool descendAvail (Vehicle *eht)
 
- Static Public Member Functions inherited from GameAction
static GameActionreadFromStream (tnstream &stream, GameMap *map)
 

Protected Member Functions

void readData (tnstream &stream)
 
void writeData (tnstream &stream) const
 
GameActionID getID () const
 
ASCString getDescription () const
 
ActionResult go (const Context &context)
 
- Protected Member Functions inherited from UnitCommand
const VehiclegetUnit () const
 
VehiclegetUnit ()
 
int getUnitID () const
 
 UnitCommand (GameMap *map)
 
 UnitCommand (Vehicle *vehicle)
 
void readData (tnstream &stream)
 
void writeData (tnstream &stream) const
 
ActionResult checkExecutionPrecondition () const
 
- Protected Member Functions inherited from Command
 Command (GameMap *gamemap)
 
void setState (State state)
 
virtual ActionResult runAction (const Context &context)
 
virtual ActionResult undoAction (const Context &context)
 
- Protected Member Functions inherited from GameAction
void deleteChildren ()
 
 GameAction (GameMap *map)
 
void addChild (GameAction *action)
 adds a child action. Ownership of the child action is passed to THIS More...
 
virtual ActionResult preCheck ()
 preCheck is called before an action is redone and should check the preconditions for the action. More...
 
virtual ActionResult postCheck ()
 postCheck is called after an action has been redone and should check that the state of the map is exactly the same as it was after the action has been executed the first time. More...
 
virtual bool undoOrderChildFirst () const
 determines the order in which the child actions are undone. More...
 
GameMapgetMap ()
 
const GameMapgetMap () const
 

Friends

template<class Child >
GameActionGameActionCreator (GameMap *map)
 

Detailed Description

Definition at line 36 of file moveunitcommand.h.

Member Typedef Documentation

Definition at line 42 of file moveunitcommand.h.

Member Enumeration Documentation

Enumerator
NoInterrupt 

the unit will not interrupt the movement if it runs onto a mine of into reaction fire

DisableHeightChange 

the unit will not change its height even if that would provide a shortcut

LimitVerticalDirection 
ShortestHeightChange 

we want only results on a certain level of height

Definition at line 76 of file moveunitcommand.h.

Constructor & Destructor Documentation

MoveUnitCommand::MoveUnitCommand ( Vehicle unit)

Definition at line 100 of file moveunitcommand.cpp.

References ContainerBase::getMap(), and GameMap::sigCoordinateShift.

MoveUnitCommand::~MoveUnitCommand ( )

Definition at line 95 of file moveunitcommand.cpp.

Member Function Documentation

bool MoveUnitCommand::ascendAvail ( Vehicle eht)
static

Definition at line 46 of file moveunitcommand.cpp.

References Vehicle::getHeightChange().

Referenced by GuiFunctions::Ascend::available(), and go().

bool MoveUnitCommand::avail ( Vehicle eht)
static
void MoveUnitCommand::calcPath ( )
void MoveUnitCommand::calcPath ( AStar3D *const  astar)
bool MoveUnitCommand::descendAvail ( Vehicle eht)
static

Definition at line 54 of file moveunitcommand.cpp.

References Vehicle::getHeightChange().

Referenced by GuiFunctions::Descend::available(), and go().

ASCString MoveUnitCommand::getCommandString ( ) const
virtual
int MoveUnitCommand::getCompletion ( )
virtual

Implements TaskInterface.

Definition at line 452 of file moveunitcommand.cpp.

vector< MapCoordinate > MoveUnitCommand::getCoordinates ( ) const
virtual

this is for informational purposes, so the player can see where a Command has taken place when reviewing it

Reimplemented from UnitCommand.

Definition at line 470 of file moveunitcommand.cpp.

ASCString MoveUnitCommand::getDescription ( ) const
protectedvirtual

Implements GameAction.

Definition at line 441 of file moveunitcommand.cpp.

References Vehicle::getName(), getUnit(), and MapCoordinate3D::toString().

GameActionID MoveUnitCommand::getID ( ) const
protectedvirtual

Implements GameAction.

Definition at line 436 of file moveunitcommand.cpp.

References ActionRegistry::MoveUnitCommand.

const AStar3D::Path & MoveUnitCommand::getPath ( )
const set<MapCoordinate3D>& MoveUnitCommand::getReachableFields ( )
inline

this will return a 2D representation of the reachable fields.

That means, if the unit can go to different levels of height on the same field, this set will only contain the level of height which can be reached with the least movement.

These functions are geared towards the 2D user interface and are not well suited to AI usage

Definition at line 117 of file moveunitcommand.h.

Referenced by GuiFunctions::MovementBase::execute(), and CargoGuiFunctions::Movement::execute().

const set<MapCoordinate3D>& MoveUnitCommand::getReachableFieldsIndirect ( )
inline
const Vehicle* MoveUnitCommand::getUnit ( ) const
inline
Vehicle* MoveUnitCommand::getUnit ( )
inline

Definition at line 121 of file moveunitcommand.h.

References UnitCommand::getUnit().

int MoveUnitCommand::getVerticalDirection ( ) const
inline
ActionResult MoveUnitCommand::go ( const Context context)
protectedvirtual
bool MoveUnitCommand::isFieldReachable ( const MapCoordinate pos,
bool  direct 
)

checks if the field can be reached by the unit this turn Precondition: searchFields(int,int) was called

Note
this function accepts a 2D position, so you can not check whether the unit can reach a certain level of height
Parameters
posthe destination field to check
directif true then only return true of the unit can stop on the destination field if false, then fields over which the unit can pass, but cannot stop (for example because another unit is standing there) will also return true

Definition at line 285 of file moveunitcommand.cpp.

References MapCoordinate::x, and MapCoordinate::y.

Referenced by GuiFunctions::MovementBase::available(), and SearchReconquerBuilding::testfield().

bool MoveUnitCommand::longDistAvailable ( const MapCoordinate pos)
bool MoveUnitCommand::operatable ( )
virtual

checks if the task can still be operated.

If the task's unit was shot down for example, this would be the method to detect it and return false

Implements TaskInterface.

Definition at line 457 of file moveunitcommand.cpp.

References getUnit().

void MoveUnitCommand::readData ( tnstream stream)
protectedvirtual

Reimplemented from Command.

Definition at line 404 of file moveunitcommand.cpp.

References MapCoordinate3D::read(), UnitCommand::readData(), and tnstream::readInt().

void MoveUnitCommand::rearm ( )
virtual
ActionResult MoveUnitCommand::searchFields ( int  height = -1,
int  capabilities = 0 
)
void MoveUnitCommand::setDestination ( const MapCoordinate destination)
void MoveUnitCommand::setDestination ( const MapCoordinate3D destination)

Definition at line 247 of file moveunitcommand.cpp.

References Command::setState(), and Command::SetUp.

void MoveUnitCommand::setFlags ( int  flags)
inline

Definition at line 82 of file moveunitcommand.h.

void MoveUnitCommand::setVerticalDirection ( int  dir)

defines whether we want to end up either at the same level of height (0), lower(<0), or heigher(>0)

Definition at line 395 of file moveunitcommand.cpp.

References LimitVerticalDirection.

Referenced by GuiFunctions::MovementBase::execute().

void MoveUnitCommand::writeData ( tnstream stream) const
protectedvirtual

Reimplemented from Command.

Definition at line 420 of file moveunitcommand.cpp.

References MapCoordinate3D::write(), UnitCommand::writeData(), and tnstream::writeInt().

Friends And Related Function Documentation

template<class Child >
GameAction* GameActionCreator ( GameMap map)
friend

Definition at line 114 of file action.h.


The documentation for this class was generated from the following files: