FIFE  be64c707dea6b3250bd4355bf5c825d25920087d
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 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...
 
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 94 of file instance.h.

Constructor & Destructor Documentation

◆ Instance() [1/2]

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

◆ ~Instance()

◆ Instance() [2/2]

FIFE::Instance::Instance ( const Instance )
private

Member Function Documentation

◆ actOnce() [1/3]

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

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

◆ actOnce() [2/3]

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

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

◆ actOnce() [3/3]

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

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

◆ actRepeat() [1/3]

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 582 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:

◆ actRepeat() [2/3]

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

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

◆ actRepeat() [3/3]

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

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

◆ addActionListener()

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

Adds new instance action listener.

Parameters
listenerto add

Definition at line 361 of file instance.cpp.

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

◆ addAnimationOverlay()

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

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

◆ addChangeListener()

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

Adds new instance change listener.

Parameters
listenerto add

Definition at line 381 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:

◆ addColorOverlay() [1/2]

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

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

◆ addColorOverlay() [2/2]

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

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

◆ addDeleteListener()

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

Adds new instance delete listener.

Parameters
listenerto add

Definition at line 1256 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:

◆ addStaticColorOverlay()

void FIFE::Instance::addStaticColorOverlay ( uint32_t  angle,
const OverlayColors colors 
)

◆ bindTimeProvider()

void FIFE::Instance::bindTimeProvider ( )
private

◆ calcMovement()

void FIFE::Instance::calcMovement ( )
private

Calculates movement based current location and speed.

◆ callOnActionFrame()

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 386 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:

◆ callOnStackPositionChange()

void FIFE::Instance::callOnStackPositionChange ( )

Definition at line 959 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:

◆ callOnTransparencyChange()

void FIFE::Instance::callOnTransparencyChange ( )

Definition at line 949 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:

◆ callOnVisibleChange()

void FIFE::Instance::callOnVisibleChange ( )

Definition at line 954 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:

◆ cancelAction()

◆ cancelMovement()

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

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

◆ convertToOverlays()

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

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

◆ createOwnObject()

void FIFE::Instance::createOwnObject ( )
private

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

Definition at line 1212 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:

◆ finalizeAction()

◆ follow() [1/2]

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 494 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.

◆ follow() [2/2]

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 503 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().

◆ getActionRuntime()

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 904 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:

◆ getActionVisual()

◆ getAnimationOverlay()

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

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

◆ getCellStackPosition()

uint8_t FIFE::Instance::getCellStackPosition ( )

Gets the cell stack position.

Definition at line 545 of file instance.cpp.

References m_cellStackPos.

◆ getChangeInfo()

InstanceChangeInfo FIFE::Instance::getChangeInfo ( )

Returns a bitmask of changes of the last update.

Definition at line 942 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:

◆ getColorOverlay() [1/2]

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

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

◆ getColorOverlay() [2/2]

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

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

◆ getCost()

double FIFE::Instance::getCost ( )

Returns cost value.

In case there is no it returns the object cost.

Definition at line 1017 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:

◆ getCostId()

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

Returns cost id.

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

Definition at line 1024 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:

◆ getCurrentAction()

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 861 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:

◆ getFacingLocation()

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 886 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:

◆ getId()

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

Get the identifier for this instance; possibly null.

Definition at line 338 of file instance.cpp.

References m_id.

◆ getLocation()

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

References m_location.

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

+ Here is the caller graph for this function:

◆ getLocationRef()

◆ getMainMultiInstance()

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

References m_mainMultiInstance.

◆ getMovementSpeed()

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

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

◆ getMultiInstances()

const std::vector< Instance * > & FIFE::Instance::getMultiInstances ( )

Returns a vector that contains all instances of a multi object.

Definition at line 553 of file instance.cpp.

References m_multiInstances.

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

+ Here is the caller graph for this function:

◆ getObject()

Object * FIFE::Instance::getObject ( )

◆ getOldLocationRef()

Location & FIFE::Instance::getOldLocationRef ( )

