FIFE  2008.0
 All Classes Namespaces Functions Variables Enumerations Enumerator Pages
FIFE::Instance Class Reference

#include <instance.h>

Inheritance diagram for FIFE::Instance:
Inheritance graph
Collaboration diagram for FIFE::Instance:
Collaboration graph

Public Member Functions

 Instance (Object *object, const Location &location, const std::string &identifier="")
 
virtual ~Instance ()
 
const std::string & getId ()
 
void setId (const std::string &identifier="")
 
ObjectgetObject ()
 
void setLocation (const Location &loc)
 
Location getLocation () const
 
Location & getLocationRef ()
 
Location getTargetLocation () const
 
void setFacingLocation (const Location &loc)
 
Location getFacingLocation ()
 
void setRotation (int32_t rotation)
 
int32_t getRotation () const
 
Location & getFacingLocationRef ()
 
void setBlocking (bool blocking)
 
bool isBlocking () const
 
void setOverrideBlocking (bool overblock)
 
bool isOverrideBlocking () const
 
void callOnActionFrame (Action *action, int32_t frame)
 
void addActionListener (InstanceActionListener *listener)
 
void removeActionListener (InstanceActionListener *listener)
 
void addChangeListener (InstanceChangeListener *listener)
 
void removeChangeListener (InstanceChangeListener *listener)
 
void addDeleteListener (InstanceDeleteListener *listener)
 
void removeDeleteListener (InstanceDeleteListener *listener)
 
Action * getCurrentAction () const
 
double getMovementSpeed () const
 
uint32_t getActionRuntime ()
 
void setActionRuntime (uint32_t time_offset)
 
void move (const std::string &action_name, const Location &target, const double speed)
 
void act (const std::string &action_name, const Location &direction, bool repeating=false)
 
void say (const std::string &text, uint32_t duration=0)
 
void follow (const std::string &action_name, Instance *leader, const double speed)
 
const std::string * getSayText () const
 
InstanceChangeInfo update ()
 
bool isActive () const
 
void setVisual (IVisual *visual)
 
template<typename T >
T * getVisual () const
 
void setTimeMultiplier (float multip)
 
float getTimeMultiplier ()
 
float getTotalTimeMultiplier ()
 
uint32_t getRuntime ()
 
void refresh ()
 
InstanceChangeInfo getChangeInfo ()
 
void onInstanceDeleted (Instance *instance)
 
- Public Member Functions inherited from FIFE::FifeClass
fifeid_t getFifeId ()
 

Detailed Description

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

Definition at line 88 of file instance.h.

Constructor & Destructor Documentation

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

Constructor Instances are created by calling addInstance from layer, thus this method should really be called only by layer or test code

Definition at line 185 of file instance.cpp.

FIFE::Instance::~Instance ( )
virtual

Destructor

Definition at line 198 of file instance.cpp.

Member Function Documentation

void FIFE::Instance::act ( const std::string &  action_name,
const Location &  direction,
bool  repeating = false 
)

Performs given named action to the instance. Performs no movement

Parameters
action_namename of the action
directioncoordinates for cell towards instance is heading to when performing the action
repeatingin case true, keeps repeating this action

Definition at line 376 of file instance.cpp.

References setFacingLocation().

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

Adds new instance action listener

Parameters
listenerto add

Definition at line 282 of file instance.cpp.

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

Adds new instance change listener

Parameters
listenerto add

Definition at line 302 of file instance.cpp.

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

Adds new instance delete listener

Parameters
listenerto add

Definition at line 636 of file instance.cpp.

Referenced by follow().

Here is the caller graph for this function:

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

void FIFE::Instance::follow ( const std::string &  action_name,
Instance leader,
const double  speed 
)

Performs given named action to the instance. While performing the action follows given instance with given speed

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

Definition at line 365 of file instance.cpp.

References addDeleteListener(), getLocationRef(), and setFacingLocation().

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

References getRuntime().

InstanceChangeInfo FIFE::Instance::getChangeInfo ( )
inline

Returns a bitmask of changes since previous update

Definition at line 410 of file instance.h.

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

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

References getFacingLocationRef().

Location & FIFE::Instance::getFacingLocationRef ( )

Returns reference to the direction where instance is heading Note: if instance didn't previously hadn't defined facing location (e.g. by movement or setFacingLocation), method creates the location thus increasing memory consumption.

