Planeshift
Public Member Functions | Static Public Member Functions | Public Attributes

Location Class Reference

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

#include <location.h>

List of all members.

Public Member Functions

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

Static Public Member Functions

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

Public Attributes

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

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 ( int  id,
csVector3 &  pos,
iSector *  sector 
)

Insert a new point in a region after this location.

Location* Location::Insert ( iDataConnection *  db,
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

Bounding box used for boundary checks.

Definition at line 60 of file location.h.

When displayed in a client this is the effect id.

Definition at line 63 of file location.h.

The ID of this location, from the DB.

Definition at line 51 of file location.h.

Prev database ID for a region.

Definition at line 57 of file location.h.

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.

The radius of this locaiton.

Definition at line 55 of file location.h.

Pointer to first location in a region.

Definition at line 64 of file location.h.

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.

The sector where this location is located.

Definition at line 58 of file location.h.

Points back to location type.

Definition at line 62 of file location.h.


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