FIFE::Instance Class Reference

#include <instance.h>

Inheritance diagram for FIFE::Instance:
Inheritance graph
[legend]
Collaboration diagram for FIFE::Instance:
Collaboration graph
[legend]

List of all members.

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 (int rotation)
int getRotation () const
Location & getFacingLocationRef ()
void setBlocking (bool blocking)
bool isBlocking () const
void setOverrideBlocking (bool overblock)
bool isOverrideBlocking () const
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
unsigned int getActionRuntime ()
void setActionRuntime (unsigned int 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, unsigned int 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 (AbstractVisual *visual)
template<typename T >
T * getVisual () const
void setTimeMultiplier (float multip)
float getTimeMultiplier ()
float getTotalTimeMultiplier ()
unsigned int getRuntime ()
void refresh ()
InstanceChangeInfo getChangeInfo ()
void onInstanceDeleted (Instance *instance)

Detailed Description

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

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

FIFE::Instance::~Instance (  )  [virtual]

Destructor

Definition at line 190 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_name name of the action
direction coordinates for cell towards instance is heading to when performing the action
repeating in case true, keeps repeating this action

Definition at line 339 of file instance.cpp.

References setFacingLocation().

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

Adds new instance action listener

Parameters:
listener to add

Definition at line 259 of file instance.cpp.

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

Adds new instance change listener

Parameters:
listener to add

Definition at line 279 of file instance.cpp.

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

Adds new instance delete listener

Parameters:
listener to add

Definition at line 590 of file instance.cpp.

Referenced by follow().

Here is the caller graph for this function:

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 isntance with given speed

Parameters:
action_name name of the action
leader followed instance
speed speed used for movement. Units = distance 1 in layer coordinates per second

Definition at line 328 of file instance.cpp.

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

unsigned int 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 510 of file instance.cpp.

References getRuntime().

InstanceChangeInfo FIFE::Instance::getChangeInfo (  )  [inline]

Returns a bitmask of changes since previous update

Definition at line 397 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 476 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 497 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 501 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 98 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 117 of file instance.h.

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

Gets reference of current location of instance

Returns:
reference to current location

Definition at line 122 of file instance.h.

Referenced by follow().

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

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

Gets object where this instance is instantiated from

Definition at line 106 of file instance.h.

int FIFE::Instance::getRotation (  )  const [inline]

Get the rotation offset of this instance

Definition at line 149 of file instance.h.

unsigned int FIFE::Instance::getRuntime (  ) 

Gets the scaled runtime in milliseconds

Returns:
runtime

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

float FIFE::Instance::getTimeMultiplier (  ) 

Gets instance speed.

See also:
setTimeMultiplier.

Definition at line 556 of file instance.cpp.

float FIFE::Instance::getTotalTimeMultiplier (  ) 

Gets instance speed, considering also model and map speeds.

See also:
setTimeMultiplier.

Definition at line 563 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 280 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 219 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 255 of file instance.cpp.

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

Gets if instance blocking can overriden

Definition at line 173 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_name name of the action
target place where to move this instance
speed speed used for movement. Units = distance 1 in layer coordinates per second

Definition at line 319 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 604 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 543 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:
listener to remove

Definition at line 264 of file instance.cpp.

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

Removes associated instance change listener

Parameters:
listener to remove

Definition at line 284 of file instance.cpp.

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

Removes associated instance delete listener

Parameters:
listener to remove

Definition at line 593 of file instance.cpp.

void FIFE::Instance::say ( const std::string &  text,
unsigned int  duration = 0 
)

Causes instance to "say" given text (shown on screen next to the instance)

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

Definition at line 346 of file instance.cpp.

References getRuntime().

Referenced by update().

Here is the caller graph for this function:

void FIFE::Instance::setActionRuntime ( unsigned int  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 519 of file instance.cpp.

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

Sets if instance blocks movement

Definition at line 249 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 364 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 245 of file instance.cpp.

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

Sets location of the instance

Parameters:
loc new location

Definition at line 223 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 169 of file instance.h.

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

Set the rotation offset of this instance

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

void FIFE::Instance::setVisual ( AbstractVisual *  visual  )  [inline]

Sets visualization to be used. Transfers ownership.

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

References say().


The documentation for this class was generated from the following files:
Generated on Wed Nov 23 13:04:59 2011 for FIFE by  doxygen 1.6.3