FIFE
|
#include <object.h>
Public Member Functions | |
Object (const std::string &identifier, const std::string &name_space, Object *inherited=NULL) | |
Constructor An object may optionally inherit default attributes from another object. More... | |
~Object () | |
Destructor. More... | |
const std::string & | getId () const |
const std::string & | getNamespace () const |
void | setId (const std::string &id) |
Sets the identifier for this object. More... | |
Action * | createAction (const std::string &identifier, bool is_default=false) |
Adds new action with given id. More... | |
Action * | getAction (const std::string &identifier) const |
Gets action with given id. More... | |
std::list< std::string > | getActionIds () const |
Gets all available action ids of the object and packs them into a list. More... | |
void | setDefaultAction (const std::string &identifier) |
Sets default action assigned to this object. More... | |
Action * | getDefaultAction () const |
Gets default action assigned to this object. More... | |
void | setPather (IPather *pather) |
Sets pather used by instances created out of this object. More... | |
IPather * | getPather () const |
Gets associated pather. More... | |
Object * | getInherited () const |
Gets an object where this object was inherited from. More... | |
void | adoptVisual (IVisual *visual) |
Sets visualization to be used. More... | |
template<typename T > | |
T * | getVisual () const |
Gets used visualization. More... | |
void | setBlocking (bool blocking) |
Sets if object blocks movement. More... | |
bool | isBlocking () const |
Gets if object blocks movement. More... | |
void | setStatic (bool stat) |
Set to true, if object is such that it doesn't move. More... | |
bool | isStatic () const |
Gets if object moves. More... | |
void | setFilename (const std::string &file) |
const std::string & | getFilename () const |
void | setCellStackPosition (uint8_t position) |
Sets the cell stack position. More... | |
uint8_t | getCellStackPosition () const |
Returns cell stack position. More... | |
bool | isSpecialCost () const |
Gets if object uses special cost. More... | |
void | setCostId (const std::string &cost) |
Sets the cost id. More... | |
const std::string & | getCostId () const |
Returns the cost id. More... | |
void | setCost (double cost) |
Sets the cost. More... | |
double | getCost () const |
Returns the cost. More... | |
bool | isMultiObject () const |
Gets if object uses special cost. More... | |
void | addMultiPartId (const std::string &partId) |
Adds a multi part identifier. More... | |
const std::list< std::string > & | getMultiPartIds () const |
Returns all multi part identifiers. More... | |
void | removeMultiPartId (const std::string &partId) |
Removes a multi part identifier. More... | |
void | removeAllMultiPartIds () |
Removes all multi part identifiers. More... | |
bool | isMultiPart () const |
Gets if object is a part of a multi object. More... | |
void | setMultiPart (bool part) |
Sets the object as a part of a multi object. More... | |
void | addMultiPart (Object *obj) |
Adds a object as a part of a multi object. More... | |
const std::set< Object * > & | getMultiParts () const |
Returns all multi part objects. More... | |
void | removeMultiPart (Object *obj) |
Removes a multi part object. More... | |
void | removeMultiParts () |
Removes all multi part objects. More... | |
void | addMultiPartCoordinate (int32_t rotation, ModelCoordinate coord) |
Adds rotationally dependent coordinates for this object part. More... | |
const std::multimap< int32_t, ModelCoordinate > & | getMultiPartCoordinates () const |
Returns all rotationally dependent coordinates from this object part. More... | |
std::vector< ModelCoordinate > | getMultiPartCoordinates (int32_t rotation) |
Returns all object part coordinates for the given rotation. More... | |
std::vector< ModelCoordinate > | getMultiObjectCoordinates (int32_t rotation) |
Returns all multi object coordinates for the given rotation. More... | |
void | setRotationAnchor (const ExactModelCoordinate &anchor) |
Sets the rotation anchor for this multi object. More... | |
const ExactModelCoordinate & | getRotationAnchor () const |
Returns the rotation anchor for this multi object. More... | |
void | setRestrictedRotation (bool restrict) |
Sets the rotation to restricted. More... | |
bool | isRestrictedRotation () const |
Gets if object uses restricted rotations. More... | |
int32_t | getRestrictedRotation (int32_t rotation) |
Returns the most obvious rotation, based on multi coordinates. More... | |
void | setZStepRange (int32_t zRange) |
Sets z-step range for object. More... | |
int32_t | getZStepRange () const |
Returns z-step range from object. More... | |
void | setArea (const std::string &id) |
Sets the area id that the instances of this object adds to their cells. More... | |
const std::string & | getArea () const |
Gets the area id that the instances of this object adds to their cells. More... | |
void | addWalkableArea (const std::string &id) |
Adds an area id to walkable area. More... | |
void | removeWalkableArea (const std::string &id) |
Removes an area id from walkable areas. More... | |
const std::list< std::string > & | getWalkableAreas () const |
Returns a list that contains all walkable area ids. More... | |
bool | operator== (const Object &obj) const |
Compares equality of two objects. More... | |
bool | operator!= (const Object &obj) const |
Compares unequality of two objects. More... | |
Private Attributes | |
std::string | m_id |
identifier More... | |
std::string | m_namespace |
namespace More... | |
std::string | m_filename |
filename More... | |
Object * | m_inherited |
pointer to inherited object More... | |
std::map< std::string, Action * > * | m_actions |
holds action ids and assigned actions More... | |
bool | m_blocking |
indicates if object blocks More... | |
bool | m_static |
indicates if object is static More... | |
IPather * | m_pather |
pointer to pathfinder More... | |
IVisual * | m_visual |
pointer to object visual More... | |
Action * | m_defaultAction |
pointer to default action More... | |
uint8_t | m_cellStack |
position on cellstack More... | |
std::string | m_costId |
cost identifier More... | |
double | m_cost |
cost value, default 1.0 More... | |
bool | m_multiPart |
indicates if object is part of multi object More... | |
bool | m_restrictedRotation |
indicates if object uses only restricted rotations More... | |
int32_t | m_zRange |
z range value More... | |
std::list< std::string > | m_multiPartIds |
list with part identifiers More... | |
ExactModelCoordinate | m_rotationAnchor |
rotation anchor More... | |
std::set< Object * > | m_multiParts |
set with part objects More... | |
type_angle2id | m_partAngleMap |
part object angles More... | |
type_angle2id | m_multiAngleMap |
multi object angles More... | |
std::multimap< int32_t, ModelCoordinate > | m_multiPartCoordinates |
part object coordinates More... | |
std::multimap< int32_t, ModelCoordinate > | m_multiObjectCoordinates |
multi object coordinates More... | |
std::string | m_area |
std::list< std::string > | m_walkableAreas |
Object class.
Objects describe the properties of objects. Objects may inherit default values from another object.
FIFE::Object::Object | ( | const std::string & | identifier, |
const std::string & | name_space, | ||
Object * | inherited = NULL |
||
) |
Constructor An object may optionally inherit default attributes from another object.
This object may override these defaults, but it may not CHANGE the inherited values.
Objects are created by calling Model::createObject, thus this method should really be called only by Model or test code
Definition at line 37 of file object.cpp.
FIFE::Object::~Object | ( | ) |
void FIFE::Object::addMultiPart | ( | Object * | obj | ) |
Adds a object as a part of a multi object.
obj | A pointer to the multi part object. |
Definition at line 231 of file object.cpp.
References m_multiParts.
void FIFE::Object::addMultiPartCoordinate | ( | int32_t | rotation, |
ModelCoordinate | coord | ||
) |
Adds rotationally dependent coordinates for this object part.
rotation | A integer value for the angle. |
coord | A ModelCoordinate as relative coordinate, 0,0 is always the multi object center. |
Definition at line 248 of file object.cpp.
References m_multiPartCoordinates, and m_partAngleMap.
Referenced by FIFE::ObjectLoader::load(), and FIFE::AtlasLoader::parseObject().
void FIFE::Object::addMultiPartId | ( | const std::string & | partId | ) |
Adds a multi part identifier.
partId | A const reference to a string that holds the identifier. |
Definition at line 201 of file object.cpp.
References m_multiPartIds.
Referenced by FIFE::ObjectLoader::load(), and FIFE::AtlasLoader::parseObject().
void FIFE::Object::addWalkableArea | ( | const std::string & | id | ) |
Adds an area id to walkable area.
The instances of this object can only walk on cells that part of the given areas.
id | The area id. |
Definition at line 338 of file object.cpp.
References m_walkableAreas.
Referenced by FIFE::ObjectLoader::load(), and FIFE::AtlasLoader::parseObject().
|
inline |
Action * FIFE::Object::createAction | ( | const std::string & | identifier, |
bool | is_default = false |
||
) |
Adds new action with given id.
In case there is action already with given id, returns it instead of new object Action instances are managed by object
identifier | An identifier or name to give the action. |
is_default | if true, becomes default action for this object default objects are used e.g. when showing them on editor. if multiple default actions are created, last one remains. In case there's no explicit default action created, first action created becomes the default |
Definition at line 69 of file object.cpp.
References getAction(), m_actions, and m_defaultAction.
Referenced by FIFE::ObjectLoader::load().
Action * FIFE::Object::getAction | ( | const std::string & | identifier | ) | const |
Gets action with given id.
If not found, returns NULL
Definition at line 92 of file object.cpp.
References getAction(), m_actions, and m_inherited.
Referenced by createAction(), getAction(), FIFE::Instance::initializeAction(), FIFE::MapLoader::load(), FIFE::Instance::move(), and setDefaultAction().
std::list< std::string > FIFE::Object::getActionIds | ( | ) | const |
Gets all available action ids of the object and packs them into a list.
Definition at line 106 of file object.cpp.
References m_actions.
const std::string & FIFE::Object::getArea | ( | ) | const |
Gets the area id that the instances of this object adds to their cells.
Definition at line 334 of file object.cpp.
References m_area.
Referenced by FIFE::Cell::addInstance(), and FIFE::Cell::removeInstance().
uint8_t FIFE::Object::getCellStackPosition | ( | ) | const |
Returns cell stack position.
Definition at line 173 of file object.cpp.
References m_cellStack.
Referenced by FIFE::MapSaver::save().
double FIFE::Object::getCost | ( | ) | const |
Returns the cost.
Definition at line 193 of file object.cpp.
References m_cost.
Referenced by FIFE::Instance::getCost(), and FIFE::MapSaver::save().
const std::string & FIFE::Object::getCostId | ( | ) | const |
Returns the cost id.
Definition at line 185 of file object.cpp.
References m_costId.
Referenced by FIFE::Instance::getCostId(), and FIFE::MapSaver::save().
|
inline |
Gets default action assigned to this object.
If none available, returns NULL
Definition at line 101 of file object.h.
References m_defaultAction.
Referenced by FIFE::LayerCache::updateVisual().
const std::string & FIFE::Object::getFilename | ( | ) | const |
Definition at line 165 of file object.cpp.
References m_filename.
|
inline |
Definition at line 68 of file object.h.
References m_id.
Referenced by FIFE::Model::deleteObject(), operator!=(), operator==(), and FIFE::MapSaver::save().
|
inline |
Gets an object where this object was inherited from.
Definition at line 114 of file object.h.
References m_inherited.
std::vector< ModelCoordinate > FIFE::Object::getMultiObjectCoordinates | ( | int32_t | rotation | ) |
Returns all multi object coordinates for the given rotation.
rotation | A integer value for the angle. |
Definition at line 270 of file object.cpp.
References FIFE::getIndexByAngle(), m_multiAngleMap, m_multiObjectCoordinates, and m_multiParts.
Referenced by FIFE::Instance::follow(), FIFE::Route::getOccupiedCells(), FIFE::Instance::move(), and FIFE::Instance::processMovement().
const std::multimap< int32_t, ModelCoordinate > & FIFE::Object::getMultiPartCoordinates | ( | ) | const |
Returns all rotationally dependent coordinates from this object part.
Definition at line 253 of file object.cpp.
References m_multiPartCoordinates.
std::vector< ModelCoordinate > FIFE::Object::getMultiPartCoordinates | ( | int32_t | rotation | ) |
Returns all object part coordinates for the given rotation.
rotation | A integer value for the angle. |
Definition at line 257 of file object.cpp.
References FIFE::getIndexByAngle(), m_multiPartCoordinates, and m_partAngleMap.
const std::list< std::string > & FIFE::Object::getMultiPartIds | ( | ) | const |
Returns all multi part identifiers.
Definition at line 205 of file object.cpp.
References m_multiPartIds.
const std::set< Object * > & FIFE::Object::getMultiParts | ( | ) | const |
Returns all multi part objects.
Definition at line 235 of file object.cpp.
References m_multiParts.
|
inline |
Definition at line 69 of file object.h.
References m_namespace.
Referenced by FIFE::Model::deleteObject(), operator!=(), operator==(), FIFE::InstanceRenderer::renderAlreadySorted(), FIFE::InstanceRenderer::renderUnsorted(), and FIFE::MapSaver::save().
|
inline |
Gets associated pather.
Definition at line 109 of file object.h.
References m_pather.
Referenced by FIFE::Instance::initializeAction().
int32_t FIFE::Object::getRestrictedRotation | ( | int32_t | rotation | ) |
Returns the most obvious rotation, based on multi coordinates.
rotation | A integer value for the original angle. |
Definition at line 312 of file object.cpp.
References FIFE::getIndexByAngle(), m_multiAngleMap, and m_partAngleMap.
Referenced by FIFE::Instance::updateMultiInstances().
const ExactModelCoordinate & FIFE::Object::getRotationAnchor | ( | ) | const |
Returns the rotation anchor for this multi object.
Definition at line 300 of file object.cpp.
References m_rotationAnchor.
Referenced by FIFE::Instance::updateMultiInstances().
|
inline |
Gets used visualization.
Definition at line 122 of file object.h.
References m_visual.
Referenced by FIFE::ObjectVisual::create(), FIFE::RenderItem::getStaticImageIndexByAngle(), FIFE::ObjectLoader::load(), and FIFE::AtlasLoader::parseObject().
const std::list< std::string > & FIFE::Object::getWalkableAreas | ( | ) | const |
Returns a list that contains all walkable area ids.
Definition at line 348 of file object.cpp.
References m_walkableAreas.
Referenced by FIFE::Instance::follow(), FIFE::Route::getLimitedAreas(), FIFE::Route::isAreaLimited(), FIFE::Instance::move(), and FIFE::Instance::processMovement().
int32_t FIFE::Object::getZStepRange | ( | ) | const |
Returns z-step range from object.
In case it is not limited -1 is returned.
Definition at line 326 of file object.cpp.
References m_zRange.
Referenced by FIFE::Instance::follow(), FIFE::Route::getZStepRange(), FIFE::Instance::move(), and FIFE::Instance::processMovement().
bool FIFE::Object::isBlocking | ( | ) | const |
Gets if object blocks movement.
Definition at line 141 of file object.cpp.
References isBlocking(), m_blocking, and m_inherited.
Referenced by isBlocking(), and FIFE::BlockingInfoRenderer::render().
bool FIFE::Object::isMultiObject | ( | ) | const |
Gets if object uses special cost.
Definition at line 197 of file object.cpp.
References m_multiPartIds.
Referenced by FIFE::Instance::Instance(), FIFE::Route::isMultiCell(), and FIFE::Instance::isMultiCell().
bool FIFE::Object::isMultiPart | ( | ) | const |
Gets if object is a part of a multi object.
Definition at line 223 of file object.cpp.
References m_multiPart.
Referenced by FIFE::MapSaver::save(), and FIFE::Instance::update().
bool FIFE::Object::isRestrictedRotation | ( | ) | const |
Gets if object uses restricted rotations.
Definition at line 308 of file object.cpp.
References m_restrictedRotation.
Referenced by FIFE::Instance::updateMultiInstances().
bool FIFE::Object::isSpecialCost | ( | ) | const |
Gets if object uses special cost.
Definition at line 177 of file object.cpp.
References m_costId.
Referenced by FIFE::MapSaver::save().
bool FIFE::Object::isStatic | ( | ) | const |
Gets if object moves.
Definition at line 151 of file object.cpp.
References isStatic(), m_inherited, and m_static.
Referenced by isStatic(), and FIFE::LayerCache::updateVisual().
bool FIFE::Object::operator!= | ( | const Object & | obj | ) | const |
Compares unequality of two objects.
Definition at line 356 of file object.cpp.
References getId(), getNamespace(), m_id, and m_namespace.
bool FIFE::Object::operator== | ( | const Object & | obj | ) | const |
Compares equality of two objects.
Definition at line 352 of file object.cpp.
References getId(), getNamespace(), m_id, and m_namespace.
void FIFE::Object::removeAllMultiPartIds | ( | ) |
Removes all multi part identifiers.
Definition at line 219 of file object.cpp.
References m_multiPartIds.
void FIFE::Object::removeMultiPart | ( | Object * | obj | ) |
Removes a multi part object.
obj | A pointer to the part object. |
Definition at line 239 of file object.cpp.
References m_multiParts.
void FIFE::Object::removeMultiPartId | ( | const std::string & | partId | ) |
Removes a multi part identifier.
partId | A const reference to a string that holds the identifier. |
Definition at line 209 of file object.cpp.
References m_multiPartIds.
void FIFE::Object::removeMultiParts | ( | ) |
void FIFE::Object::removeWalkableArea | ( | const std::string & | id | ) |
Removes an area id from walkable areas.
id | The area id. |
Definition at line 344 of file object.cpp.
References m_walkableAreas.
void FIFE::Object::setArea | ( | const std::string & | id | ) |
Sets the area id that the instances of this object adds to their cells.
id | The area id, default is "". |
Definition at line 330 of file object.cpp.
References m_area.
Referenced by FIFE::ObjectLoader::load(), and FIFE::AtlasLoader::parseObject().
|
inline |
Sets if object blocks movement.
Definition at line 126 of file object.h.
References m_blocking.
Referenced by FIFE::ObjectLoader::load(), and FIFE::AtlasLoader::parseObject().
void FIFE::Object::setCellStackPosition | ( | uint8_t | position | ) |
Sets the cell stack position.
Is used to determine which Instance is on top of a cell.
position | The stack position on a cell, range 0-255. |
Definition at line 169 of file object.cpp.
References m_cellStack.
Referenced by FIFE::ObjectLoader::load(), and FIFE::AtlasLoader::parseObject().
void FIFE::Object::setCost | ( | double | cost | ) |
Sets the cost.
cost | A double which value is used as cost. |
Definition at line 189 of file object.cpp.
References m_cost.
Referenced by FIFE::ObjectLoader::load(), and FIFE::AtlasLoader::parseObject().
void FIFE::Object::setCostId | ( | const std::string & | cost | ) |
Sets the cost id.
cost | A const reference to a string which contains the identifier. |
Definition at line 181 of file object.cpp.
References m_costId.
Referenced by FIFE::ObjectLoader::load(), and FIFE::AtlasLoader::parseObject().
void FIFE::Object::setDefaultAction | ( | const std::string & | identifier | ) |
Sets default action assigned to this object.
If not available, then default action is not changed.
Definition at line 118 of file object.cpp.
References getAction(), m_actions, m_defaultAction, and m_inherited.
void FIFE::Object::setFilename | ( | const std::string & | file | ) |
Definition at line 161 of file object.cpp.
References m_filename.
Referenced by FIFE::ObjectLoader::load(), and FIFE::AtlasLoader::parseObject().
|
inline |
void FIFE::Object::setMultiPart | ( | bool | part | ) |
Sets the object as a part of a multi object.
part | A boolean, true if the object is a part of a multi object, otherwise false. |
Definition at line 227 of file object.cpp.
References m_multiPart.
Referenced by FIFE::MapLoader::load().
void FIFE::Object::setPather | ( | IPather * | pather | ) |
Sets pather used by instances created out of this object.
Definition at line 137 of file object.cpp.
References m_pather.
Referenced by FIFE::ObjectLoader::load(), and FIFE::AtlasLoader::parseObject().
void FIFE::Object::setRestrictedRotation | ( | bool | restrict | ) |
Sets the rotation to restricted.
If this is enabled the multi object uses only rotation values are which based on multi coordinates.
restrict | A boolean, if true the rotation will be restricted, false for free rotation. |
Definition at line 304 of file object.cpp.
References m_restrictedRotation.
Referenced by FIFE::ObjectLoader::load(), and FIFE::AtlasLoader::parseObject().
void FIFE::Object::setRotationAnchor | ( | const ExactModelCoordinate & | anchor | ) |
Sets the rotation anchor for this multi object.
Is used to rotate the images from multi part objects around this relative point, default is 0.0, 0.0 the center of the multi object.
anchor | A const reference to a ExactModelCoordinate that holds the anchor coordinate. |
Definition at line 296 of file object.cpp.
References m_rotationAnchor.
Referenced by FIFE::ObjectLoader::load(), and FIFE::AtlasLoader::parseObject().
|
inline |
Set to true, if object is such that it doesn't move.
Definition at line 134 of file object.h.
References m_static.
Referenced by FIFE::ObjectLoader::load(), and FIFE::AtlasLoader::parseObject().
void FIFE::Object::setZStepRange | ( | int32_t | zRange | ) |
Sets z-step range for object.
0 means it can not climb, with a value of 1 it can climb a z-height of 1 and so on.
zRange | The z-step range as int. |
Definition at line 322 of file object.cpp.
References m_zRange.
Referenced by FIFE::ObjectLoader::load(), and FIFE::AtlasLoader::parseObject().
|
private |
holds action ids and assigned actions
Definition at line 343 of file object.h.
Referenced by createAction(), getAction(), getActionIds(), setDefaultAction(), and ~Object().
|
private |
|
private |
indicates if object blocks
Definition at line 346 of file object.h.
Referenced by isBlocking(), and setBlocking().
|
private |
position on cellstack
Definition at line 361 of file object.h.
Referenced by getCellStackPosition(), and setCellStackPosition().
|
private |
|
private |
cost identifier
Definition at line 364 of file object.h.
Referenced by getCostId(), isSpecialCost(), and setCostId().
|
private |
pointer to default action
Definition at line 358 of file object.h.
Referenced by createAction(), getDefaultAction(), and setDefaultAction().
|
private |
|
private |
identifier
Definition at line 331 of file object.h.
Referenced by getId(), operator!=(), operator==(), and setId().
|
private |
pointer to inherited object
Definition at line 340 of file object.h.
Referenced by getAction(), getInherited(), isBlocking(), isStatic(), and setDefaultAction().
|
private |
multi object angles
Definition at line 391 of file object.h.
Referenced by getMultiObjectCoordinates(), and getRestrictedRotation().
|
private |
multi object coordinates
Definition at line 397 of file object.h.
Referenced by getMultiObjectCoordinates().
|
private |
indicates if object is part of multi object
Definition at line 370 of file object.h.
Referenced by isMultiPart(), and setMultiPart().
|
private |
part object coordinates
Definition at line 394 of file object.h.
Referenced by addMultiPartCoordinate(), and getMultiPartCoordinates().
|
private |
list with part identifiers
Definition at line 379 of file object.h.
Referenced by addMultiPartId(), getMultiPartIds(), isMultiObject(), removeAllMultiPartIds(), and removeMultiPartId().
|
private |
set with part objects
Definition at line 385 of file object.h.
Referenced by addMultiPart(), getMultiObjectCoordinates(), getMultiParts(), removeMultiPart(), and removeMultiParts().
|
private |
namespace
Definition at line 334 of file object.h.
Referenced by getNamespace(), operator!=(), and operator==().
|
private |
part object angles
Definition at line 388 of file object.h.
Referenced by addMultiPartCoordinate(), getMultiPartCoordinates(), and getRestrictedRotation().
|
private |
pointer to pathfinder
Definition at line 352 of file object.h.
Referenced by getPather(), and setPather().
|
private |
indicates if object uses only restricted rotations
Definition at line 373 of file object.h.
Referenced by isRestrictedRotation(), and setRestrictedRotation().
|
private |
rotation anchor
Definition at line 382 of file object.h.
Referenced by getRotationAnchor(), and setRotationAnchor().
|
private |
indicates if object is static
Definition at line 349 of file object.h.
Referenced by isStatic(), and setStatic().
|
private |
pointer to object visual
Definition at line 355 of file object.h.
Referenced by adoptVisual(), getVisual(), and ~Object().
|
private |
Definition at line 401 of file object.h.
Referenced by addWalkableArea(), getWalkableAreas(), and removeWalkableArea().
|
private |
z range value
Definition at line 376 of file object.h.
Referenced by getZStepRange(), and setZStepRange().