Gets reference of old location of instance.

Returns
reference to old location

Definition at line 890 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:

◆ getOldRotation()

int32_t FIFE::Instance::getOldRotation ( ) const

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

Definition at line 897 of file instance.cpp.

References m_activity, FIFE::Instance::InstanceActivity::m_oldRotation, and m_rotation.

◆ getRotation()

int32_t FIFE::Instance::getRotation ( ) const

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

Definition at line 330 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:

◆ getRoute()

Route * FIFE::Instance::getRoute ( )

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

Definition at line 531 of file instance.cpp.

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

◆ getRuntime()

uint32_t FIFE::Instance::getRuntime ( )

◆ getSayText()

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

Returns pointer to currently set saytext.

In case no text is set, returns NULL

Definition at line 610 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:

◆ getSpeed()

double FIFE::Instance::getSpeed ( )

Returns speed modifier.

Definition at line 1031 of file instance.cpp.

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

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

+ Here is the caller graph for this function:

◆ getStaticColorOverlay()

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

Returns closest matching static color overlay for given angle.

Returns
pointer to OverlayColor class

Definition at line 1088 of file instance.cpp.

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

◆ getTargetLocation()

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

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

◆ getTimeMultiplier()

float FIFE::Instance::getTimeMultiplier ( )

◆ getTotalTimeMultiplier()

float FIFE::Instance::getTotalTimeMultiplier ( )

◆ getVisual()

◆ initializeAction()

◆ initializeChanges()

void FIFE::Instance::initializeChanges ( )
private

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

Definition at line 271 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:

◆ isActive()

bool FIFE::Instance::isActive ( ) const

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

Definition at line 288 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:

◆ isAnimationOverlay()

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

Indicates if there exists a animation overlay for given action.

Definition at line 1191 of file instance.cpp.

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

◆ isBlocking()

bool FIFE::Instance::isBlocking ( ) const

Gets if instance blocks movement.

Definition at line 349 of file instance.cpp.

References m_blocking.

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

+ Here is the caller graph for this function:

◆ isColorOverlay()

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

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

Definition at line 1199 of file instance.cpp.

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

◆ isMultiCell()

bool FIFE::Instance::isMultiCell ( )

Returns true if it is multi cell otherwise false.

Definition at line 1039 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:

◆ isMultiObject()

bool FIFE::Instance::isMultiObject ( )

Returns true if it is multi object otherwise false.

Definition at line 1043 of file instance.cpp.

References m_multiInstances.

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

+ Here is the caller graph for this function:

◆ isOverrideBlocking()

bool FIFE::Instance::isOverrideBlocking ( ) const

Gets if instance blocking can overriden.

Definition at line 357 of file instance.cpp.

References m_overrideBlocking.

◆ isSpecialCost()

bool FIFE::Instance::isSpecialCost ( )

Returns true if instance or object have special cost otherwise false.

Definition at line 549 of file instance.cpp.

References m_specialCost.

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

+ Here is the caller graph for this function:

◆ isSpecialSpeed()

bool FIFE::Instance::isSpecialSpeed ( )

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

Definition at line 1035 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:

◆ isStaticColorOverlay()

bool FIFE::Instance::isStaticColorOverlay ( )

Indicates if there exists a static color overlay.

Definition at line 1105 of file instance.cpp.

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

◆ move()

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

◆ onInstanceDeleted()

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

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

◆ operator=()

Instance& FIFE::Instance::operator= ( const Instance )
private

◆ prepareForUpdate()

void FIFE::Instance::prepareForUpdate ( )
private

◆ processMovement()

bool FIFE::Instance::processMovement ( )
private

◆ refresh()

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

References bindTimeProvider(), and initializeChanges().

Referenced by prepareForUpdate().

+ Here is the caller graph for this function:

◆ removeActionListener()

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

Removes associated instance action listener.

Parameters
listenerto remove

Definition at line 366 of file instance.cpp.

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

◆ removeAnimationOverlay()

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

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