Returns
reference to the direction of instance.

Definition at line 546 of file instance.cpp.

Referenced by getFacingLocation().

Here is the caller graph for this function:

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

Get the identifier for this instance; possibly null.

Definition at line 103 of file instance.h.

Location FIFE::Instance::getLocation ( ) const
inline

Gets current location of instance

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

Definition at line 122 of file instance.h.

Referenced by FIFE::Camera::attach().

Here is the caller graph for this function:

Location& FIFE::Instance::getLocationRef ( )
inline

Gets reference of current location of instance

Returns
reference to current location

Definition at line 127 of file instance.h.

Referenced by follow(), FIFE::Camera::getMatchingInstances(), and FIFE::Camera::update().

Here is the caller graph for this function:

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

Object* FIFE::Instance::getObject ( )
inline

Gets object where this instance is instantiated from

Definition at line 111 of file instance.h.

int32_t FIFE::Instance::getRotation ( ) const
inline

Get the rotation offset of this instance

Definition at line 154 of file instance.h.

uint32_t FIFE::Instance::getRuntime ( )

Gets the scaled runtime in milliseconds

Returns
runtime

Definition at line 621 of file instance.cpp.

References FIFE::TimeProvider::getGameTime(), and FIFE::Map::getTimeProvider().

Referenced by getActionRuntime(), and say().

Here is the caller graph for this function:

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

Returns pointer to currently set saytext. In case no text is set, returns NULL

Definition at line 394 of file instance.cpp.

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

float FIFE::Instance::getTimeMultiplier ( )

Gets instance speed.

See also
setTimeMultiplier.

Definition at line 601 of file instance.cpp.

float FIFE::Instance::getTotalTimeMultiplier ( )

Gets instance speed, considering also model and map speeds.

See also
setTimeMultiplier.

Definition at line 608 of file instance.cpp.

References FIFE::Map::getTimeProvider(), and FIFE::TimeProvider::getTotalMultiplier().

template<typename T >
T* FIFE::Instance::getVisual ( ) const
inline

Gets used visualization

Definition at line 291 of file instance.h.

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

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

Referenced by FIFE::Layer::addInstance(), FIFE::Layer::createInstance(), setLocation(), and setRotation().

Here is the caller graph for this function:

bool FIFE::Instance::isBlocking ( ) const

Gets if instance blocks movement

Definition at line 278 of file instance.cpp.

bool FIFE::Instance::isOverrideBlocking ( ) const
inline

Gets if instance blocking can overriden

Definition at line 178 of file instance.h.

void FIFE::Instance::move ( const std::string &  action_name,
const Location &  target,
const double  speed 
)

Performs given named action to the instance. While performing the action moves instance to given target with given speed

Parameters
action_namename of the action
targetplace where to move this instance
speedspeed used for movement. Units = distance 1 in layer coordinates per second

Definition at line 356 of file instance.cpp.

References setFacingLocation().

void FIFE::Instance::onInstanceDeleted ( Instance instance)

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

Definition at line 655 of file instance.cpp.

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

Referenced by setLocation(), and setRotation().

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

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

Removes associated instance change listener

Parameters
listenerto remove

Definition at line 321 of file instance.cpp.

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

Removes associated instance delete listener

Parameters
listenerto remove

Definition at line 640 of file instance.cpp.

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

References getRuntime().

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 The action time offset that should be applied

Definition at line 564 of file instance.cpp.

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

Sets if instance blocks movement

Definition at line 272 of file instance.cpp.

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

Referenced by act(), follow(), and move().

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

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

Sets location of the instance

Parameters
locnew location

Definition at line 231 of file instance.cpp.

References isActive(), and refresh().

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

Here is the caller graph for this function:

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

Sets if instance blocking can overriden

Definition at line 174 of file instance.h.

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

Set the rotation offset of this instance

Definition at line 256 of file instance.cpp.

References isActive(), and refresh().

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

Sets speed for the map. See Model::setTimeMultiplier.

Definition at line 593 of file instance.cpp.

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

Sets visualization to be used. Transfers ownership.

Definition at line 287 of file instance.h.

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

Here is the caller graph for this function:

InstanceChangeInfo FIFE::Instance::update ( )

Updates the instance related to the current action

Note
call this only once in engine update cycle, so that tracking between current position and previous position keeps in sync.
Returns
marked changes

Definition at line 436 of file instance.cpp.

References say().


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