FIFE  6e1afdbeda11afe9ac53e6023a4be96ef88f1dc6
FIFE::Instance Class Reference

An Instance is an "instantiation" of an Object at a Location. More...

#include <instance.h>

+ Inheritance diagram for FIFE::Instance:
+ Collaboration diagram for FIFE::Instance:

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...
 
ObjectgetObject ()
 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...
 
LocationgetLocationRef ()
 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...
 
LocationgetOldLocationRef ()
 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...
 
ActiongetCurrentAction () 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 actOnce (const std::string &actionName, const Location &direction)
 Performs given named action to the instance, once only. More...
 
void actOnce (const std::string &actionName, int32_t rotation)
 Performs given named action to the instance, once only. More...
 
void actOnce (const std::string &actionName)
 Performs given named action to the instance, once only. More...
 
void actRepeat (const std::string &actionName, const Location &direction)
 Performs given named action to the instance, repeated. More...
 
void actRepeat (const std::string &actionName, int32_t rotation)
 Performs given named action to the instance, repeated Performs no movement. More...
 
void actRepeat (const std::string &actionName)
 Performs given named action to the instance, repeated. 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...
 
RoutegetRoute ()
 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...
 
std::string getCostId ()
 Returns cost id. More...
 
double getSpeed ()
 Returns speed modifier. More...
 
bool isSpecialSpeed ()
 Returns true if instance or object have special speed modifier otherwise false. 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...
 
void setMainMultiInstance (Instance *main)
 Sets a instance to the main multi instance of this instance. More...
 
InstancegetMainMultiInstance ()
 Returns a pointer to the main mulit instance or Null if the instance is not part of a multi instance object. More...
 
void addStaticColorOverlay (uint32_t angle, const OverlayColors &colors)
 Adds new static color overlay with given angle (degrees). More...
 
OverlayColorsgetStaticColorOverlay (int32_t angle)
 Returns closest matching static color overlay for given angle. More...
 
void removeStaticColorOverlay (int32_t angle)
 Removes a static color overlay with given angle (degrees). More...
 
bool isStaticColorOverlay ()
 Indicates if there exists a static color overlay. More...
 
void addColorOverlay (const std::string &actionName, uint32_t angle, const OverlayColors &colors)
 Adds new color overlay with given angle (degrees) to given action. More...
 
OverlayColorsgetColorOverlay (const std::string &actionName, uint32_t angle)
 Returns closest matching color overlay for given angle and action. More...
 
void removeColorOverlay (const std::string &actionName, int32_t angle)
 Removes a color overlay with given angle (degrees) from given action. More...
 
void addAnimationOverlay (const std::string &actionName, uint32_t angle, int32_t order, const AnimationPtr &animationptr)
 Adds new animation overlay with given angle (degrees) and order to given action. More...
 
std::map< int32_t, AnimationPtrgetAnimationOverlay (const std::string &actionName, int32_t angle)
 Gets map with animations closest to given angle. More...
 
void removeAnimationOverlay (const std::string &actionName, uint32_t angle, int32_t order)
 Removes animation overlay with given angle (degrees) and order from action. More...
 
void addColorOverlay (const std::string &actionName, uint32_t angle, int32_t order, const OverlayColors &colors)
 Adds new color overlay with given angle (degrees) and order to given action animation overlay. More...
 
OverlayColorsgetColorOverlay (const std::string &actionName, uint32_t angle, int32_t order)
 Returns closest matching color overlay for given angle, order and action animation overlay. More...
 
void removeColorOverlay (const std::string &actionName, int32_t angle, int32_t order)
 Removes a color overlay with given angle (degrees), order from given action animation overlay. More...
 
void convertToOverlays (const std::string &actionName, bool color)
 If the action have base animation and optional color overlay it gets converted to animation overlay. More...
 
bool isAnimationOverlay (const std::string &actionName)
 Indicates if there exists a animation overlay for given action. More...
 
bool isColorOverlay (const std::string &actionName)
 Indicates if there exists a color overlay for given action or animation overlay. More...
 
- Public Member Functions inherited from FIFE::FifeClass
 FifeClass ()
 
virtual ~FifeClass ()
 
fifeid_t getFifeId ()
 Gets unique id of this instance inside the engine. More...
 
- Public Member Functions inherited from FIFE::InstanceDeleteListener
virtual ~InstanceDeleteListener ()
 

Private Member Functions

 Instance (const Instance &)
 
