Planeshift
Location Class Reference

A Location is a named place on the map, located dynamically by NPCs as scripted. More...

#include <location.h>

Public Member Functions

bool Adjust (iDataConnection *db, const csVector3 &pos, iSector *sector)
 Adjust the postion of this location. More...
 
bool Adjust (iDataConnection *db, const csVector3 &pos, iSector *sector, float rot_angle)
 Adjust the postion of this location. More...
 
bool Adjust (const csVector3 &pos, iSector *sector)
 Adjust the postion of this location. More...
 
bool Adjust (const csVector3 &pos, iSector *sector, float rot_angle)
 Adjust the postion of this location. More...
 
void CalculateBoundingBox ()
 Function to calculate the bounding box for a location. More...
 
bool CheckWithinBounds (iEngine *engine, const csVector3 &pos, const iSector *sector)
 Check if a point is within bounds of this location. More...
 
bool CreateUpdate (iDataConnection *db)
 Create or update an entry for this location in the DB. More...
 
const csBox2 & GetBoundingBox () const
 Return the bounding box for this location. More...
 
uint32_t GetEffectID (iEffectIDAllocator *allocator)
 Return the effect ID for this location or assign a new ID. More...
 
csString GetFlags () const
 Get flags. More...
 
int GetID () const
 Get the DB ID. More...
 
const char * GetName () const
 retrive the name of this location. More...
 
const csVector3 & GetPosition () const
 Return the position of this location. More...
 
float GetRadius () const
 Get the Radius. More...
 
bool GetRandomPosition (iEngine *engine, csVector3 &pos, iSector *&sector)
 Get a random position in the location. More...
 
float GetRotationAngle () const
 Get the rotation angle. More...
 
iSector * GetSector (iEngine *engine)
 Return cached sector or find the sector and cache it from engine. More...
 
iSector * GetSector (iEngine *engine) const
 Return cached sector or find the sector and cache it from engine. More...
 
const char * GetTypeName () const
 Get the type name of this location. More...
 
bool Import (iDocumentNode *node, iDataConnection *db, int typeID)
 Import a location from an XML document. More...
 
LocationInsert (iDataConnection *db, csVector3 &pos, iSector *sector)
 Insert a new point in a region after this location. More...
 
LocationInsert (int id, csVector3 &pos, iSector *sector)
 Insert a new point in a region after this location. More...
 
bool IsCircle ()
 Query if this location is a circle. More...
 
bool IsRegion ()
 Query if this location is a region. More...
 
bool Load (iResultRow &row, iEngine *engine, iDataConnection *db)
 Load a location from the DB. More...
 
 Location ()
 Constructor. More...
 
 Location (LocationType *locationType, const char *locationName, const csVector3 &pos, iSector *sector, float radius, float rot_angle, const csString &flags)
 Constructor. More...
 
bool SetFlag (const csString &flag, bool enable)
 Set flag. More...
 
bool SetFlags (const csString &flags)
 Set flags. More...
 
void SetID (int id)
 Set DB ID. More...
 
void SetName (const csString &name)
 Set the name. More...
 
bool SetRadius (iDataConnection *db, float radius)
 Set Radius and recalculate the boudning box. More...
 
void SetRadius (float radius)
 Set Radius and recalculate the boudning box. More...
 
csString ToString () const
 Create text representation. More...
 
 ~Location ()
 Destructor. More...
 

Static Public Member Functions

static int GetSectorID (iDataConnection *db, const char *name)
 retrive a sector ID. More...
 

Public Attributes

csBox2 boundingBox
 Bounding box used for boundary checks. More...
 
uint32_t effectID
 When displayed in a client this is the effect id. More...
 
int id
 The ID of this location, from the DB. More...
 
int id_prev_loc_in_region
 Prev database ID for a region. More...
 
csArray< Location * > locs
 A number of points for regions. Including self for first location in region. More...
 
csString name
 The name of this location. More...
 
csVector3 pos
 The positon of this location. More...
 
float radius
 The radius of this locaiton. More...
 
Locationregion
 Pointer to first location in a region. More...
 
float rot_angle
 Some location has an angle. More...
 
csWeakRef< iSector > sector
 Cached sector. More...
 
csString sectorName
 The sector where this location is located. More...
 
LocationTypetype
 Points back to location type. More...
 

Detailed Description

A Location is a named place on the map, located dynamically by NPCs as scripted.

Note
Location dosn't support multi sector locations yes.

Definition at line 48 of file location.h.

Constructor & Destructor Documentation

Location::Location ( )

Constructor.

Location::Location ( LocationType locationType,
const char *  locationName,
const csVector3 &  pos,
iSector *  sector,
float  radius,
float  rot_angle,
const csString &  flags 
)

Constructor.

Location::~Location ( )

Destructor.

Member Function Documentation

bool Location::Adjust ( iDataConnection *  db,
const csVector3 &  pos,
iSector *  sector 
)

Adjust the postion of this location.

bool Location::Adjust ( iDataConnection *  db,
const csVector3 &  pos,
iSector *  sector,
float  rot_angle 
)

Adjust the postion of this location.

bool Location::Adjust ( const csVector3 &  pos,
iSector *  sector 
)

