22 #ifndef FIFE_INSTANCE_H
23 #define FIFE_INSTANCE_H
115 const std::string&
getId();
119 void setId(
const std::string& identifier=
"");
263 void move(
const std::string& actionName,
const Location& target,
const double speed,
const std::string& costId =
"");
269 void actOnce(
const std::string& actionName,
const Location& direction);
275 void actOnce(
const std::string& actionName, int32_t rotation);
280 void actOnce(
const std::string& actionName);
292 void actRepeat(
const std::string& actionName, int32_t rotation);
297 void actRepeat(
const std::string& actionName);
303 void say(
const std::string& text,
uint32_t duration=0);
311 void follow(
const std::string& actionName,
Instance* leader,
const double speed);
319 void follow(
const std::string& actionName,
Route* route,
const double speed);
428 void setCost(
const std::string&
id,
double cost);
511 std::map<int32_t, AnimationPtr>
getAnimationOverlay(
const std::string& actionName, int32_t angle);
bool isMultiObject()
Returns true if it is multi object otherwise false.
void callOnVisibleChange()
Instance(Object *object, const Location &location, const std::string &identifier="")
Constructor Instances are created by calling addInstance from layer, thus this method should really b...
Timeprovider is an utility providing time management functionality You can have hierarchy of time pro...
void prepareForUpdate()
called to prepare the instance for an update
void initializeAction(const std::string &actionName)
Initialize action for use.
std::string getCostId()
Returns cost id.
InstanceActivity * m_activity
void updateMultiInstances()
Updates the visual positions of all instances in case this is a multi object.
void follow(const std::string &actionName, Instance *leader, const double speed)
Performs given named action to the instance.
InstanceActivity(Instance &source)
bool m_isVisitor
is instance a visitor (FoW)
Action * m_action
action on previous round. : might become invalid, only used for address comparison ...
void createOwnObject()
Creates an own object for the instance to allow visual customization.
VisitorShapeInfo m_visitorShape
visitor shape type
void addActionListener(InstanceActionListener *listener)
Adds new instance action listener.
void cancelAction()
Cancel current action.
bool m_ownObject
indicates if m_object is customized
void initializeChanges()
called when instance has been changed. Causes instance to create InstanceActivity ...
void setId(const std::string &identifier="")
Set the identifier for this instance.
void addDeleteListener(InstanceDeleteListener *listener)
Adds new instance delete listener.
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.
void callOnActionFrame(Action *action, int32_t frame)
Auxiliary function to inform ActionListeners about the active ActionFrame.
bool isActive() const
If this returns true, the instance needs to be updated.
bool m_blocking
blocking status on previous round
bool isAnimationOverlay(const std::string &actionName)
Indicates if there exists a animation overlay for given action.
bool isBlocking() const
Gets if instance blocks movement.
bool isColorOverlay(const std::string &actionName)
Indicates if there exists a color overlay for given action or animation overlay.
bool isSpecialSpeed()
Returns true if instance or object have special speed modifier otherwise false.
void setMainMultiInstance(Instance *main)
Sets a instance to the main multi instance of this instance.
void setFacingLocation(const Location &loc)
Sets the direction where instance is heading.
Action visual contains data that is needed to visualize different actions on screen.
virtual ~InstanceActionListener()
Location getTargetLocation() const
Gets movement target in case instance is moving.
std::vector< InstanceDeleteListener * > m_deleteListeners
listeners for deletion of the instance
InstanceChangeInfo getChangeInfo()
Returns a bitmask of changes of the last update.
T * getVisual() const
Gets used visualization.
bool m_blocking
instance blocking info
Base class for all fife classes Used e.g.
void removeAnimationOverlay(const std::string &actionName, uint32_t angle, int32_t order)
Removes animation overlay with given angle (degrees) and order from action.
void setVisitorRadius(uint16_t radius)
Sets the range for a visitor.
void cancelMovement(uint32_t length=1)
Cancel movement after a given length.
Location m_location
current location
uint32_t getActionRuntime()
Gets the time in milliseconds how long action has been active In case there is no current action...
virtual void onInstanceActionCancelled(Instance *instance, Action *action)=0
virtual void onInstanceDeleted(Instance *instance)=0
void setVisual(IVisual *visual)
Sets visualization to be used.
ActionVisual * getActionVisual(const std::string &actionName, bool create)
Returns pointer to action visual, can also create it.
void setActionRuntime(uint32_t time_offset)
Sets the time in milliseconds how long an action has been active This was requested in Ticket #373...
Action * getCurrentAction() const
Gets the currently active action.
std::string m_sayText
say text on previous round
bool isSpecialCost()
Returns true if instance or object have special cost otherwise false.
Location & getLocationRef()
Gets reference of current location of instance.
void callOnTransparencyChange()
const std::string * getSayText() const
Returns pointer to currently set saytext.
void update(Instance &source)
updates cached variables, marks changes
void convertToOverlays(const std::string &actionName, bool color)
If the action have base animation and optional color overlay it gets converted to animation overlay...
void removeDeleteListener(InstanceDeleteListener *listener)
Removes associated instance delete listener.
OverlayColors * getStaticColorOverlay(int32_t angle)
Returns closest matching static color overlay for given angle.
virtual void onInstanceActionFinished(Instance *instance, Action *action)=0
void calcMovement()
Calculates movement based current location and speed.
uint16_t m_visitorRadius
visitor radius (FoW)
void addChangeListener(InstanceChangeListener *listener)
Adds new instance change listener.
double m_speed
speed on previous round
IVisual * m_visual
instance visualization
int32_t m_rotation
The rotation offset of this instance.
void setOverrideBlocking(bool overblock)
Sets if instance blocking can overriden.
const std::vector< Instance * > & getMultiInstances()
Returns a vector that contains all instances of a multi object.
Instance * m_mainMultiInstance
pointer to the main multi instance
std::vector< InstanceActionListener * > m_actionListeners
listeners for action related events
Object * getObject()
Gets object where this instance is instantiated from.
std::vector< InstanceChangeListener * > m_changeListeners
listeners for changes
uint32_t InstanceChangeInfo
float m_timeMultiplier
time multiplier on previous round
void callOnStackPositionChange()
virtual void onInstanceChanged(Instance *instance, InstanceChangeInfo info)=0
int32_t getRotation() const
Get the rotation offset of this instance Returns direction where instance is heading.
Location & getOldLocationRef()
Gets reference of old location of instance.
OverlayColors * getColorOverlay(const std::string &actionName, uint32_t angle)
Returns closest matching color overlay for given angle and action.
Location getFacingLocation()
Returns the direction where instance is heading.
void removeStaticColorOverlay(int32_t angle)
Removes a static color overlay with given angle (degrees).
virtual ~InstanceDeleteListener()
void addColorOverlay(const std::string &actionName, uint32_t angle, const OverlayColors &colors)
Adds new color overlay with given angle (degrees) to given action.
void setTimeMultiplier(float multip)
Sets speed for the map.
Location getLocation() const
Gets current location of instance.
virtual void onInstanceActionFrame(Instance *instance, Action *action, int32_t frame)=0
void removeChangeListener(InstanceChangeListener *listener)
Removes associated instance change listener.
uint8_t getCellStackPosition()
Gets the cell stack position.
Instance * getMainMultiInstance()
Returns a pointer to the main mulit instance or Null if the instance is not part of a multi instance ...
void onInstanceDeleted(Instance *instance)
callback so other instances we depend on can notify us if they go away
bool isStaticColorOverlay()
Indicates if there exists a static color overlay.
InstanceActivity gets allocated in case there is some runtime activity related to the instance...
Location m_location
location on previous round
void bindTimeProvider()
rebinds time provider based on new location
void setBlocking(bool blocking)
Sets if instance blocks movement.
double getMovementSpeed() const
Gets the speed in case instance is moving otherwise returns 0.
InstanceChangeInfo m_additional
additional change info, used for visual class (transparency, visible, stackpos)
void finalizeAction()
Finalize current action.
ActionInfo * m_actionInfo
action information, allocated when actions are bind
void setCellStackPosition(uint8_t stack)
Sets the cell stack position.
double m_cost
holds cost value
TimeProvider * m_timeProvider
time scaler for this instance
SayInfo * m_sayInfo
text to say + duration, allocated when something is said
VisitorShapeInfo getVisitorShape()
Gets the shape type for a visitor.
Instance & operator=(const Instance &)
void actOnce(const std::string &actionName, const Location &direction)
Performs given named action to the instance, once only.
InstanceChangeInfo m_changeInfo
bitmask stating current changes
bool m_specialCost
indicates special cost
std::string m_costId
holds cost id
std::vector< Instance * > m_multiInstances
vector that holds all multi instances
double getCost()
Returns cost value.
float getTotalTimeMultiplier()
Gets instance speed, considering also model and map speeds.
void addStaticColorOverlay(uint32_t angle, const OverlayColors &colors)
Adds new static color overlay with given angle (degrees).
void removeColorOverlay(const std::string &actionName, int32_t angle)
Removes a color overlay with given angle (degrees) from given action.
bool isOverrideBlocking() const
Gets if instance blocking can overriden.
float getTimeMultiplier()
Gets instance speed.
void resetCost()
Resets cost.
void actRepeat(const std::string &actionName, const Location &direction)
Performs given named action to the instance, repeated.
InstanceChangeInfo update()
Updates the instance related to the current action.
int32_t getOldRotation() const
Get the old rotation offset of this instance Returns direction where instance was heading...
virtual ~InstanceChangeListener()
const std::string & getId()
Get the identifier for this instance; possibly null.
Location m_oldLocation
location on previous cell
void setRotation(int32_t rotation)
Set the rotation offset of this instance.
void removeActionListener(InstanceActionListener *listener)
Removes associated instance action listener.
virtual ~Instance()
Destructor.
uint32_t getRuntime()
Gets the scaled runtime in milliseconds.
Route * getRoute()
Returns a pointer to the route, in case there is no, it returns NULL.
void refresh()
Refreshes instance e.g.
std::map< int32_t, AnimationPtr > getAnimationOverlay(const std::string &actionName, int32_t angle)
Gets map with animations closest to given angle.
void move(const std::string &actionName, const Location &target, const double speed, const std::string &costId="")
Performs given named action to the instance.
Object * m_object
object where instantiated from
uint16_t getVisitorRadius()
Gets the visitor range.
bool isVisitor()
If instance is a visitor it returns true otherwise false.
bool isMultiCell()
Returns true if it is multi cell otherwise false.
uint8_t m_cellStackPos
position on cell stack
int32_t m_rotation
rotation on previous round
void setLocation(const Location &loc)
Sets location of the instance.
An Instance is an "instantiation" of an Object at a Location.
bool processMovement()
Moves instance. Returns true if finished.
bool m_overrideBlocking
allow to override the blocking property
void setCost(const std::string &id, double cost)
Sets for the given cost id a cost.
double getSpeed()
Returns speed modifier.
int32_t m_oldRotation
rotation on previous round
void say(const std::string &text, uint32_t duration=0)
Causes instance to "say" given text (shown on screen next to the instance)
void setVisitor(bool visit)
Marks this instance as a visitor.
void setVisitorShape(VisitorShapeInfo info)
Sets the shape type for a visitor.