Instanceoperator= (const Instance &)
 
void finalizeAction ()
 Finalize current action. More...
 
void cancelAction ()
 Cancel 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...
 
void prepareForUpdate ()
 called to prepare the instance for an update More...
 
void createOwnObject ()
 Creates an own object for the instance to allow visual customization. More...
 
ActionVisualgetActionVisual (const std::string &actionName, bool create)
 Returns pointer to action visual, can also create it. More...
 

Private Attributes

std::string m_id
 
int32_t m_rotation
 The rotation offset of this instance. More...
 
InstanceActivitym_activity
 
InstanceChangeInfo m_changeInfo
 bitmask stating current changes More...
 
std::vector< InstanceDeleteListener * > m_deleteListeners
 listeners for deletion of the instance More...
 
Objectm_object
 object where instantiated from More...
 
bool m_ownObject
 indicates if m_object is customized More...
 
Location m_location
 current location More...
 
IVisualm_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...
 
Instancem_mainMultiInstance
 pointer to the main multi instance More...
 

Detailed Description

An Instance is an "instantiation" of an Object at a Location.

Definition at line 101 of file instance.h.

Constructor & Destructor Documentation

FIFE::Instance::Instance ( Object object,
const Location location,
const std::string &  identifier = "" 
)
FIFE::Instance::Instance ( const Instance )
private

Member Function Documentation

void FIFE::Instance::actOnce ( const std::string &  actionName,
const Location direction 
)

Performs given named action to the instance, once only.

Performs no movement

Parameters
actionNamename of the action
directioncoordinates for cell towards instance is heading to when performing the action

Definition at line 592 of file instance.cpp.

References initializeAction(), FIFE::Instance::InstanceActivity::m_actionInfo, m_activity, FIFE::ActionInfo::m_repeating, and setFacingLocation().

void FIFE::Instance::actOnce ( const std::string &  actionName,
int32_t  rotation 
)

Performs given named action to the instance, once only.

Performs no movement

Parameters
actionNamename of the action
rotationrotation which the instance use when performing the action

Definition at line 598 of file instance.cpp.

References initializeAction(), FIFE::Instance::InstanceActivity::m_actionInfo, m_activity, FIFE::ActionInfo::m_repeating, and setRotation().

void FIFE::Instance::actOnce ( const std::string &  actionName)

Performs given named action to the instance, once only.

Performs no movement and use current rotation

Parameters
actionNamename of the action

Definition at line 604 of file instance.cpp.

References initializeAction(), FIFE::Instance::InstanceActivity::m_actionInfo, m_activity, and FIFE::ActionInfo::m_repeating.

void FIFE::Instance::actRepeat ( const std::string &  actionName,
const Location direction 
)

Performs given named action to the instance, repeated.

Performs no movement

Parameters
actionNamename of the action
directioncoordinates for cell towards instance is heading to when performing the action

Definition at line 609 of file instance.cpp.

References initializeAction(), FIFE::Instance::InstanceActivity::m_actionInfo, m_activity, FIFE::ActionInfo::m_repeating, and setFacingLocation().

Referenced by FIFE::MapLoader::load().

+ Here is the caller graph for this function:

void FIFE::Instance::actRepeat ( const std::string &  actionName,
int32_t  rotation 
)

Performs given named action to the instance, repeated Performs no movement.

Parameters
actionNamename of the action
rotationrotation which the instance use when performing the action

Definition at line 615 of file instance.cpp.

References initializeAction(), FIFE::Instance::InstanceActivity::m_actionInfo, m_activity, FIFE::ActionInfo::m_repeating, and setRotation().

void FIFE::Instance::actRepeat ( const std::string &  actionName)

Performs given named action to the instance, repeated.

Performs no movement and use current rotation

Parameters
actionNamename of the action

Definition at line 621 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.

Parameters
listenerto add

Definition at line 364 of file instance.cpp.

References initializeChanges(), FIFE::Instance::InstanceActivity::m_actionListeners, and m_activity.

void FIFE::Instance::addAnimationOverlay ( const std::string &  actionName,
uint32_t  angle,
int32_t  order,
const AnimationPtr animationptr 
)

Adds new animation overlay with given angle (degrees) and order to given action.

Definition at line 1166 of file instance.cpp.

References FIFE::ActionVisual::addAnimationOverlay(), getActionVisual(), FIFE::ICHANGE_VISUAL, m_activity, FIFE::Instance::InstanceActivity::m_additional, and prepareForUpdate().

