22 #ifndef FIFE_INSTANCE_H
23 #define FIFE_INSTANCE_H
112 const std::string&
getId();
116 void setId(
const std::string& identifier=
"");
260 void move(
const std::string& actionName,
const Location& target,
const double speed,
const std::string& costId =
"");
267 void act(
const std::string& actionName,
const Location& direction,
bool repeating=
false);
274 void act(
const std::string& actionName, int32_t rotation,
bool repeating=
false);
280 void act(
const std::string& actionName,
bool repeating=
false);
286 void say(
const std::string& text,
uint32_t duration=0);
294 void follow(
const std::string& actionName,
Instance* leader,
const double speed);
302 void follow(
const std::string& actionName,
Route* route,
const double speed);
411 void setCost(
const std::string&
id,
double cost);
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 initializeAction(const std::string &actionName)
Initialize action for use.
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 ...
VisitorShapeInfo m_visitorShape
visitor shape type
void addActionListener(InstanceActionListener *listener)
Adds new instance action listener.
const std::string & getCostId()
Returns cost id.
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 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 isBlocking() const
Gets if instance blocks movement.
void setFacingLocation(const Location &loc)
Sets the direction where instance is heading.
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 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 onInstanceDeleted(Instance *instance)=0
void setVisual(IVisual *visual)
Sets visualization to be used.
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 removeDeleteListener(InstanceDeleteListener *listener)
Removes associated instance delete listener.
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.
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.
Location getFacingLocation()
Returns the direction where instance is heading.
virtual ~InstanceDeleteListener()
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.
void onInstanceDeleted(Instance *instance)
callback so other instances we depend on can notify us if they go away
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 act(const std::string &actionName, const Location &direction, bool repeating=false)
Performs given named action to the instance.
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 &)
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.
bool isOverrideBlocking() const
Gets if instance blocking can overriden.
float getTimeMultiplier()
Gets instance speed.
void resetCost()
Resets cost.
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.
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.
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.