Vegastrike 0.5.1 rc1  1.0
Original sources for Vegastrike Evolved
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Orders::MatchLinearVelocity Class Reference

#include <flybywire.h>

Inheritance diagram for Orders::MatchLinearVelocity:
Order

Public Member Functions

 MatchLinearVelocity (const Vector &desired, bool Local, bool afterburner, bool fini=true)
 
void Execute ()
 
void SetDesiredVelocity (const Vector &desired, bool Local)
 
void SetAfterburn (bool use_afterburn)
 
virtual ~MatchLinearVelocity ()
 
virtual std::string getOrderDescription ()
 
- Public Member Functions inherited from Order
virtual void ChooseTarget ()
 this function calls the destructor (needs to be overridden for python; More...
 
virtual bool PursueTarget (Unit *, bool isleader)
 
void ClearMessages ()
 clears the messasges of this order More...
 
 Order ()
 The default constructor setting everything to NULL and no dependency on order. More...
 
 Order (int type, int subtype)
 The constructor that specifies what order dependencies this order has. More...
 
virtual void Destroy ()
 The virutal function that unrefs all memory then calls Destruct () which takes care of unreffing this or calling delete on this. More...
 
OrderqueryType (unsigned int type)
 returns a pointer to the first order that may be bitwised ored with that type More...
 
OrderqueryAny (unsigned int type)
 returns a pointer to the first order that may be bitwise ored with any type More...
 
void eraseType (unsigned int type)
 Erases all orders that bitwise OR with that type. More...
 
bool AttachOrder (Unit *targets)
 Attaches a group of targets to this order (used for strategery-type games) More...
 
bool AttachOrder (QVector target)
 Attaches a navigation point to this order. More...
 
bool AttachSelfOrder (Unit *targets)
 Attaches a group (form up) to this order. More...
 
OrderEnqueueOrder (Order *ord)
 Enqueues another order that will be executed (in parallel perhaps) when next void Execute() is called. More...
 
OrderReplaceOrder (Order *ord)
 Replaces the first order of that type in the order queue. More...
 
bool Done ()
 
int getType ()
 
int getSubType ()
 
virtual void SetParent (Unit *parent1)
 Sets the parent of this Unit. Any virtual functions must call this one. More...
 
UnitGetParent () const
 
virtual void Communicate (const class CommunicationMessage &c)
 Sends a communication message from the Unit (encapulated in c) to this unit. More...
 
virtual void ProcessCommMessage (class CommunicationMessage &c)
 processes a single message...generally called by the Messages() func More...
 
virtual void ProcessCommunicationMessages (float CommRepsonseTime, bool RemoveMessageProcessed)
 responds (or does not) to certain messages in the message queue More...
 
OrderfindOrder (Order *ord)
 return pointer to order or NULL if not found More...
 
void eraseOrder (Order *ord)
 erase that order from the list More...
 
OrderEnqueueOrderFirst (Order *ord)
 enqueue order as first order More...
 
virtual olist_tgetOrderList ()
 returns the orderlist (NULL for orders that haven't got any) More...
 
virtual void AdjustRelationTo (Unit *un, float factor)
 
OrderfindOrderList ()
 searches the suborders recursively for the first order that has an orderlist More...
 
std::string createFullOrderDescription (int level=0)
 
void setActionString (std::string astring)
 
std::string getActionString ()
 
virtual float getMood ()
 

Protected Attributes

Vector desired_velocity
 werld space... generally r*speed or local space More...
 
bool LocalVelocity
 specified in Local or World coordinates More...
 
bool willfinish
 
bool afterburn
 
- Protected Attributes inherited from Order
Unitparent
 The unit this order is attached to. More...
 
unsigned int type
 The bit code (from ORDERTYPES) that this order is (for parallel execution) More...
 
unsigned int subtype
 
bool done
 Whether or not this order is done. More...
 
UnitContainer group
 If this order applies to a group of units (as in form up with this group) More...
 
QVector targetlocation
 If this order applies to a physical location in world space. More...
 
std::vector< Order * > suborders
 The queue of suborders that will be executed in parallel according to bit code. More...
 
std::list< class
CommunicationMessage * > 
messagequeue
 a bunch of communications that have not been answered CommunicationMessages are actually containing reference to a nice Finite State Machine that can allow a player to have a reasonable conversation with an AI More...
 
std::string actionstring
 

Additional Inherited Members

- Public Types inherited from Order
enum  ORDERTYPES {
  MOVEMENT =1, FACING =2, WEAPON =4, CLOAKING =8,
  ALLTYPES =(1|2|4|8)
}
 The varieties of order types MOVEMENT,FACING, and WEAPON orders may not be mutually executed (lest one engine goes left, the other right) More...
 
enum  SUBORDERTYPES { SLOCATION =1, STARGET =2, SSELF =4 }
 
- Protected Member Functions inherited from Order
virtual ~Order ()
 
virtual void Destructor ()
 changes the local relation of this unit to another...may inform superiors about "good" or bad! behavior depending on the AI More...
 

Detailed Description

This class attempts to match a given Linear velocity given a desired velocity That velocity can be local ("all ahead full") or in world space ("lets fire thrusters towards planet")

Definition at line 13 of file flybywire.h.

Constructor & Destructor Documentation

Orders::MatchLinearVelocity::MatchLinearVelocity ( const Vector desired,
bool  Local,
bool  afterburner,
bool  fini = true 
)
inline

Definition at line 22 of file flybywire.h.

References Order::done.

22  : MatchLinearVelocity( const Vector &desired, bool Local, bool afterburner, bool fini = true ) : Order( MOVEMENT,
23  SLOCATION )
24  , desired_velocity( desired )
25  , LocalVelocity( Local )
26  , willfinish( fini )
27  , afterburn( afterburner )
28  {
29  done = false;
30  }
MatchLinearVelocity::~MatchLinearVelocity ( )
virtual

Definition at line 73 of file flybywire.cpp.

References VSFileSystem::vs_fprintf().

74 {
75 #ifdef ORDERDEBUG
76  VSFileSystem::vs_fprintf( stderr, "mlv%x", this );
77  fflush( stderr );
78 #endif
79 }

Member Function Documentation

void MatchLinearVelocity::Execute ( )
virtual

don't need to clamp thrust since the Thrust does it for you

caution might change

Reimplemented from Order.

Definition at line 57 of file flybywire.cpp.

References Order::done, i, MATCHLINVELEXECUTE, MATCHLINVELSETUP, Order::suborders, VELTHRESHOLD, VSFileSystem::vs_fprintf(), and willfinish.

58 {
59  if ( !suborders.empty() ) {
60  static int i = 0;
61  if (i++%1000 == 0)
62  VSFileSystem::vs_fprintf( stderr, "cannot execute suborders as Linear Velocity Matcher" ); //error printout just in case
63  }
65  if (willfinish) {
66  if ( (done = fabs( desired.i+FrameOfRef.i-velocity.i ) < VELTHRESHOLD && fabs( desired.j+FrameOfRef.j-velocity.j )
67  < VELTHRESHOLD && fabs( desired.k+FrameOfRef.k-velocity.k ) < VELTHRESHOLD) )
68  return;
69  }
71 }
virtual std::string Orders::MatchLinearVelocity::getOrderDescription ( )
inlinevirtual

Reimplemented from Order.

Definition at line 42 of file flybywire.h.

43  {
44  return "mlv";
45  }
void Orders::MatchLinearVelocity::SetAfterburn ( bool  use_afterburn)
inline

Definition at line 37 of file flybywire.h.

References afterburn.

38  {
39  afterburn = use_afterburn;
40  }
void Orders::MatchLinearVelocity::SetDesiredVelocity ( const Vector desired,
bool  Local 
)
inline

Definition at line 32 of file flybywire.h.

References desired_velocity, and LocalVelocity.

33  {
34  desired_velocity = desired;
35  LocalVelocity = Local;
36  }

Member Data Documentation

bool Orders::MatchLinearVelocity::afterburn
protected

Definition at line 21 of file flybywire.h.

Referenced by SetAfterburn().

Vector Orders::MatchLinearVelocity::desired_velocity
protected

werld space... generally r*speed or local space

Definition at line 17 of file flybywire.h.

Referenced by SetDesiredVelocity().

bool Orders::MatchLinearVelocity::LocalVelocity
protected

specified in Local or World coordinates

Definition at line 19 of file flybywire.h.

Referenced by SetDesiredVelocity().

bool Orders::MatchLinearVelocity::willfinish
protected

Definition at line 20 of file flybywire.h.

Referenced by Execute().


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