void FIFE::Instance::addChangeListener ( InstanceChangeListener listener)

Adds new instance change listener.

Parameters
listenerto add

Definition at line 384 of file instance.cpp.

References initializeChanges(), m_activity, and FIFE::Instance::InstanceActivity::m_changeListeners.

Referenced by FIFE::Trigger::attach(), and FIFE::SoundSource::SoundSource().

+ Here is the caller graph for this function:

void FIFE::Instance::addColorOverlay ( const std::string &  actionName,
uint32_t  angle,
const OverlayColors colors 
)

Adds new color overlay with given angle (degrees) to given action.

Definition at line 1140 of file instance.cpp.

References FIFE::ActionVisual::addColorOverlay(), getActionVisual(), FIFE::ICHANGE_VISUAL, m_activity, FIFE::Instance::InstanceActivity::m_additional, and prepareForUpdate().

void FIFE::Instance::addColorOverlay ( const std::string &  actionName,
uint32_t  angle,
int32_t  order,
const OverlayColors colors 
)

Adds new color overlay with given angle (degrees) and order to given action animation overlay.

Definition at line 1192 of file instance.cpp.

References FIFE::ActionVisual::addColorOverlay(), getActionVisual(), FIFE::ICHANGE_VISUAL, m_activity, FIFE::Instance::InstanceActivity::m_additional, and prepareForUpdate().

void FIFE::Instance::addDeleteListener ( InstanceDeleteListener listener)

Adds new instance delete listener.

Parameters
listenerto add

Definition at line 1283 of file instance.cpp.

References m_deleteListeners.

Referenced by FIFE::InstanceRenderer::addColored(), FIFE::RendererNode::addInstance(), FIFE::InstanceRenderer::addOutlined(), FIFE::InstanceRenderer::addTransparentArea(), FIFE::Trigger::attach(), FIFE::RendererNode::changeInstance(), follow(), and Instance().

+ Here is the caller graph for this function:

void FIFE::Instance::addStaticColorOverlay ( uint32_t  angle,
const OverlayColors colors 
)
void FIFE::Instance::bindTimeProvider ( )
private
void FIFE::Instance::calcMovement ( )
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.

Parameters
actionpointer to the action
frameframe index number of the animation

Definition at line 389 of file instance.cpp.

References FIFE::Instance::InstanceActivity::m_actionListeners, and m_activity.

Referenced by FIFE::LayerCache::updateVisual().

+ Here is the caller graph for this function:

void FIFE::Instance::callOnStackPositionChange ( )

Definition at line 986 of file instance.cpp.

References FIFE::ICHANGE_STACKPOS, m_activity, FIFE::Instance::InstanceActivity::m_additional, and prepareForUpdate().

Referenced by FIFE::InstanceVisual::setStackPosition().

+ Here is the caller graph for this function:

void FIFE::Instance::callOnTransparencyChange ( )

Definition at line 976 of file instance.cpp.

References FIFE::ICHANGE_TRANSPARENCY, m_activity, FIFE::Instance::InstanceActivity::m_additional, and prepareForUpdate().

Referenced by FIFE::InstanceVisual::setTransparency().

+ Here is the caller graph for this function:

void FIFE::Instance::callOnVisibleChange ( )

Definition at line 981 of file instance.cpp.

References FIFE::ICHANGE_VISIBLE, m_activity, FIFE::Instance::InstanceActivity::m_additional, and prepareForUpdate().

Referenced by FIFE::InstanceVisual::setVisible().

+ Here is the caller graph for this function:

void FIFE::Instance::cancelMovement ( uint32_t  length = 1)

Cancel movement after a given length.

If no length is set then 1 is used. This means that the instance stops at the center of the next cell (can be the same as the current).

Definition at line 522 of file instance.cpp.

References FIFE::Route::cutPath(), FIFE::Instance::InstanceActivity::m_actionInfo, m_activity, and FIFE::ActionInfo::m_route.

void FIFE::Instance::convertToOverlays ( const std::string &  actionName,
bool  color 
)

If the action have base animation and optional color overlay it gets converted to animation overlay.

Definition at line 1234 of file instance.cpp.

References FIFE::ActionVisual::convertToOverlays(), and getActionVisual().

void FIFE::Instance::createOwnObject ( )
private

Creates an own object for the instance to allow visual customization.

Definition at line 1239 of file instance.cpp.

