FIFE
|
An Instance is an "instantiation" of an Object at a Location. More...
#include <instance.h>
Classes | |
class | InstanceActivity |
InstanceActivity gets allocated in case there is some runtime activity related to the instance. More... | |
Public Member Functions | |
Instance (Object *object, const Location &location, const std::string &identifier="") | |
Constructor Instances are created by calling addInstance from layer, thus this method should really be called only by layer or test code. More... | |
virtual | ~Instance () |
Destructor. More... | |
const std::string & | getId () |
Get the identifier for this instance; possibly null. More... | |
void | setId (const std::string &identifier="") |
Set the identifier for this instance. More... | |
Object * | getObject () |
Gets object where this instance is instantiated from. More... | |
void | setLocation (const Location &loc) |
Sets location of the instance. More... | |
Location | getLocation () const |
Gets current location of instance. More... | |
Location & | getLocationRef () |
Gets reference of current location of instance. More... | |
Location | getTargetLocation () const |
Gets movement target in case instance is moving. More... | |
void | setFacingLocation (const Location &loc) |
Sets the direction where instance is heading. More... | |
Location | getFacingLocation () |
Returns the direction where instance is heading. More... | |
Location & | getOldLocationRef () |
Gets reference of old location of instance. More... | |
void | setRotation (int32_t rotation) |
Set the rotation offset of this instance. More... | |
int32_t | getRotation () const |
Get the rotation offset of this instance Returns direction where instance is heading. More... | |
int32_t | getOldRotation () const |
Get the old rotation offset of this instance Returns direction where instance was heading. More... | |
void | setBlocking (bool blocking) |
Sets if instance blocks movement. More... | |
bool | isBlocking () const |
Gets if instance blocks movement. More... | |
void | setOverrideBlocking (bool overblock) |
Sets if instance blocking can overriden. More... | |
bool | isOverrideBlocking () const |
Gets if instance blocking can overriden. More... | |
void | callOnActionFrame (Action *action, int32_t frame) |
Auxiliary function to inform ActionListeners about the active ActionFrame. More... | |
void | addActionListener (InstanceActionListener *listener) |
Adds new instance action listener. More... | |
void | removeActionListener (InstanceActionListener *listener) |
Removes associated instance action listener. More... | |
void | addChangeListener (InstanceChangeListener *listener) |
Adds new instance change listener. More... | |
void | removeChangeListener (InstanceChangeListener *listener) |
Removes associated instance change listener. More... | |
void | addDeleteListener (InstanceDeleteListener *listener) |
Adds new instance delete listener. More... | |
void | removeDeleteListener (InstanceDeleteListener *listener) |
Removes associated instance delete listener. More... | |
Action * | getCurrentAction () const |
Gets the currently active action. More... | |
double | getMovementSpeed () const |
Gets the speed in case instance is moving otherwise returns 0. More... | |
uint32_t | getActionRuntime () |
Gets the time in milliseconds how long action has been active In case there is no current action, returns -1. More... | |
void | setActionRuntime (uint32_t time_offset) |
Sets the time in milliseconds how long an action has been active This was requested in Ticket #373. More... | |
void | move (const std::string &actionName, const Location &target, const double speed, const std::string &costId="") |
Performs given named action to the instance. More... | |
void | act (const std::string &actionName, const Location &direction, bool repeating=false) |
Performs given named action to the instance. More... | |
void | act (const std::string &actionName, int32_t rotation, bool repeating=false) |
Performs given named action to the instance. More... | |
void | act (const std::string &actionName, bool repeating=false) |
Performs given named action to the instance. More... | |
void | say (const std::string &text, uint32_t duration=0) |
Causes instance to "say" given text (shown on screen next to the instance) More... | |
void | follow (const std::string &actionName, Instance *leader, const double speed) |
Performs given named action to the instance. More... | |
void | follow (const std::string &actionName, Route *route, const double speed) |
Performs given named action to the instance. More... | |
void | cancelMovement (uint32_t length=1) |
Cancel movement after a given length. More... | |
const std::string * | getSayText () const |
Returns pointer to currently set saytext. More... | |
InstanceChangeInfo | update () |
Updates the instance related to the current action. More... | |
bool | isActive () const |
If this returns true, the instance needs to be updated. More... | |
void | setVisual (IVisual *visual) |
Sets visualization to be used. More... | |
template<typename T > | |
T * | getVisual () const |
Gets used visualization. More... | |
void | callOnTransparencyChange () |
void | callOnVisibleChange () |
void | callOnStackPositionChange () |
void | setTimeMultiplier (float multip) |
Sets speed for the map. More... | |
float | getTimeMultiplier () |
Gets instance speed. More... | |
float | getTotalTimeMultiplier () |
Gets instance speed, considering also model and map speeds. More... | |
uint32_t | getRuntime () |
Gets the scaled runtime in milliseconds. More... | |
void | refresh () |
Refreshes instance e.g. More... | |
InstanceChangeInfo | getChangeInfo () |
Returns a bitmask of changes of the last update. More... | |
void | onInstanceDeleted (Instance *instance) |
callback so other instances we depend on can notify us if they go away More... | |
Route * | getRoute () |
Returns a pointer to the route, in case there is no, it returns NULL. More... | |
void | setVisitor (bool visit) |
Marks this instance as a visitor. More... | |
bool | isVisitor () |
If instance is a visitor it returns true otherwise false. More... | |
void | setVisitorShape (VisitorShapeInfo info) |
Sets the shape type for a visitor. More... | |
VisitorShapeInfo | getVisitorShape () |
Gets the shape type for a visitor. More... | |
void | setVisitorRadius (uint16_t radius) |
Sets the range for a visitor. More... | |
uint16_t | getVisitorRadius () |
Gets the visitor range. More... | |
void | setCellStackPosition (uint8_t stack) |
Sets the cell stack position. More... | |
uint8_t | getCellStackPosition () |
Gets the cell stack position. More... | |
bool | isSpecialCost () |
Returns true if instance or object have special cost otherwise false. More... | |
void | setCost (const std::string &id, double cost) |
Sets for the given cost id a cost. More... | |
void | resetCost () |
Resets cost. More... | |
double | getCost () |
Returns cost value. More... | |
const std::string & | getCostId () |
Returns cost id. More... | |
bool | isMultiCell () |
Returns true if it is multi cell otherwise false. More... | |
bool | isMultiObject () |
Returns true if it is multi object otherwise false. More... | |
void | updateMultiInstances () |
Updates the visual positions of all instances in case this is a multi object. More... | |
const std::vector< Instance * > & | getMultiInstances () |
Returns a vector that contains all instances of a multi object. More... | |
![]() | |
FifeClass () | |
virtual | ~FifeClass () |
fifeid_t | getFifeId () |
Gets unique id of this instance inside the engine. More... | |
![]() | |
virtual | ~InstanceDeleteListener () |
Private Member Functions | |
Instance (const Instance &) | |
Instance & | operator= (const Instance &) |
void | finalizeAction () |
Finalize current action. More... | |
void | initializeAction (const std::string &actionName) |
Initialize action for use. More... | |
bool | processMovement () |
Moves instance. Returns true if finished. More... | |
void | calcMovement () |
Calculates movement based current location and speed. More... | |
void | bindTimeProvider () |
rebinds time provider based on new location More... | |
void | initializeChanges () |
called when instance has been changed. Causes instance to create InstanceActivity More... | |
Private Attributes | |
std::string | m_id |
int32_t | m_rotation |
The rotation offset of this instance. More... | |
InstanceActivity * | m_activity |
InstanceChangeInfo | m_changeInfo |
bitmask stating current changes More... | |
std::vector < InstanceDeleteListener * > | m_deleteListeners |
listeners for deletion of the instance More... | |
Object * | m_object |
object where instantiated from More... | |
Location | m_location |
current location More... | |
IVisual * | m_visual |
instance visualization More... | |
bool | m_blocking |
instance blocking info More... | |
bool | m_overrideBlocking |
allow to override the blocking property More... | |
bool | m_isVisitor |
is instance a visitor (FoW) More... | |
VisitorShapeInfo | m_visitorShape |
visitor shape type More... | |
uint16_t | m_visitorRadius |
visitor radius (FoW) More... | |
uint8_t | m_cellStackPos |
position on cell stack More... | |
bool | m_specialCost |
indicates special cost More... | |
double | m_cost |
holds cost value More... | |
std::string | m_costId |
holds cost id More... | |
std::vector< Instance * > | m_multiInstances |
vector that holds all multi instances More... | |
An Instance is an "instantiation" of an Object at a Location.
Definition at line 97 of file instance.h.
FIFE::Instance::Instance | ( | Object * | object, |
const Location & | location, | ||
const std::string & | identifier = "" |
||
) |
Constructor Instances are created by calling addInstance from layer, thus this method should really be called only by layer or test code.
Definition at line 198 of file instance.cpp.
References addDeleteListener(), FIFE::InstanceVisual::create(), FIFE::Layer::createInstance(), FIFE::Location::getExactLayerCoordinatesRef(), FIFE::Location::getLayer(), FIFE::Object::isMultiObject(), m_location, m_multiInstances, m_object, m_rotation, FIFE::PointType3D< T >::x, FIFE::PointType3D< T >::y, and FIFE::PointType3D< T >::z.
|
virtual |
Destructor.
Definition at line 241 of file instance.cpp.
References finalizeAction(), FIFE::Instance::InstanceActivity::m_actionInfo, FIFE::Instance::InstanceActivity::m_actionListeners, m_activity, m_deleteListeners, m_multiInstances, and m_visual.
|
private |
void FIFE::Instance::act | ( | const std::string & | actionName, |
const Location & | direction, | ||
bool | repeating = false |
||
) |
Performs given named action to the instance.
Performs no movement
actionName | name of the action |
direction | coordinates for cell towards instance is heading to when performing the action |
repeating | in case true, keeps repeating this action |
Definition at line 573 of file instance.cpp.
References initializeAction(), FIFE::Instance::InstanceActivity::m_actionInfo, m_activity, FIFE::ActionInfo::m_repeating, and setFacingLocation().
Referenced by FIFE::MapLoader::load().
void FIFE::Instance::act | ( | const std::string & | actionName, |
int32_t | rotation, | ||
bool | repeating = false |
||
) |
Performs given named action to the instance.
Performs no movement
actionName | name of the action |
rotation | rotation which the instance use when performing the action |
repeating | in case true, keeps repeating this action |
Definition at line 579 of file instance.cpp.
References initializeAction(), FIFE::Instance::InstanceActivity::m_actionInfo, m_activity, FIFE::ActionInfo::m_repeating, and setRotation().
void FIFE::Instance::act | ( | const std::string & | actionName, |
bool | repeating = false |
||
) |
Performs given named action to the instance.
Performs no movement and use current rotation
actionName | name of the action |
repeating | in case true, keeps repeating this action |
Definition at line 585 of file instance.cpp.
References initializeAction(), FIFE::Instance::InstanceActivity::m_actionInfo, m_activity, and FIFE::ActionInfo::m_repeating.
void FIFE::Instance::addActionListener | ( | InstanceActionListener * | listener | ) |
Adds new instance action listener.
listener | to add |
Definition at line 362 of file instance.cpp.
References initializeChanges(), FIFE::Instance::InstanceActivity::m_actionListeners, and m_activity.
void FIFE::Instance::addChangeListener | ( | InstanceChangeListener * | listener | ) |
Adds new instance change listener.
listener | to add |
Definition at line 382 of file instance.cpp.
References initializeChanges(), m_activity, and FIFE::Instance::InstanceActivity::m_changeListeners.
void FIFE::Instance::addDeleteListener | ( | InstanceDeleteListener * | listener | ) |
Adds new instance delete listener.
listener | to add |
Definition at line 1031 of file instance.cpp.
References m_deleteListeners.
Referenced by FIFE::InstanceRenderer::addColored(), FIFE::RendererNode::addInstance(), FIFE::InstanceRenderer::addOutlined(), FIFE::InstanceRenderer::addTransparentArea(), FIFE::RendererNode::changeInstance(), follow(), and Instance().
|
private |
rebinds time provider based on new location
Definition at line 866 of file instance.cpp.
References FIFE::Location::getLayer(), FIFE::Layer::getMap(), FIFE::TimeProvider::getMultiplier(), FIFE::Map::getTimeProvider(), m_activity, m_location, FIFE::Instance::InstanceActivity::m_timeProvider, and FIFE::TimeProvider::setMultiplier().
Referenced by getActionRuntime(), getRuntime(), refresh(), setTimeMultiplier(), and update().
|
private |
Calculates movement based current location and speed.
void FIFE::Instance::callOnActionFrame | ( | Action * | action, |
int32_t | frame | ||
) |
Auxiliary function to inform ActionListeners about the active ActionFrame.
action | pointer to the action |
frame | frame index number of the animation |
Definition at line 387 of file instance.cpp.
References FIFE::Instance::InstanceActivity::m_actionListeners, and m_activity.
Referenced by FIFE::LayerCache::updateVisual().
void FIFE::Instance::callOnStackPositionChange | ( | ) |
Definition at line 916 of file instance.cpp.
References FIFE::ICHANGE_STACKPOS, initializeChanges(), isActive(), m_activity, FIFE::Instance::InstanceActivity::m_additional, and refresh().
Referenced by FIFE::InstanceVisual::setStackPosition().
void FIFE::Instance::callOnTransparencyChange | ( | ) |
Definition at line 898 of file instance.cpp.
References FIFE::ICHANGE_TRANSPARENCY, initializeChanges(), isActive(), m_activity, FIFE::Instance::InstanceActivity::m_additional, and refresh().
Referenced by FIFE::InstanceVisual::setTransparency().
void FIFE::Instance::callOnVisibleChange | ( | ) |
Definition at line 907 of file instance.cpp.
References FIFE::ICHANGE_VISIBLE, initializeChanges(), isActive(), m_activity, FIFE::Instance::InstanceActivity::m_additional, and refresh().
Referenced by FIFE::InstanceVisual::setVisible().
void FIFE::Instance::cancelMovement | ( | uint32_t | length = 1 | ) |
Cancel movement after a given length.
If no lenght is set then 1 is used. This mean that the instance stops at the center of the next cell (can be the same as the current).
Definition at line 511 of file instance.cpp.
References FIFE::Route::cutPath(), FIFE::Instance::InstanceActivity::m_actionInfo, m_activity, and FIFE::ActionInfo::m_route.
|
private |
Finalize current action.
Definition at line 777 of file instance.cpp.
References FIFE::_log, FL_DBG, isMultiObject(), FIFE::ActionInfo::m_action, FIFE::Instance::InstanceActivity::m_actionInfo, FIFE::Instance::InstanceActivity::m_actionListeners, m_activity, FIFE::ActionInfo::m_leader, m_multiInstances, and removeDeleteListener().
Referenced by move(), update(), and ~Instance().
void FIFE::Instance::follow | ( | const std::string & | actionName, |
Instance * | leader, | ||
const double | speed | ||
) |
Performs given named action to the instance.
While performing the action follows given instance with given speed
actionName | name of the action |
leader | followed instance |
speed | speed used for movement. Units = distance 1 in layer coordinates per second |
Definition at line 486 of file instance.cpp.
References FIFE::_log, addDeleteListener(), FL_DBG, getLocationRef(), initializeAction(), FIFE::Instance::InstanceActivity::m_actionInfo, m_activity, FIFE::ActionInfo::m_leader, m_location, FIFE::ActionInfo::m_speed, and FIFE::ActionInfo::m_target.
void FIFE::Instance::follow | ( | const std::string & | actionName, |
Route * | route, | ||
const double | speed | ||
) |
Performs given named action to the instance.
While performing the action follows given route with given speed. Note: In this case route isn't delete at the end.
actionName | name of the action |
route | followed route |
speed | speed used for movement. Units = distance 1 in layer coordinates per second |
Definition at line 495 of file instance.cpp.
References FIFE::_log, FL_DBG, FIFE::Layer::getCellGrid(), FIFE::Route::getEndNode(), FIFE::Location::getLayer(), FIFE::Location::getLayerCoordinates(), FIFE::Object::getMultiObjectCoordinates(), FIFE::Object::getWalkableAreas(), FIFE::Object::getZStepRange(), initializeAction(), isMultiCell(), FIFE::Instance::InstanceActivity::m_actionInfo, m_activity, FIFE::ActionInfo::m_delete_route, m_location, m_object, m_rotation, FIFE::ActionInfo::m_route, FIFE::ActionInfo::m_speed, FIFE::ActionInfo::m_target, FIFE::Route::setObject(), and FIFE::Route::setOccupiedArea().
uint32_t FIFE::Instance::getActionRuntime | ( | ) |
Gets the time in milliseconds how long action has been active In case there is no current action, returns -1.
Definition at line 853 of file instance.cpp.
References bindTimeProvider(), FIFE::TimeProvider::getGameTime(), getRuntime(), FIFE::ActionInfo::m_action_offset_time, FIFE::ActionInfo::m_action_start_time, FIFE::Instance::InstanceActivity::m_actionInfo, m_activity, and FIFE::Instance::InstanceActivity::m_timeProvider.
Referenced by FIFE::LayerCache::updateVisual().
uint8_t FIFE::Instance::getCellStackPosition | ( | ) |
Gets the cell stack position.
Definition at line 561 of file instance.cpp.
References m_cellStackPos.
InstanceChangeInfo FIFE::Instance::getChangeInfo | ( | ) |
Returns a bitmask of changes of the last update.
Definition at line 891 of file instance.cpp.
References FIFE::ICHANGE_NO_CHANGES, m_activity, and m_changeInfo.
Referenced by FIFE::LayerCache::updateInstance().
double FIFE::Instance::getCost | ( | ) |
Returns cost value.
In case there is no it returns the object cost.
Definition at line 978 of file instance.cpp.
References FIFE::Object::getCost(), m_cost, m_object, and m_specialCost.
Referenced by FIFE::Cell::addInstance().
const std::string & FIFE::Instance::getCostId | ( | ) |
Returns cost id.
In case there is no it returns the object cost id.
Definition at line 985 of file instance.cpp.
References FIFE::Object::getCostId(), m_costId, m_object, and m_specialCost.
Referenced by FIFE::Cell::addInstance(), and FIFE::Cell::removeInstance().
Action * FIFE::Instance::getCurrentAction | ( | ) | const |
Gets the currently active action.
This is owned by the instance's object, so don't delete it!
Definition at line 810 of file instance.cpp.
References FIFE::ActionInfo::m_action, FIFE::Instance::InstanceActivity::m_actionInfo, and m_activity.
Referenced by FIFE::LayerCache::updateVisual().
Location FIFE::Instance::getFacingLocation | ( | ) |
Returns the direction where instance is heading.
Definition at line 835 of file instance.cpp.
References FIFE::getFacing(), m_location, and m_rotation.
const std::string & FIFE::Instance::getId | ( | ) |
Get the identifier for this instance; possibly null.
Definition at line 335 of file instance.cpp.
References m_id.
Location FIFE::Instance::getLocation | ( | ) | const |
Gets current location of instance.
Definition at line 303 of file instance.cpp.
References m_location.
Referenced by FIFE::Camera::attach(), and FIFE::InstanceRenderer::renderAlreadySorted().
Location & FIFE::Instance::getLocationRef | ( | ) |
Gets reference of current location of instance.
Definition at line 307 of file instance.cpp.
References m_location.
Referenced by FIFE::InstanceTree::addInstance(), FIFE::Layer::addInstance(), follow(), FIFE::RendererNode::getCalculatedPoint(), FIFE::Camera::getMatchingInstances(), FIFE::CellCacheChangeListener::onInstanceCreate(), FIFE::CellCacheChangeListener::onInstanceDelete(), FIFE::InstanceDistanceSortLocation::operator()(), FIFE::InstanceDistanceSortCameraAndLocation::operator()(), processMovement(), FIFE::GridRenderer::render(), FIFE::BlockingInfoRenderer::render(), FIFE::InstanceRenderer::renderAlreadySorted(), FIFE::Camera::update(), and FIFE::LayerCache::updatePosition().
double FIFE::Instance::getMovementSpeed | ( | ) | const |
Gets the speed in case instance is moving otherwise returns 0.
Definition at line 824 of file instance.cpp.
References FIFE::Instance::InstanceActivity::m_actionInfo, m_activity, and FIFE::ActionInfo::m_speed.
const std::vector< Instance * > & FIFE::Instance::getMultiInstances | ( | ) |
Returns a vector that contains all instances of a multi object.
Definition at line 569 of file instance.cpp.
References m_multiInstances.
Referenced by FIFE::CellCacheChangeListener::onInstanceCreate(), and FIFE::CellCacheChangeListener::onInstanceDelete().
Object * FIFE::Instance::getObject | ( | ) |
Gets object where this instance is instantiated from.
Definition at line 280 of file instance.cpp.
References m_object.
Referenced by FIFE::Cell::addInstance(), FIFE::RenderItem::getStaticImageIndexByAngle(), FIFE::Cell::removeInstance(), FIFE::BlockingInfoRenderer::render(), FIFE::InstanceRenderer::renderAlreadySorted(), FIFE::InstanceRenderer::renderUnsorted(), and FIFE::LayerCache::updateVisual().
Location & FIFE::Instance::getOldLocationRef | ( | ) |
Gets reference of old location of instance.
Definition at line 839 of file instance.cpp.
References m_activity, m_location, and FIFE::Instance::InstanceActivity::m_oldLocation.
Referenced by FIFE::Map::update().
int32_t FIFE::Instance::getOldRotation | ( | ) | const |
Get the old rotation offset of this instance Returns direction where instance was heading.
Definition at line 846 of file instance.cpp.
References m_activity, FIFE::Instance::InstanceActivity::m_oldRotation, and m_rotation.
int32_t FIFE::Instance::getRotation | ( | ) | const |
Get the rotation offset of this instance Returns direction where instance is heading.
Definition at line 327 of file instance.cpp.
References m_rotation.
Referenced by move(), FIFE::CellCacheChangeListener::onInstanceCreate(), FIFE::CellCacheChangeListener::onInstanceDelete(), processMovement(), and FIFE::LayerCache::updateVisual().
Route * FIFE::Instance::getRoute | ( | ) |
Returns a pointer to the route, in case there is no, it returns NULL.
Definition at line 523 of file instance.cpp.
References FIFE::Instance::InstanceActivity::m_actionInfo, m_activity, and FIFE::ActionInfo::m_route.
uint32_t FIFE::Instance::getRuntime | ( | ) |
Gets the scaled runtime in milliseconds.
Definition at line 953 of file instance.cpp.
References bindTimeProvider(), FIFE::TimeProvider::getGameTime(), FIFE::Location::getLayer(), FIFE::Layer::getMap(), FIFE::TimeManager::getTime(), FIFE::Map::getTimeProvider(), FIFE::DynamicSingleton< TimeManager >::instance(), m_activity, m_location, and FIFE::Instance::InstanceActivity::m_timeProvider.
Referenced by getActionRuntime(), initializeAction(), and say().
const std::string * FIFE::Instance::getSayText | ( | ) | const |
Returns pointer to currently set saytext.
In case no text is set, returns NULL
Definition at line 601 of file instance.cpp.
References m_activity, FIFE::Instance::InstanceActivity::m_sayInfo, and FIFE::SayInfo::m_txt.
Referenced by FIFE::FloatingTextRenderer::render().
Location FIFE::Instance::getTargetLocation | ( | ) | const |
Gets movement target in case instance is moving.
In case not, returns current location To move target location, call move-method
Definition at line 817 of file instance.cpp.
References FIFE::Instance::InstanceActivity::m_actionInfo, m_activity, m_location, and FIFE::ActionInfo::m_target.
float FIFE::Instance::getTimeMultiplier | ( | ) |
Gets instance speed.
Definition at line 933 of file instance.cpp.
References FIFE::TimeProvider::getMultiplier(), m_activity, and FIFE::Instance::InstanceActivity::m_timeProvider.
float FIFE::Instance::getTotalTimeMultiplier | ( | ) |
Gets instance speed, considering also model and map speeds.
Definition at line 940 of file instance.cpp.
References FIFE::Location::getLayer(), FIFE::Layer::getMap(), FIFE::Map::getTimeProvider(), FIFE::TimeProvider::getTotalMultiplier(), m_activity, m_location, and FIFE::Instance::InstanceActivity::m_timeProvider.
uint16_t FIFE::Instance::getVisitorRadius | ( | ) |
Gets the visitor range.
Definition at line 553 of file instance.cpp.
References m_visitorRadius.
Referenced by FIFE::Cell::addInstance(), and FIFE::Cell::removeInstance().
VisitorShapeInfo FIFE::Instance::getVisitorShape | ( | ) |
Gets the shape type for a visitor.
Definition at line 545 of file instance.cpp.
References m_visitorShape.
Referenced by FIFE::Cell::addInstance(), and FIFE::Cell::removeInstance().
|
inline |
Gets used visualization.
Definition at line 331 of file instance.h.
References m_visual.
Referenced by FIFE::InstanceVisual::create(), FIFE::InstanceDistanceSortCamera::operator()(), FIFE::InstanceDistanceSortLocation::operator()(), FIFE::InstanceDistanceSortCameraAndLocation::operator()(), FIFE::InstanceRenderer::renderAlreadySorted(), and FIFE::LayerCache::updateVisual().
|
private |
Initialize action for use.
Definition at line 416 of file instance.cpp.
References FIFE::Object::getAction(), FIFE::Object::getPather(), getRuntime(), initializeChanges(), isMultiObject(), FIFE::ActionInfo::m_action, FIFE::ActionInfo::m_action_start_time, FIFE::Instance::InstanceActivity::m_actionInfo, m_activity, m_location, m_multiInstances, m_object, and FIFE::ActionInfo::m_prev_call_time.
Referenced by act(), follow(), and move().
|
private |
called when instance has been changed. Causes instance to create InstanceActivity
Definition at line 267 of file instance.cpp.
References FIFE::Location::getLayer(), m_activity, m_location, and FIFE::Layer::setInstanceActivityStatus().
Referenced by addActionListener(), addChangeListener(), callOnStackPositionChange(), callOnTransparencyChange(), callOnVisibleChange(), initializeAction(), refresh(), say(), setBlocking(), setLocation(), setRotation(), and setTimeMultiplier().
bool FIFE::Instance::isActive | ( | ) | const |
If this returns true, the instance needs to be updated.
Definition at line 276 of file instance.cpp.
References m_activity.
Referenced by FIFE::Layer::addInstance(), callOnStackPositionChange(), callOnTransparencyChange(), callOnVisibleChange(), FIFE::Layer::createInstance(), FIFE::Layer::deleteInstance(), FIFE::Layer::removeInstance(), setBlocking(), setLocation(), and setRotation().
bool FIFE::Instance::isBlocking | ( | ) | const |
Gets if instance blocks movement.
Definition at line 350 of file instance.cpp.
References m_blocking.
Referenced by FIFE::BlockingInfoRenderer::render().
bool FIFE::Instance::isMultiCell | ( | ) |
Returns true if it is multi cell otherwise false.
Definition at line 992 of file instance.cpp.
References FIFE::Object::isMultiObject(), and m_object.
Referenced by follow(), move(), FIFE::CellCacheChangeListener::onInstanceCreate(), FIFE::CellCacheChangeListener::onInstanceDelete(), and processMovement().
bool FIFE::Instance::isMultiObject | ( | ) |
Returns true if it is multi object otherwise false.
Definition at line 996 of file instance.cpp.
References m_multiInstances.
Referenced by finalizeAction(), initializeAction(), and onInstanceDeleted().
bool FIFE::Instance::isOverrideBlocking | ( | ) | const |
Gets if instance blocking can overriden.
Definition at line 358 of file instance.cpp.
References m_overrideBlocking.
bool FIFE::Instance::isSpecialCost | ( | ) |
Returns true if instance or object have special cost otherwise false.
Definition at line 565 of file instance.cpp.
References m_specialCost.
Referenced by FIFE::Cell::addInstance(), and FIFE::Cell::removeInstance().
bool FIFE::Instance::isVisitor | ( | ) |
If instance is a visitor it returns true otherwise false.
Definition at line 537 of file instance.cpp.
References m_isVisitor.
Referenced by FIFE::Cell::addInstance(), and FIFE::Cell::removeInstance().
void FIFE::Instance::move | ( | const std::string & | actionName, |
const Location & | target, | ||
const double | speed, | ||
const std::string & | costId = "" |
||
) |
Performs given named action to the instance.
While performing the action moves instance to given target with given speed
actionName | name of the action |
target | place where to move this instance |
speed | speed used for movement. Units = distance 1 in layer coordinates per second |
costid | id for special costs which is be used as extra multiplier. |
Definition at line 444 of file instance.cpp.
References FIFE::_log, FIFE::Math< T >::Equal(), finalizeAction(), FL_DBG, FIFE::Object::getAction(), FIFE::Layer::getCellGrid(), FIFE::Route::getCostId(), FIFE::Location::getLayer(), FIFE::Location::getLayerCoordinates(), FIFE::Object::getMultiObjectCoordinates(), getRotation(), FIFE::Object::getWalkableAreas(), FIFE::Object::getZStepRange(), initializeAction(), isMultiCell(), FIFE::ActionInfo::m_action, FIFE::Instance::InstanceActivity::m_actionInfo, m_activity, m_location, m_object, FIFE::ActionInfo::m_pather, m_rotation, FIFE::ActionInfo::m_route, FIFE::ActionInfo::m_speed, FIFE::ActionInfo::m_target, FIFE::Route::setCostId(), setFacingLocation(), FIFE::Route::setObject(), FIFE::Route::setOccupiedArea(), FIFE::Route::setRotation(), and FIFE::IPather::solveRoute().
|
virtual |
callback so other instances we depend on can notify us if they go away
Implements FIFE::InstanceDeleteListener.
Definition at line 1050 of file instance.cpp.
References isMultiObject(), FIFE::Instance::InstanceActivity::m_actionInfo, m_activity, FIFE::ActionInfo::m_leader, and m_multiInstances.
|
private |
Moves instance. Returns true if finished.
Definition at line 608 of file instance.cpp.
References FIFE::Map::addInstanceForTransfer(), FIFE::IPather::followRoute(), FIFE::Layer::getCellGrid(), FIFE::Route::getCurrentNode(), FIFE::Route::getEndNode(), FIFE::TimeProvider::getGameTime(), FIFE::Location::getLayer(), FIFE::Location::getLayerCoordinates(), FIFE::Location::getLayerDistanceTo(), getLocationRef(), FIFE::Layer::getMap(), FIFE::Object::getMultiObjectCoordinates(), FIFE::Route::getPathLength(), FIFE::Route::getPreviousNode(), getRotation(), FIFE::Route::getRotation(), FIFE::Route::getRouteStatus(), FIFE::Object::getWalkableAreas(), FIFE::Object::getZStepRange(), isMultiCell(), FIFE::Route::isReplanned(), FIFE::Instance::InstanceActivity::m_actionInfo, m_activity, FIFE::ActionInfo::m_leader, m_location, m_multiInstances, m_object, FIFE::ActionInfo::m_pather, FIFE::ActionInfo::m_prev_call_time, m_rotation, FIFE::ActionInfo::m_route, FIFE::ActionInfo::m_speed, FIFE::ActionInfo::m_target, FIFE::Instance::InstanceActivity::m_timeProvider, FIFE::ROUTE_FAILED, FIFE::ROUTE_SOLVED, FIFE::Route::setEndNode(), setFacingLocation(), FIFE::Location::setLayerCoordinates(), setLocation(), FIFE::Route::setObject(), FIFE::Route::setOccupiedArea(), FIFE::Route::setReplanned(), setRotation(), FIFE::Route::setRotation(), FIFE::Route::setStartNode(), and FIFE::IPather::solveRoute().
Referenced by update().
void FIFE::Instance::refresh | ( | ) |
Refreshes instance e.g.
in case location is updated directly (not via setLocation) In this case e.g. instance's master time provider is changed, so it needs to be updated
Definition at line 886 of file instance.cpp.
References bindTimeProvider(), and initializeChanges().
Referenced by callOnStackPositionChange(), callOnTransparencyChange(), callOnVisibleChange(), setBlocking(), setLocation(), and setRotation().
void FIFE::Instance::removeActionListener | ( | InstanceActionListener * | listener | ) |
Removes associated instance action listener.
listener | to remove |
Definition at line 367 of file instance.cpp.
References FIFE::_log, FL_WARN, FIFE::Instance::InstanceActivity::m_actionListeners, and m_activity.
void FIFE::Instance::removeChangeListener | ( | InstanceChangeListener * | listener | ) |
Removes associated instance change listener.
listener | to remove |
Definition at line 401 of file instance.cpp.
References FIFE::_log, FL_WARN, m_activity, and FIFE::Instance::InstanceActivity::m_changeListeners.
void FIFE::Instance::removeDeleteListener | ( | InstanceDeleteListener * | listener | ) |
Removes associated instance delete listener.
listener | to remove |
Definition at line 1035 of file instance.cpp.
References FIFE::_log, FL_WARN, and m_deleteListeners.
Referenced by FIFE::RendererNode::changeInstance(), finalizeAction(), FIFE::InstanceRenderer::removeColored(), FIFE::RendererNode::removeInstance(), FIFE::InstanceRenderer::removeInstance(), FIFE::InstanceRenderer::removeOutlined(), and FIFE::InstanceRenderer::removeTransparentArea().
void FIFE::Instance::resetCost | ( | ) |
void FIFE::Instance::say | ( | const std::string & | text, |
uint32_t | duration = 0 |
||
) |
Causes instance to "say" given text (shown on screen next to the instance)
text | text to say. If "" given, clear the text |
duration | duration to show the text (in ms). If 0, shows forever |
Definition at line 590 of file instance.cpp.
References getRuntime(), initializeChanges(), m_activity, FIFE::Instance::InstanceActivity::m_sayInfo, and FIFE::SayInfo::m_start_time.
Referenced by update().
void FIFE::Instance::setActionRuntime | ( | uint32_t | time_offset | ) |
Sets the time in milliseconds how long an action has been active This was requested in Ticket #373.
This way the state of the action can be saved and restored at a later time
time_offset | The action time offset that should be applied |
Definition at line 862 of file instance.cpp.
References FIFE::ActionInfo::m_action_offset_time, FIFE::Instance::InstanceActivity::m_actionInfo, and m_activity.
void FIFE::Instance::setBlocking | ( | bool | blocking | ) |
Sets if instance blocks movement.
Definition at line 339 of file instance.cpp.
References initializeChanges(), isActive(), m_blocking, m_overrideBlocking, and refresh().
void FIFE::Instance::setCellStackPosition | ( | uint8_t | stack | ) |
Sets the cell stack position.
Definition at line 557 of file instance.cpp.
References m_cellStackPos.
Referenced by FIFE::MapLoader::load().
void FIFE::Instance::setCost | ( | const std::string & | id, |
double | cost | ||
) |
Sets for the given cost id a cost.
id | name of the cost id |
cost | value for the cost |
Definition at line 968 of file instance.cpp.
References m_cost, m_costId, and m_specialCost.
Referenced by FIFE::MapLoader::load().
void FIFE::Instance::setFacingLocation | ( | const Location & | loc | ) |
Sets the direction where instance is heading.
Useful e.g. with static instances which don't "move" or "act"
Definition at line 831 of file instance.cpp.
References FIFE::getAngleBetween(), m_location, and setRotation().
Referenced by act(), move(), and processMovement().
void FIFE::Instance::setId | ( | const std::string & | identifier = "" | ) |
void FIFE::Instance::setLocation | ( | const Location & | loc | ) |
Sets location of the instance.
loc | new location |
Definition at line 284 of file instance.cpp.
References FIFE::InstanceTree::addInstance(), FIFE::Layer::getInstanceTree(), FIFE::Location::getLayer(), FIFE::Location::getLayerCoordinates(), initializeChanges(), isActive(), m_location, refresh(), and FIFE::InstanceTree::removeInstance().
Referenced by processMovement().
void FIFE::Instance::setOverrideBlocking | ( | bool | overblock | ) |
Sets if instance blocking can overriden.
Definition at line 354 of file instance.cpp.
References m_overrideBlocking.
void FIFE::Instance::setRotation | ( | int32_t | rotation | ) |
Set the rotation offset of this instance.
Definition at line 311 of file instance.cpp.
References initializeChanges(), isActive(), m_rotation, and refresh().
Referenced by act(), FIFE::MapLoader::load(), processMovement(), and setFacingLocation().
void FIFE::Instance::setTimeMultiplier | ( | float | multip | ) |
Sets speed for the map.
Definition at line 925 of file instance.cpp.
References bindTimeProvider(), initializeChanges(), m_activity, FIFE::Instance::InstanceActivity::m_timeProvider, and FIFE::TimeProvider::setMultiplier().
void FIFE::Instance::setVisitor | ( | bool | visit | ) |
Marks this instance as a visitor.
Definition at line 533 of file instance.cpp.
References m_isVisitor.
Referenced by FIFE::MapLoader::load().
void FIFE::Instance::setVisitorRadius | ( | uint16_t | radius | ) |
Sets the range for a visitor.
Definition at line 549 of file instance.cpp.
References m_visitorRadius.
Referenced by FIFE::MapLoader::load().
void FIFE::Instance::setVisitorShape | ( | VisitorShapeInfo | info | ) |
Sets the shape type for a visitor.
Definition at line 541 of file instance.cpp.
References m_visitorShape.
Referenced by FIFE::MapLoader::load().
|
inline |
Sets visualization to be used.
Transfers ownership.
Definition at line 327 of file instance.h.
References m_visual.
Referenced by FIFE::InstanceVisual::create().
InstanceChangeInfo FIFE::Instance::update | ( | ) |
Updates the instance related to the current action.
Definition at line 721 of file instance.cpp.
References bindTimeProvider(), finalizeAction(), FIFE::Action::getDuration(), FIFE::TimeProvider::getGameTime(), FIFE::ICHANGE_NO_CHANGES, FIFE::Object::isMultiPart(), FIFE::ActionInfo::m_action, FIFE::ActionInfo::m_action_offset_time, FIFE::ActionInfo::m_action_start_time, FIFE::Instance::InstanceActivity::m_actionInfo, FIFE::Instance::InstanceActivity::m_actionListeners, m_activity, m_changeInfo, m_deleteListeners, FIFE::SayInfo::m_duration, m_object, FIFE::ActionInfo::m_prev_call_time, FIFE::ActionInfo::m_repeating, FIFE::Instance::InstanceActivity::m_sayInfo, FIFE::SayInfo::m_start_time, FIFE::ActionInfo::m_target, FIFE::Instance::InstanceActivity::m_timeProvider, processMovement(), say(), and FIFE::Instance::InstanceActivity::update().
Referenced by FIFE::Layer::deleteInstance(), and FIFE::Layer::removeInstance().
void FIFE::Instance::updateMultiInstances | ( | ) |
Updates the visual positions of all instances in case this is a multi object.
Definition at line 1000 of file instance.cpp.
References FIFE::Math< T >::Cos(), FIFE::Location::getMapCoordinates(), FIFE::Object::getRestrictedRotation(), FIFE::Object::getRotationAnchor(), FIFE::Object::isRestrictedRotation(), m_location, m_multiInstances, m_object, m_rotation, FIFE::Math< T >::pi(), FIFE::Location::setExactLayerCoordinates(), FIFE::Location::setLayerCoordinates(), FIFE::Location::setMapCoordinates(), FIFE::Math< T >::Sin(), FIFE::PointType3D< T >::x, and FIFE::PointType3D< T >::y.
Referenced by FIFE::CellCacheChangeListener::onInstanceCreate(), and FIFE::CellCacheChangeListener::onInstanceDelete().
|
private |
Definition at line 497 of file instance.h.
Referenced by act(), addActionListener(), addChangeListener(), bindTimeProvider(), callOnActionFrame(), callOnStackPositionChange(), callOnTransparencyChange(), callOnVisibleChange(), cancelMovement(), finalizeAction(), follow(), getActionRuntime(), getChangeInfo(), getCurrentAction(), getMovementSpeed(), getOldLocationRef(), getOldRotation(), getRoute(), getRuntime(), getSayText(), getTargetLocation(), getTimeMultiplier(), getTotalTimeMultiplier(), initializeAction(), initializeChanges(), isActive(), move(), onInstanceDeleted(), processMovement(), removeActionListener(), removeChangeListener(), say(), setActionRuntime(), setTimeMultiplier(), update(), and ~Instance().
|
private |
instance blocking info
Definition at line 510 of file instance.h.
Referenced by isBlocking(), setBlocking(), and FIFE::Instance::InstanceActivity::update().
|
private |
position on cell stack
Definition at line 520 of file instance.h.
Referenced by getCellStackPosition(), and setCellStackPosition().
|
private |
bitmask stating current changes
Definition at line 499 of file instance.h.
Referenced by getChangeInfo(), update(), and FIFE::Instance::InstanceActivity::update().
|
private |
|
private |
|
private |
listeners for deletion of the instance
Definition at line 501 of file instance.h.
Referenced by addDeleteListener(), removeDeleteListener(), update(), and ~Instance().
|
private |
Definition at line 442 of file instance.h.
|
private |
is instance a visitor (FoW)
Definition at line 514 of file instance.h.
Referenced by isVisitor(), and setVisitor().
|
private |
current location
Definition at line 506 of file instance.h.
Referenced by bindTimeProvider(), follow(), getFacingLocation(), getLocation(), getLocationRef(), getOldLocationRef(), getRuntime(), getTargetLocation(), getTotalTimeMultiplier(), initializeAction(), initializeChanges(), Instance(), move(), processMovement(), setFacingLocation(), setLocation(), FIFE::Instance::InstanceActivity::update(), and updateMultiInstances().
|
private |
vector that holds all multi instances
Definition at line 529 of file instance.h.
Referenced by finalizeAction(), getMultiInstances(), initializeAction(), Instance(), isMultiObject(), onInstanceDeleted(), processMovement(), updateMultiInstances(), and ~Instance().
|
private |
object where instantiated from
Definition at line 504 of file instance.h.
Referenced by follow(), getCost(), getCostId(), getObject(), initializeAction(), Instance(), isMultiCell(), move(), processMovement(), update(), and updateMultiInstances().
|
private |
allow to override the blocking property
Definition at line 512 of file instance.h.
Referenced by isOverrideBlocking(), setBlocking(), and setOverrideBlocking().
|
private |
The rotation offset of this instance.
This is in addition to possible camera rotation and intended for setting, for example, a rotation of a tile.
Definition at line 446 of file instance.h.
Referenced by follow(), getFacingLocation(), getOldRotation(), getRotation(), Instance(), move(), processMovement(), setRotation(), FIFE::Instance::InstanceActivity::update(), and updateMultiInstances().
|
private |
indicates special cost
Definition at line 522 of file instance.h.
Referenced by getCost(), getCostId(), isSpecialCost(), resetCost(), and setCost().
|
private |
visitor radius (FoW)
Definition at line 518 of file instance.h.
Referenced by getVisitorRadius(), and setVisitorRadius().
|
private |
visitor shape type
Definition at line 516 of file instance.h.
Referenced by getVisitorShape(), and setVisitorShape().
|
private |
instance visualization
Definition at line 508 of file instance.h.
Referenced by getVisual(), setVisual(), and ~Instance().