19 #ifndef __LOCATION_H__ 20 #define __LOCATION_H__ 22 #include <csutil/csstring.h> 23 #include <csgeom/vector3.h> 24 #include <csgeom/box.h> 25 #include <csutil/parray.h> 26 #include <csutil/list.h> 27 #include <iengine/sector.h> 28 #include <csutil/weakref.h> 72 Location(
LocationType* locationType,
const char* locationName,
const csVector3 &pos, iSector* sector,
float radius,
float rot_angle,
const csString &flags);
118 bool SetFlag(
const csString &flag,
bool enable)
151 bool Load(iResultRow &row, iEngine* engine, iDataConnection* db);
160 bool Import(iDocumentNode* node, iDataConnection* db,
int typeID);
169 return locs.GetSize() != 0;
176 return locs.GetSize() == 0;
185 iSector*
GetSector(iEngine* engine)
const;
202 bool CheckWithinBounds(iEngine* engine,
const csVector3 &pos,
const iSector* sector);
219 static int GetSectorID(iDataConnection* db,
const char* name);
225 return name.GetDataSafe();
242 bool Adjust(iDataConnection* db,
const csVector3 &pos, iSector* sector);
246 bool Adjust(iDataConnection* db,
const csVector3 &pos, iSector* sector,
float rot_angle);
250 bool Adjust(
const csVector3 &pos, iSector* sector);
254 bool Adjust(
const csVector3 &pos, iSector* sector,
float rot_angle);
258 Location*
Insert(iDataConnection* db, csVector3 &pos, iSector* sector);
301 bool Load(iDocumentNode* node);
302 bool Import(iDocumentNode* node, iDataConnection*
db);
303 bool ImportLocations(iDocumentNode* node, iDataConnection*
db);
307 bool Load(iResultRow &row, iEngine* engine, iDataConnection*
db);
311 void AddLocation(
Location* location);
315 void RemoveLocation(
Location* location);
346 return name.GetDataSafe();
366 bool Load(iEngine* engine, iDataConnection*
db);
370 int GetNumberOfLocations()
const;
392 Location* FindLocation(
const char* typeName,
const char*
name);
404 size_t FindLocationsInSector(iEngine* engine, iSector*
sector, csList<Location*> &list);
408 Location* FindNearestLocation(
psWorld* world, csVector3 &
pos, iSector* sector,
float range,
float* found_range);
412 Location* FindNearestLocation(
psWorld* world,
const char* typeName, csVector3 &pos, iSector* sector,
float range,
float* found_range);
416 Location* FindRandomLocation(
psWorld* world,
const char* typeName, csVector3 &pos, iSector* sector,
float range,
float* found_range);
420 csHash<LocationType*, csString>::GlobalIterator GetIterator();
424 Location* CreateLocation(iDataConnection* db,
LocationType* locationType,
const char* locationName,
426 const csString &flags);
430 Location* CreateLocation(
const char* locationTypeName,
const char* locationName,
431 const csVector3 &pos, iSector* sector,
float radius,
float rot_angle,
432 const csString &flags);
437 const csVector3 &pos, iSector* sector,
float radius,
float rot_angle,
438 const csString &flags);
442 LocationType* CreateLocationType(iDataConnection* db,
const csString &locationName);
446 LocationType* CreateLocationType(
const csString &locationName);
450 LocationType* CreateLocationType(
int id,
const csString &locationName);
454 bool RemoveLocationType(iDataConnection* db,
const csString &locationName);
458 bool RemoveLocationType(
const csString &locationName);
461 csHash<LocationType*, csString> loctypes;
462 csArray<Location*> all_locations;
void SetID(int id)
Set DB ID.
psWorld is in charge of managing all regions (zone map files) and loading/unloading them as needed...
const char * GetName() const
retrive the name of this location.
iSector * GetSector(iEngine *engine)
Return cached sector or find the sector and cache it from engine.
bool SetFlags(const csString &flags)
Set flags.
float GetRadius() const
Get the Radius.
bool Adjust(iDataConnection *db, const csVector3 &pos, iSector *sector)
Adjust the postion of this location.
int id
The DB ID of this location type.
csString sectorName
The sector where this location is located.
int GetID() const
retrive the ID of this location type.
bool IsCircle()
Query if this location is a circle.
float GetRotationAngle() const
Get the rotation angle.
void CalculateBoundingBox()
Function to calculate the bounding box for a location.
static int GetSectorID(iDataConnection *db, const char *name)
retrive a sector ID.
const csVector3 & GetPosition() const
Return the position of this location.
csArray< Location * > locs
All the location of this location type.
int GetID() const
Get the DB ID.
bool Load(iResultRow &row, iEngine *engine, iDataConnection *db)
Load a location from the DB.
uint32_t GetEffectID(iEffectIDAllocator *allocator)
Return the effect ID for this location or assign a new ID.
bool CheckWithinBounds(iEngine *engine, const csVector3 &pos, const iSector *sector)
Check if a point is within bounds of this location.
This stores a vector of positions listing a set of points defining a common type of location...
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.
iDataConnection * db
Global connection to the Database. Set from the psDatabase class.
bool Import(iDocumentNode *node, iDataConnection *db, int typeID)
Import a location from an XML document.
Manager that manage all locations and location types.
bool SetFlag(const csString &flag, bool enable)
Set flag.
int id
The ID of this location, from the DB.
Location * region
Pointer to first location in a region.
csBox2 boundingBox
Bounding box used for boundary checks.
const csBox2 & GetBoundingBox() const
Return the bounding box for this location.
csWeakRef< iSector > sector
Cached sector.
bool SetRadius(iDataConnection *db, float radius)
Set Radius and recalculate the boudning box.
float radius
The radius of this locaiton.
csString name
The name of this location type.
void SetName(const csString &name)
Set the name.
Helper interface to allocate effect IDs.
Location * Insert(iDataConnection *db, csVector3 &pos, iSector *sector)
Insert a new point in a region after this location.
bool IsRegion()
Query if this location is a region.
csString ToString() const
Create text representation.
int id_prev_loc_in_region
Prev database ID for a region.
csString GetFlags() const
Get flags.
bool CreateUpdate(iDataConnection *db)
Create or update an entry for this location in the DB.
bool GetRandomPosition(iEngine *engine, csVector3 &pos, iSector *§or)
Get a random position in the location.
LocationType * type
Points back to location type.
A Location is a named place on the map, located dynamically by NPCs as scripted.
uint32_t effectID
When displayed in a client this is the effect id.
float rot_angle
Some location has an angle.
const char * GetName() const
retrive the name of this location type.
const char * GetTypeName() const
Get the type name of this location.