References FIFE::Object::adoptVisual(), FIFE::ObjectVisual::create(), FIFE::Object::getId(), FIFE::Object::getNamespace(), FIFE::Object::getVisual(), m_object, and m_ownObject.

Referenced by addStaticColorOverlay(), and getActionVisual().

+ Here is the caller graph for this function:

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

Parameters
actionNamename of the action
leaderfollowed instance
speedspeed used for movement. Units = distance 1 in layer coordinates per second

Definition at line 497 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 deleted or resetted at the end.

Parameters
actionNamename of the action
routefollowed route
speedspeed used for movement. Units = distance 1 in layer coordinates per second

Definition at line 506 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.

Returns
action runtime

Definition at line 931 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().

+ Here is the caller graph for this function:

std::map< int32_t, AnimationPtr > FIFE::Instance::getAnimationOverlay ( const std::string &  actionName,
int32_t  angle 
)

Gets map with animations closest to given angle.

Returns
ordered animation map

Definition at line 1175 of file instance.cpp.

References getActionVisual(), and FIFE::ActionVisual::getAnimationOverlay().

uint8_t FIFE::Instance::getCellStackPosition ( )

Gets the cell stack position.

Definition at line 572 of file instance.cpp.

References m_cellStackPos.

InstanceChangeInfo FIFE::Instance::getChangeInfo ( )

Returns a bitmask of changes of the last update.

Definition at line 969 of file instance.cpp.

References FIFE::ICHANGE_NO_CHANGES, m_activity, and m_changeInfo.

Referenced by FIFE::LayerCache::updateInstance().

+ Here is the caller graph for this function:

OverlayColors * FIFE::Instance::getColorOverlay ( const std::string &  actionName,
uint32_t  angle 
)

Returns closest matching color overlay for given angle and action.

Returns
pointer to OverlayColor class

Definition at line 1149 of file instance.cpp.

References getActionVisual(), and FIFE::ActionVisual::getColorOverlay().

OverlayColors * FIFE::Instance::getColorOverlay ( const std::string &  actionName,
uint32_t  angle,
int32_t  order 
)

Returns closest matching color overlay for given angle, order and action animation overlay.

Returns
pointer to OverlayColor class

Definition at line 1201 of file instance.cpp.

References getActionVisual(), and FIFE::ActionVisual::getColorOverlay().

double FIFE::Instance::getCost ( )

Returns cost value.

In case there is no it returns the object cost.

Definition at line 1044 of file instance.cpp.

References FIFE::Object::getCost(), m_cost, m_object, and m_specialCost.

Referenced by FIFE::Cell::addInstance().

+ Here is the caller graph for this function:

std::string FIFE::Instance::getCostId ( )

Returns cost id.

In case there is no it returns the object cost id.

Definition at line 1051 of file instance.cpp.

References FIFE::Object::getCostId(), m_costId, m_object, and m_specialCost.

Referenced by FIFE::Cell::addInstance(), and FIFE::Cell::removeInstance().

+ Here is the caller graph for this function:

Action * FIFE::Instance::getCurrentAction ( ) const

Gets the currently active action.

This is owned by the instance's object, so don't delete it!

Returns
current action, NULL in case there is none

Definition at line 888 of file instance.cpp.

References FIFE::ActionInfo::m_action, FIFE::Instance::InstanceActivity::m_actionInfo, and m_activity.

Referenced by getActionVisual(), and FIFE::LayerCache::updateVisual().

+ Here is the caller graph for this function:

Location FIFE::Instance::getFacingLocation ( )

Returns the direction where instance is heading.

Note
does not return const Location&, since swig wont be const correct
Returns
the direction of instance.

Definition at line 913 of file instance.cpp.

References FIFE::getFacing(), m_location, and m_rotation.

Referenced by FIFE::SoundSource::setDirection().

+ Here is the caller graph for this function:

const std::string & FIFE::Instance::getId ( )

Get the identifier for this instance; possibly null.

Definition at line 341 of file instance.cpp.

References m_id.

Location FIFE::Instance::getLocation ( ) const

Gets current location of instance.

Note
does not return const Location&, since swig wont be const correct
Returns
current location

Definition at line 314 of file instance.cpp.

References m_location.

Referenced by FIFE::Camera::attach(), FIFE::InstanceRenderer::renderAlreadySorted(), and FIFE::InstanceRenderer::renderUnsorted().

+ Here is the caller graph for this function:

Instance * FIFE::Instance::getMainMultiInstance ( )

