eSensor Class Reference

#include <eSensor.h>

Inheritance diagram for eSensor:

Inheritance graph
[legend]
Collaboration diagram for eSensor:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 tCHECKED_PTR_CONST (eHalfEdge) ehit
 eSensor (eGameObject *o, const eCoord &start, const eCoord &d)
virtual void PassEdge (const eWall *w, REAL time, REAL, int=1)
void detect (REAL range)
void SetCurrentFace (eFace *f)
eSensorSetInverseSpeed (REAL inverseSpeed)
 Sets the inverse speed of the sensor.
REAL GetInverseSpeed (void) const
 Gets the inverse speed of the sensor.
eSensor const & GetInverseSpeed (REAL &inverseSpeed) const
 Gets the inverse speed of the sensor.

Public Attributes

REAL hit
int lr
eCoord before_hit

Protected Member Functions

 tCHECKED_PTR (eGameObject) owned

Private Attributes

REAL inverseSpeed_


Detailed Description

Definition at line 39 of file eSensor.h.


Constructor & Destructor Documentation

eSensor::eSensor ( eGameObject o,
const eCoord &  start,
const eCoord &  d 
)

Definition at line 37 of file eSensor.cpp.

References eGameObject::currentFace, NULL, and eGameObject::pos.

00038         :eStackGameObject(o->grid, start,d,o->currentFace)
00039         ,hit(1000),ehit(NULL),lr(0), owned(o) , inverseSpeed_(0)
00040 {
00041     if (owned)
00042     {
00043         currentFace=owned->currentFace;
00044 
00045         // find a better current face if our start postion is not really at the
00046         // current position of the owner
00047         if ( grid && !currentFace || !currentFace->IsInside( pos ) && currentFace->IsInside( owned->pos ) )
00048         {
00049             currentFace = o->grid->FindSurroundingFace( pos, currentFace );
00050         }
00051     }
00052     else
00053         currentFace=NULL;
00054 }


Member Function Documentation

eSensor::tCHECKED_PTR_CONST ( eHalfEdge   ) 

void eSensor::PassEdge ( const eWall w,
REAL  time,
REAL  a,
int  = 1 
) [virtual]

Reimplemented from eGameObject.

Reimplemented in eCameraSensor, gCycleChatBot::Sensor, and gSensor.

Definition at line 56 of file eSensor.cpp.

References before_hit, eGameObject::dir, eCoord, eWall::Edge(), hit, inverseSpeed_, lr, eWall::Massive(), eWall::Point(), REAL, and eWall::Vec().

Referenced by gSensor::PassEdge().

00056                                                          {
00057     if (!w->Massive()){
00058         return;
00059     }
00060 
00061     // extrapolate the hit time
00062     REAL hitTime = owned->LastTime() + time * inverseSpeed_;
00063 
00064     if (owned && !owned->EdgeIsDangerous(w, hitTime, a))
00065         return;
00066 
00067     lr=0;
00068 
00069     const eHalfEdge *e = w->Edge();
00070 
00071     eCoord eEdge_dir=w->Vec();
00072     eCoord collPos = w->Point( a );
00073 
00074     // con << dir << eEdge_dir << '\n';
00075     REAL dec=- eEdge_dir*dir;
00076 
00077     if (dec>0)
00078         lr=1;
00079     else if (dec<0)
00080         lr=-1;
00081     else
00082         lr=0;
00083 
00084     hit=time;
00085     ehit=e;
00086     before_hit=collPos-dir*.000001;
00087 
00088     throw eSensorFinished();
00089 }

Here is the call graph for this function:

Here is the caller graph for this function:

void eSensor::detect ( REAL  range  ) 

Definition at line 95 of file eSensor.cpp.

References before_hit, eGameObject::dir, eDebugLine::Draw(), hit, eGameObject::Move(), eGameObject::pos, and eDebugLine::SetColor().

Referenced by gCycleChatBot::Activate(), gAIPlayer::ActOnData(), eCamera::Bound(), gCycleMovement::CalculateAcceleration(), ClampDisplacement(), gCycleMovement::DoTurn(), gAIPlayer::EmergencySurvive(), gAISensor::gAISensor(), gCycleMovement::GetMaxSpaceAhead(), gCycle::ReadSync(), eCamera::Render(), se_SanifyDisplacement(), gAIPlayer::ThinkPath(), gAIPlayer::ThinkSurvive(), gAIPlayer::ThinkTrace(), and eCamera::Timestep().