◆ removeChangeListener()

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

Removes associated instance change listener.

Parameters
listenerto remove

Definition at line 400 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:

◆ removeColorOverlay() [1/2]

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

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

◆ removeColorOverlay() [2/2]

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

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

◆ removeDeleteListener()

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

◆ removeStaticColorOverlay()

void FIFE::Instance::removeStaticColorOverlay ( int32_t  angle)

◆ resetCost()

void FIFE::Instance::resetCost ( )

Resets cost.

Definition at line 1013 of file instance.cpp.

References m_specialCost.

◆ say()

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 599 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:

◆ setActionRuntime()

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

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

◆ setBlocking()

void FIFE::Instance::setBlocking ( bool  blocking)

Sets if instance blocks movement.

Definition at line 342 of file instance.cpp.

References m_blocking, m_overrideBlocking, and prepareForUpdate().

◆ setCellStackPosition()

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

Sets the cell stack position.

Definition at line 541 of file instance.cpp.

References m_cellStackPos.

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

+ Here is the caller graph for this function:

◆ setCost()

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 1007 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:

◆ setFacingLocation()

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 882 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:

◆ setId()

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

Set the identifier for this instance.

Definition at line 334 of file instance.cpp.

References m_id.

◆ setLocation()

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

Sets location of the instance.

Parameters
locnew location

Definition at line 296 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:

◆ setMainMultiInstance()

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

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

Definition at line 557 of file instance.cpp.

References m_mainMultiInstance.

Referenced by Instance().

+ Here is the caller graph for this function:

◆ setOverrideBlocking()

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

Sets if instance blocking can overriden.

Definition at line 353 of file instance.cpp.

References m_overrideBlocking.

◆ setRotation()

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

Set the rotation offset of this instance.

Definition at line 319 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:

◆ setTimeMultiplier()

void FIFE::Instance::setTimeMultiplier ( float  multip)

◆ setVisual()

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

Sets visualization to be used.

Transfers ownership.

Definition at line 338 of file instance.h.

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

+ Here is the caller graph for this function:

◆ update()

◆ updateMultiInstances()

Member Data Documentation

◆ m_activity

◆ m_blocking

bool FIFE::Instance::m_blocking
private

instance blocking info

Definition at line 585 of file instance.h.

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

◆ m_cellStackPos

uint8_t FIFE::Instance::m_cellStackPos
private

position on cell stack

Definition at line 589 of file instance.h.

Referenced by getCellStackPosition(), and setCellStackPosition().

◆ m_changeInfo

InstanceChangeInfo FIFE::Instance::m_changeInfo
private

bitmask stating current changes

Definition at line 572 of file instance.h.

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

◆ m_cost

double FIFE::Instance::m_cost
private

holds cost value

Definition at line 593 of file instance.h.

Referenced by getCost(), and setCost().

◆ m_costId

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

holds cost id

Definition at line 595 of file instance.h.

Referenced by getCostId(), and setCost().

◆ m_deleteListeners

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

listeners for deletion of the instance

Definition at line 574 of file instance.h.

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

◆ m_id

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

Definition at line 513 of file instance.h.

Referenced by getId(), and setId().

◆ m_location

◆ m_mainMultiInstance

Instance* FIFE::Instance::m_mainMultiInstance
private

pointer to the main multi instance

Definition at line 599 of file instance.h.

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

◆ m_multiInstances

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

◆ m_object

◆ m_overrideBlocking

bool FIFE::Instance::m_overrideBlocking
private

allow to override the blocking property

Definition at line 587 of file instance.h.

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

◆ m_ownObject

bool FIFE::Instance::m_ownObject
private

◆ m_rotation

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 517 of file instance.h.

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

◆ m_specialCost

bool FIFE::Instance::m_specialCost
private

indicates special cost

Definition at line 591 of file instance.h.

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

◆ m_visual

IVisual* FIFE::Instance::m_visual
private

instance visualization

Definition at line 583 of file instance.h.

Referenced by ~Instance().


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