Returns a pointer to the main mulit instance or Null if the instance is not part of a multi instance object.

Definition at line 588 of file instance.cpp.

References m_mainMultiInstance.

double FIFE::Instance::getMovementSpeed ( ) const

Gets the speed in case instance is moving otherwise returns 0.

Returns
instance speed. Value 1 means distance 1 in layer coordinates / second

Definition at line 902 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 580 of file instance.cpp.

References m_multiInstances.

Referenced by FIFE::CellCacheChangeListener::onInstanceCreate(), and FIFE::CellCacheChangeListener::onInstanceDelete().

+ Here is the caller graph for this function:

Object * FIFE::Instance::getObject ( )
Location & FIFE::Instance::getOldLocationRef ( )

Gets reference of old location of instance.

Returns
reference to old location

Definition at line 917 of file instance.cpp.

References m_activity, m_location, and FIFE::Instance::InstanceActivity::m_oldLocation.

Referenced by FIFE::Trigger::move(), and FIFE::Map::update().

+ Here is the caller graph for this function:

int32_t FIFE::Instance::getOldRotation ( ) const

Get the old rotation offset of this instance Returns direction where instance was heading.

Definition at line 924 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 333 of file instance.cpp.

References m_rotation.

Referenced by move(), FIFE::CellCacheChangeListener::onInstanceCreate(), FIFE::CellCacheChangeListener::onInstanceDelete(), processMovement(), and FIFE::LayerCache::updateVisual().

+ Here is the caller graph for this function:

Route * FIFE::Instance::getRoute ( )

Returns a pointer to the route, in case there is no, it returns NULL.

Definition at line 534 of file instance.cpp.

References FIFE::Instance::InstanceActivity::m_actionInfo, m_activity, and FIFE::ActionInfo::m_route.

uint32_t FIFE::Instance::getRuntime ( )
const std::string * FIFE::Instance::getSayText ( ) const

Returns pointer to currently set saytext.

In case no text is set, returns NULL

Definition at line 637 of file instance.cpp.

References m_activity, FIFE::Instance::InstanceActivity::m_sayInfo, and FIFE::SayInfo::m_txt.

Referenced by FIFE::FloatingTextRenderer::render().

+ Here is the caller graph for this function:

double FIFE::Instance::getSpeed ( )

Returns speed modifier.

Definition at line 1058 of file instance.cpp.

References FIFE::Object::getSpeed(), and m_object.

Referenced by FIFE::Cell::addInstance().

+ Here is the caller graph for this function:

OverlayColors * FIFE::Instance::getStaticColorOverlay ( int32_t  angle)

Returns closest matching static color overlay for given angle.

Returns
pointer to OverlayColor class

Definition at line 1115 of file instance.cpp.

References FIFE::ObjectVisual::getStaticColorOverlay(), FIFE::Object::getVisual(), m_object, and m_ownObject.

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

See also
move
Note
does not return const Location&, since swig wont be const correct
Returns
Movement target location

Definition at line 895 of file instance.cpp.

References FIFE::Instance::InstanceActivity::m_actionInfo, m_activity, m_location, and FIFE::ActionInfo::m_target.

float FIFE::Instance::getTimeMultiplier ( )
float FIFE::Instance::getTotalTimeMultiplier ( )
uint16_t FIFE::Instance::getVisitorRadius ( )

Gets the visitor range.

Definition at line 564 of file instance.cpp.

References m_visitorRadius.

Referenced by FIFE::Cell::addInstance(), and FIFE::Cell::removeInstance().

+ Here is the caller graph for this function:

VisitorShapeInfo FIFE::Instance::getVisitorShape ( )

Gets the shape type for a visitor.

Definition at line 556 of file instance.cpp.

References m_visitorShape.

Referenced by FIFE::Cell::addInstance(), and FIFE::Cell::removeInstance().

+ Here is the caller graph for this function:

void FIFE::Instance::initializeChanges ( )
private

called when instance has been changed. Causes instance to create InstanceActivity

Definition at line 274 of file instance.cpp.

References FIFE::Location::getLayer(), m_activity, m_location, and FIFE::Layer::setInstanceActivityStatus().

Referenced by addActionListener(), addChangeListener(), initializeAction(), prepareForUpdate(), refresh(), say(), and setTimeMultiplier().

+ Here is the caller graph for this function:

bool FIFE::Instance::isActive ( ) const

If this returns true, the instance needs to be updated.