00095                               {
00096     //  eCoord start = pos;
00097     //  pos=pos+dir*.01;
00098     before_hit=pos+dir*(range-.001);
00099     hit=range+.00001f;
00100     ehit = 0;
00101 
00102     /*
00103     {
00104       ePoint a(pos);
00105       ePoint b(pos+dir*range);
00106       eEdge e(&a,&b);
00107 
00108       
00109       for(int i=eGameObject::gameObjects.Len()-1;i>=0;i--){
00110         eGameObject *target=gameobject::gameObjects(i);
00111         
00112         if (target->type()==ArmageTron_CYCLE){
00113     gCycle *c=(gCycle *)target;
00114     if (c->Alive() && c!=owned){
00115      const eEdge *oe=c->Edge();
00116      if (oe){
00117        ePoint *meet=e.IntersectWith(oe);
00118      
00119        if (meet){ // whoops. Hit!
00120          REAL ratio=oe->Ratio(*meet);
00121          // gPlayerWall *w=(gPlayerWall *)oe->w;
00122          REAL time=e.Ratio(*meet)*range;
00123          PassEdge(oe,time,ratio,1);
00124          delete meet;
00125        }
00126      }
00127     }
00128         }
00129       } 
00130     }
00131     */
00132 
00133     try
00134     {
00135         Move(pos+dir*range,0,range);
00136     }
00137     catch( eSensorFinished & e )
00138     {
00139     }
00140 
00141 #ifdef DEBUGLINE
00142     if (hit < range)
00143     {
00144         eDebugLine::SetColor  (0, 1, 1);
00145         eDebugLine::Draw(start, .1, before_hit, .1);
00146 
00147         eDebugLine::SetColor  (0, .5, 1);
00148         eDebugLine::Draw(before_hit, .1, before_hit, 2.0);
00149     }
00150     else
00151     {
00152         eDebugLine::SetColor  (1, 0, 0);
00153         eDebugLine::Draw(start, .5, pos, .5);
00154     }
00155 #endif
00156 }

Here is the call graph for this function:

Here is the caller graph for this function:

void eSensor::SetCurrentFace ( eFace f  )  [inline]

Definition at line 52 of file eSensor.h.

References eGameObject::currentFace.

00052 { currentFace = f ; }

eSensor & eSensor::SetInverseSpeed ( REAL  inverseSpeed  )  [inline]

Sets the inverse speed of the sensor.

Parameters:
inverseSpeed the inverse speed of the sensor to set
Returns:
A reference to this to allow chaining

Definition at line 106 of file eSensor.h.

References inverseSpeed_.

00107 {
00108     this->inverseSpeed_ = inverseSpeed;
00109     return *this;
00110 }

REAL eSensor::GetInverseSpeed ( void   )  const [inline]

Gets the inverse speed of the sensor.

Returns:
the inverse speed of the sensor

Definition at line 73 of file eSensor.h.

00074 {
00075     return this->inverseSpeed_;
00076 }

eSensor const & eSensor::GetInverseSpeed ( REAL inverseSpeed  )  const [inline]

Gets the inverse speed of the sensor.

Parameters:
inverseSpeed the inverse speed of the sensor to fill
Returns:
A reference to this to allow chaining

Definition at line 89 of file eSensor.h.

References inverseSpeed_.

00090 {
00091     inverseSpeed = this->inverseSpeed_;
00092     return *this;
00093 }

eSensor::tCHECKED_PTR ( eGameObject   )  [protected]


Member Data Documentation

REAL eSensor::hit

Definition at line 41 of file eSensor.h.

Referenced by gCycleChatBot::Activate(), gAIPlayer::ActOnData(), eCamera::Bound(), gCycleMovement::CalculateAcceleration(), ClampDisplacement(), detect(), gCycleMovement::DoTurn(), gAIPlayer::EmergencySurvive(), gAISensor::gAISensor(), gCycleMovement::GetMaxSpaceAhead(), PassEdge(), eCamera::Render(), se_SanifyDisplacement(), sg_Gap(), gAIPlayer::ThinkPath(), gAIPlayer::ThinkSurvive(), gAIPlayer::ThinkTrace(), and eCamera::Timestep().

int eSensor::lr

Definition at line 43 of file eSensor.h.

Referenced by gHitData::AddHit(), blocks(), gCycleChatBot::Distance(), gSensor::PassEdge(), and PassEdge().

eCoord eSensor::before_hit

Definition at line 44 of file eSensor.h.

Referenced by gHitData::AddHit(), gEnemyInfluence::AddSensor(), blocks(), eCamera::Bound(), detect(), gCycleChatBot::Distance(), PassEdge(), gCycle::ReadSync(), and sg_DropTempWall().

REAL eSensor::inverseSpeed_ [private]

Definition at line 60 of file eSensor.h.

Referenced by GetInverseSpeed(), PassEdge(), and SetInverseSpeed().


The documentation for this class was generated from the following files:
Generated on Sat Mar 15 23:29:24 2008 for Armagetron Advanced by  doxygen 1.5.4