FIFE
2008.0
|
#include <instance.h>
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="") |
Object * | getObject () |
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) |
![]() | |
fifeid_t | getFifeId () |
An Instance is an "instantiation" of an Object at a Location.
Definition at line 88 of file instance.h.
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.
|
virtual |
Destructor
Definition at line 198 of file instance.cpp.
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
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 376 of file instance.cpp.
References setFacingLocation().
void FIFE::Instance::addActionListener | ( | InstanceActionListener * | listener) |
Adds new instance action listener
listener | to add |
Definition at line 282 of file instance.cpp.
void FIFE::Instance::addChangeListener | ( | InstanceChangeListener * | listener) |
Adds new instance change listener
listener | to add |
Definition at line 302 of file instance.cpp.
void FIFE::Instance::addDeleteListener | ( | InstanceDeleteListener * | listener) |
Adds new instance delete listener
listener | to add |
Definition at line 636 of file instance.cpp.
Referenced by follow().
void FIFE::Instance::callOnActionFrame | ( | Action * | action, |
int32_t | frame | ||
) |
Auxiliary function to inform ActionListeners about the active ActionFrame.
action | pointer to the action |
frame | frame 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
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 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
Definition at line 555 of file instance.cpp.
References getRuntime().
|
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!
Definition at line 521 of file instance.cpp.
Location FIFE::Instance::getFacingLocation | ( | ) |
Returns the direction where instance is heading
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.
Definition at line 546 of file instance.cpp.
Referenced by getFacingLocation().
|
inline |
Get the identifier for this instance; possibly null.
Definition at line 103 of file instance.h.
|
inline |
Gets current location of instance
Definition at line 122 of file instance.h.
Referenced by FIFE::Camera::attach().
|
inline |
Gets reference of current location of instance
Definition at line 127 of file instance.h.
Referenced by follow(), FIFE::Camera::getMatchingInstances(), and FIFE::Camera::update().
double FIFE::Instance::getMovementSpeed | ( | ) | const |
Gets the speed in case instance is moving otherwise returns 0
Definition at line 535 of file instance.cpp.
|
inline |
Gets object where this instance is instantiated from
Definition at line 111 of file instance.h.
|
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
Definition at line 621 of file instance.cpp.
References FIFE::TimeProvider::getGameTime(), and FIFE::Map::getTimeProvider().
Referenced by getActionRuntime(), and say().
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
Definition at line 528 of file instance.cpp.
float FIFE::Instance::getTimeMultiplier | ( | ) |
float FIFE::Instance::getTotalTimeMultiplier | ( | ) |
Gets instance speed, considering also model and map speeds.
Definition at line 608 of file instance.cpp.
References FIFE::Map::getTimeProvider(), and FIFE::TimeProvider::getTotalMultiplier().
|
inline |
Gets used visualization
Definition at line 291 of file instance.h.
Referenced by FIFE::InstanceVisual::create().
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().
bool FIFE::Instance::isBlocking | ( | ) | const |
Gets if instance blocks movement
Definition at line 278 of file instance.cpp.
|
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
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 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().
void FIFE::Instance::removeActionListener | ( | InstanceActionListener * | listener) |
Removes associated instance action listener
listener | to remove |
Definition at line 287 of file instance.cpp.
void FIFE::Instance::removeChangeListener | ( | InstanceChangeListener * | listener) |
Removes associated instance change listener
listener | to remove |
Definition at line 321 of file instance.cpp.
void FIFE::Instance::removeDeleteListener | ( | InstanceDeleteListener * | listener) |
Removes associated instance delete listener
listener | to 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)
text | text to say. If "" given, clear the text |
duration | duration to show the text (in ms). If 0, shows forever |
Definition at line 383 of file instance.cpp.
References getRuntime().
Referenced by update().
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().
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
loc | new location |
Definition at line 231 of file instance.cpp.
References isActive(), and refresh().
Referenced by FIFE::Layer::addInstance().
|
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.
|
inline |
Sets visualization to be used. Transfers ownership.
Definition at line 287 of file instance.h.
Referenced by FIFE::InstanceVisual::create().
InstanceChangeInfo FIFE::Instance::update | ( | ) |
Updates the instance related to the current action
Definition at line 436 of file instance.cpp.
References say().