Definition at line 291 of file instance.cpp.

References m_activity.

Referenced by FIFE::Layer::addInstance(), FIFE::Layer::createInstance(), FIFE::Layer::deleteInstance(), prepareForUpdate(), and FIFE::Layer::removeInstance().

+ Here is the caller graph for this function:

bool FIFE::Instance::isAnimationOverlay ( const std::string &  actionName)

Indicates if there exists a animation overlay for given action.

Definition at line 1218 of file instance.cpp.

References getActionVisual(), and FIFE::ActionVisual::isAnimationOverlay().

bool FIFE::Instance::isBlocking ( ) const

Gets if instance blocks movement.

Definition at line 352 of file instance.cpp.

References m_blocking.

Referenced by FIFE::BlockingInfoRenderer::render().

+ Here is the caller graph for this function:

bool FIFE::Instance::isColorOverlay ( const std::string &  actionName)

Indicates if there exists a color overlay for given action or animation overlay.

Definition at line 1226 of file instance.cpp.

References getActionVisual(), and FIFE::ActionVisual::isColorOverlay().

bool FIFE::Instance::isMultiCell ( )

Returns true if it is multi cell otherwise false.

Definition at line 1066 of file instance.cpp.

References FIFE::Object::isMultiObject(), and m_object.

Referenced by follow(), move(), FIFE::CellCacheChangeListener::onInstanceCreate(), FIFE::CellCacheChangeListener::onInstanceDelete(), and processMovement().

+ Here is the caller graph for this function:

bool FIFE::Instance::isMultiObject ( )

Returns true if it is multi object otherwise false.

Definition at line 1070 of file instance.cpp.

References m_multiInstances.

Referenced by cancelAction(), finalizeAction(), initializeAction(), and onInstanceDeleted().

+ Here is the caller graph for this function:

bool FIFE::Instance::isOverrideBlocking ( ) const

Gets if instance blocking can overriden.

Definition at line 360 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 576 of file instance.cpp.

References m_specialCost.

Referenced by FIFE::Cell::addInstance(), and FIFE::Cell::removeInstance().

+ Here is the caller graph for this function:

bool FIFE::Instance::isSpecialSpeed ( )

Returns true if instance or object have special speed modifier otherwise false.

Definition at line 1062 of file instance.cpp.

References FIFE::Object::isSpecialSpeed(), and m_object.

Referenced by FIFE::Cell::addInstance(), and FIFE::Cell::removeInstance().

+ Here is the caller graph for this function:

bool FIFE::Instance::isStaticColorOverlay ( )

Indicates if there exists a static color overlay.

Definition at line 1132 of file instance.cpp.

References FIFE::Object::getVisual(), FIFE::ObjectVisual::isColorOverlay(), m_object, and m_ownObject.

bool FIFE::Instance::isVisitor ( )

If instance is a visitor it returns true otherwise false.

Definition at line 548 of file instance.cpp.

References m_isVisitor.

Referenced by FIFE::Cell::addInstance(), and FIFE::Cell::removeInstance().

+ Here is the caller graph for this function:

void FIFE::Instance::move ( const std::string &  actionName,
const Location target,
const double  speed,
const std::string &  costId = "" 
)
void FIFE::Instance::onInstanceDeleted ( Instance instance)
virtual

callback so other instances we depend on can notify us if they go away

Implements FIFE::InstanceDeleteListener.

Definition at line 1302 of file instance.cpp.

References isMultiObject(), FIFE::Instance::InstanceActivity::m_actionInfo, m_activity, FIFE::ActionInfo::m_leader, and m_multiInstances.

Instance& FIFE::Instance::operator= ( const Instance )
private
void FIFE::Instance::prepareForUpdate ( )
private
bool FIFE::Instance::processMovement ( )
private
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 964 of file instance.cpp.

References bindTimeProvider(), and initializeChanges().

Referenced by prepareForUpdate().

+ Here is the caller graph for this function:

void FIFE::Instance::removeActionListener ( InstanceActionListener listener)

Removes associated instance action listener.

Parameters
listenerto remove

Definition at line 369 of file instance.cpp.

References FIFE::_log, FL_WARN, FIFE::Instance::InstanceActivity::m_actionListeners, and m_activity.

void FIFE::Instance::removeAnimationOverlay ( const std::string &  actionName,
uint32_t  angle,
int32_t  order 
)

Removes animation overlay with given angle (degrees) and order from action.

Definition at line 1183 of file instance.cpp.

