Public Member Functions

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 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 ()
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 172 of file instance.cpp.

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

Destructor

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

References setFacingLocation().

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

Adds new instance action listener

Parameters:
listener to add

Definition at line 224 of file instance.cpp.

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

Adds new instance change listener

Parameters:
listener to add

Definition at line 244 of file instance.cpp.

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

Adds new instance delete listener

Parameters:
listener to add

Definition at line 555 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 293 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 475 of file instance.cpp.

References getRuntime().

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

Returns a bitmask of changes since previous update

Definition at line 371 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 441 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 462 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 466 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 455 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.

Referenced by FIFE::InstanceVisualCacheItem::getStaticImageIndexByAngle().

Here is the caller graph for this function:

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 541 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 322 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 448 of file instance.cpp.

float FIFE::Instance::getTimeMultiplier (  ) 

Gets instance speed.

See also:
setTimeMultiplier.

Definition at line 521 of file instance.cpp.

float FIFE::Instance::getTotalTimeMultiplier (  ) 

Gets instance speed, considering also model and map speeds.

See also:
setTimeMultiplier.

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

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

Here is the caller graph for this function:

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 284 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 569 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 508 of file instance.cpp.

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

Removes associated instance action listener

Parameters:
listener to remove

Definition at line 229 of file instance.cpp.

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

Removes associated instance change listener

Parameters:
listener to remove

Definition at line 249 of file instance.cpp.

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

Removes associated instance delete listener

Parameters:
listener to remove

Definition at line 558 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 311 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 484 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 329 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 220 of file instance.cpp.

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

Sets location of the instance

Parameters:
loc new location

Definition at line 209 of file instance.cpp.

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

Set the rotation offset of this instance

Definition at line 215 of file instance.cpp.

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

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

Definition at line 513 of file instance.cpp.

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

Sets visualization to be used. Transfers ownership.

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

References say().


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