Adjust the postion of this location.

bool Location::Adjust ( const csVector3 &  pos,
iSector *  sector,
float  rot_angle 
)

Adjust the postion of this location.

void Location::CalculateBoundingBox ( )

Function to calculate the bounding box for a location.

This function should be called after the location has been loaded or modified.

bool Location::CheckWithinBounds ( iEngine *  engine,
const csVector3 &  pos,
const iSector *  sector 
)

Check if a point is within bounds of this location.

bool Location::CreateUpdate ( iDataConnection *  db)

Create or update an entry for this location in the DB.

Note
Will update if there is a id different from -1.
const csBox2& Location::GetBoundingBox ( ) const

Return the bounding box for this location.

Returns
Bounding box of the location
uint32_t Location::GetEffectID ( iEffectIDAllocator allocator)

Return the effect ID for this location or assign a new ID.

Parameters
allocator
csString Location::GetFlags ( ) const
inline

Get flags.

Note
No flags implemented yet.

Definition at line 102 of file location.h.

int Location::GetID ( ) const
inline

Get the DB ID.

Definition at line 80 of file location.h.

const char* Location::GetName ( ) const
inline

retrive the name of this location.

Definition at line 223 of file location.h.

const csVector3& Location::GetPosition ( ) const
inline

Return the position of this location.

Definition at line 94 of file location.h.

float Location::GetRadius ( ) const
inline

Get the Radius.

Definition at line 125 of file location.h.

bool Location::GetRandomPosition ( iEngine *  engine,
csVector3 &  pos,
iSector *&  sector 
)

Get a random position in the location.

Will return the position found. Do not relay on the state of the parameters if operation failes.

Parameters
engineUsed to find the sector
posThe found position is returned here.
sectorThe found sector is returned here.
Returns
True if position is found.
float Location::GetRotationAngle ( ) const
inline

Get the rotation angle.

Definition at line 140 of file location.h.

iSector* Location::GetSector ( iEngine *  engine)

Return cached sector or find the sector and cache it from engine.

iSector* Location::GetSector ( iEngine *  engine) const

Return cached sector or find the sector and cache it from engine.

static int Location::GetSectorID ( iDataConnection *  db,
const char *  name 
)
static

retrive a sector ID.

const char* Location::GetTypeName ( ) const

Get the type name of this location.

bool Location::Import ( iDocumentNode *  node,
iDataConnection *  db,
int  typeID 
)

Import a location from an XML document.

Location* Location::Insert ( iDataConnection *  db,
csVector3 &  pos,
iSector *  sector 
)

Insert a new point in a region after this location.

Location* Location::Insert ( int  id,
csVector3 &  pos,
iSector *  sector 
)

Insert a new point in a region after this location.

bool Location::IsCircle ( )
inline

Query if this location is a circle.

Definition at line 174 of file location.h.

bool Location::IsRegion ( )
inline

Query if this location is a region.

Returns
return true when this location is a region.
Note
Region is a location with multiple points.

Definition at line 167 of file location.h.

bool Location::Load ( iResultRow &  row,
iEngine *  engine,
iDataConnection *  db 
)

Load a location from the DB.

bool Location::SetFlag ( const csString &  flag,
bool  enable 
)
inline

Set flag.

Note
No flags implemented yet.

Definition at line 118 of file location.h.

bool Location::SetFlags ( const csString &  flags)
inline

Set flags.

Note
No flags implemented yet.

Definition at line 110 of file location.h.

void Location::SetID ( int  id)
inline

Set DB ID.

Definition at line 87 of file location.h.

void Location::SetName ( const csString &  name)
inline

Set the name.

Definition at line 230 of file location.h.

bool Location::SetRadius ( iDataConnection *  db,
float  radius 
)

Set Radius and recalculate the boudning box.

void Location::SetRadius ( float  radius)

Set Radius and recalculate the boudning box.

csString Location::ToString ( ) const

Create text representation.

Member Data Documentation

csBox2 Location::boundingBox

Bounding box used for boundary checks.

Definition at line 60 of file location.h.

uint32_t Location::effectID

When displayed in a client this is the effect id.

Definition at line 63 of file location.h.

int Location::id

The ID of this location, from the DB.

Definition at line 51 of file location.h.

int Location::id_prev_loc_in_region

Prev database ID for a region.

Definition at line 57 of file location.h.

csArray<Location*> Location::locs

A number of points for regions. Including self for first location in region.

Definition at line 56 of file location.h.

csString Location::name

The name of this location.

Definition at line 52 of file location.h.

csVector3 Location::pos

The positon of this location.

Definition at line 53 of file location.h.

float Location::radius

The radius of this locaiton.

Definition at line 55 of file location.h.

Location* Location::region

Pointer to first location in a region.

Definition at line 64 of file location.h.

float Location::rot_angle

Some location has an angle.

Definition at line 54 of file location.h.

csWeakRef<iSector> Location::sector

Cached sector.

Definition at line 61 of file location.h.

csString Location::sectorName

The sector where this location is located.

Definition at line 58 of file location.h.

LocationType* Location::type

Points back to location type.

Definition at line 62 of file location.h.


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