References getActionVisual(), FIFE::ICHANGE_VISUAL, m_activity, FIFE::Instance::InstanceActivity::m_additional, prepareForUpdate(), and FIFE::ActionVisual::removeAnimationOverlay().

void FIFE::Instance::removeChangeListener ( InstanceChangeListener listener)

Removes associated instance change listener.

Parameters
listenerto remove

Definition at line 403 of file instance.cpp.

References FIFE::_log, FL_WARN, m_activity, and FIFE::Instance::InstanceActivity::m_changeListeners.

Referenced by FIFE::Trigger::detach(), and FIFE::SoundSource::~SoundSource().

+ Here is the caller graph for this function:

void FIFE::Instance::removeColorOverlay ( const std::string &  actionName,
int32_t  angle 
)

Removes a color overlay with given angle (degrees) from given action.

Definition at line 1157 of file instance.cpp.

References getActionVisual(), FIFE::ICHANGE_VISUAL, m_activity, FIFE::Instance::InstanceActivity::m_additional, prepareForUpdate(), and FIFE::ActionVisual::removeColorOverlay().

void FIFE::Instance::removeColorOverlay ( const std::string &  actionName,
int32_t  angle,
int32_t  order 
)

Removes a color overlay with given angle (degrees), order from given action animation overlay.

Definition at line 1209 of file instance.cpp.

References getActionVisual(), FIFE::ICHANGE_VISUAL, m_activity, FIFE::Instance::InstanceActivity::m_additional, prepareForUpdate(), and FIFE::ActionVisual::removeColorOverlay().

void FIFE::Instance::removeDeleteListener ( InstanceDeleteListener listener)
void FIFE::Instance::removeStaticColorOverlay ( int32_t  angle)
void FIFE::Instance::resetCost ( )

Resets cost.

Definition at line 1040 of file instance.cpp.

References m_specialCost.

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)

Parameters
texttext to say. If "" given, clear the text
durationduration to show the text (in ms). If 0, shows forever

Definition at line 626 of file instance.cpp.

References getRuntime(), initializeChanges(), m_activity, FIFE::Instance::InstanceActivity::m_sayInfo, and FIFE::SayInfo::m_start_time.

Referenced by update().

+ Here is the caller graph for this function:

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

Parameters
time_offsetThe action time offset that should be applied

Definition at line 940 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 345 of file instance.cpp.

References m_blocking, m_overrideBlocking, and prepareForUpdate().

void FIFE::Instance::setCellStackPosition ( uint8_t  stack)

Sets the cell stack position.

Definition at line 568 of file instance.cpp.

References m_cellStackPos.

Referenced by FIFE::MapLoader::load().

+ Here is the caller graph for this function:

void FIFE::Instance::setCost ( const std::string &  id,
double  cost 
)

Sets for the given cost id a cost.

Parameters
idname of the cost id
costvalue for the cost

Definition at line 1034 of file instance.cpp.

References m_cost, m_costId, and m_specialCost.

Referenced by FIFE::MapLoader::load().

+ Here is the caller graph for this function:

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 909 of file instance.cpp.

References FIFE::getAngleBetween(), m_location, and setRotation().

Referenced by actOnce(), actRepeat(), move(), and processMovement().

+ Here is the caller graph for this function:

void FIFE::Instance::setId ( const std::string &  identifier = "")

Set the identifier for this instance.

Definition at line 337 of file instance.cpp.

References m_id.

void FIFE::Instance::setLocation ( const Location loc)

Sets location of the instance.

Parameters
locnew location

Definition at line 299 of file instance.cpp.

References FIFE::InstanceTree::addInstance(), FIFE::Layer::getInstanceTree(), FIFE::Location::getLayer(), FIFE::Location::getLayerCoordinates(), m_location, prepareForUpdate(), and FIFE::InstanceTree::removeInstance().

Referenced by processMovement().

+ Here is the caller graph for this function:

void FIFE::Instance::setMainMultiInstance ( Instance main)

Sets a instance to the main multi instance of this instance.

Definition at line 584 of file instance.cpp.

References m_mainMultiInstance.

Referenced by Instance().

+ Here is the caller graph for this function:

void FIFE::Instance::setOverrideBlocking ( bool  overblock)

Sets if instance blocking can overriden.

Definition at line 356 of file instance.cpp.

References m_overrideBlocking.

void FIFE::Instance::setRotation ( int32_t  rotation)

Set the rotation offset of this instance.

Definition at line 322 of file instance.cpp.

References m_rotation, and prepareForUpdate().

Referenced by actOnce(), actRepeat(), FIFE::MapLoader::load(), processMovement(), and setFacingLocation().

+ Here is the caller graph for this function:

void FIFE::Instance::setTimeMultiplier ( float  multip)
void FIFE::Instance::setVisitor ( bool  visit)

Marks this instance as a visitor.

Definition at line 544 of file instance.cpp.

References m_isVisitor.

Referenced by FIFE::MapLoader::load().

+ Here is the caller graph for this function:

void FIFE::Instance::setVisitorRadius ( uint16_t  radius)

Sets the range for a visitor.

Definition at line 560 of file instance.cpp.

References m_visitorRadius.

Referenced by FIFE::MapLoader::load().

+ Here is the caller graph for this function:

void FIFE::Instance::setVisitorShape ( VisitorShapeInfo  info)

Sets the shape type for a visitor.

Definition at line 552 of file instance.cpp.

References m_visitorShape.

Referenced by FIFE::MapLoader::load().

+ Here is the caller graph for this function:

void FIFE::Instance::setVisual ( IVisual visual)
inline

Sets visualization to be used.

Transfers ownership.

Definition at line 345 of file instance.h.

Referenced by FIFE::InstanceVisual::create().

+ Here is the caller graph for this function:

Member Data Documentation

bool FIFE::Instance::m_blocking
private

instance blocking info

Definition at line 616 of file instance.h.

Referenced by isBlocking(), setBlocking(), and FIFE::Instance::InstanceActivity::update().

uint8_t FIFE::Instance::m_cellStackPos
private

position on cell stack

Definition at line 626 of file instance.h.

Referenced by getCellStackPosition(), and setCellStackPosition().

InstanceChangeInfo FIFE::Instance::m_changeInfo
private

bitmask stating current changes

Definition at line 603 of file instance.h.

Referenced by getChangeInfo(), update(), and FIFE::Instance::InstanceActivity::update().

double FIFE::Instance::m_cost
private

holds cost value

Definition at line 630 of file instance.h.

Referenced by getCost(), and setCost().

std::string FIFE::Instance::m_costId
private

holds cost id

Definition at line 632 of file instance.h.

Referenced by getCostId(), and setCost().

std::vector<InstanceDeleteListener*> FIFE::Instance::m_deleteListeners
private

listeners for deletion of the instance

Definition at line 605 of file instance.h.

Referenced by addDeleteListener(), removeDeleteListener(), update(), and ~Instance().

std::string FIFE::Instance::m_id
private

Definition at line 544 of file instance.h.

Referenced by getId(), and setId().

bool FIFE::Instance::m_isVisitor
private

is instance a visitor (FoW)

Definition at line 620 of file instance.h.

Referenced by isVisitor(), and setVisitor().

Instance* FIFE::Instance::m_mainMultiInstance
private

pointer to the main multi instance

Definition at line 636 of file instance.h.

Referenced by getMainMultiInstance(), Instance(), and setMainMultiInstance().

std::vector<Instance*> FIFE::Instance::m_multiInstances
private
bool FIFE::Instance::m_overrideBlocking
private

allow to override the blocking property

Definition at line 618 of file instance.h.

Referenced by isOverrideBlocking(), setBlocking(), and setOverrideBlocking().

bool FIFE::Instance::m_ownObject
private
int32_t FIFE::Instance::m_rotation
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 548 of file instance.h.

Referenced by follow(), getFacingLocation(), getOldRotation(), getRotation(), Instance(), move(), processMovement(), setRotation(), FIFE::Instance::InstanceActivity::update(), and updateMultiInstances().

bool FIFE::Instance::m_specialCost
private

indicates special cost

Definition at line 628 of file instance.h.

Referenced by getCost(), getCostId(), isSpecialCost(), resetCost(), and setCost().

uint16_t FIFE::Instance::m_visitorRadius
private

visitor radius (FoW)

Definition at line 624 of file instance.h.

Referenced by getVisitorRadius(), and setVisitorRadius().

VisitorShapeInfo FIFE::Instance::m_visitorShape
private

visitor shape type

Definition at line 622 of file instance.h.

Referenced by getVisitorShape(), and setVisitorShape().

IVisual* FIFE::Instance::m_visual
private

instance visualization

Definition at line 614 of file instance.h.

Referenced by ~Instance().


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