eris 1.4.0
A WorldForge client library.
Task.h
1#ifndef ERIS_TASK_H
2#define ERIS_TASK_H
3
4#include <sigc++/trackable.h>
5#include <sigc++/signal.h>
6
7#include <map>
8#include <string>
9#include <vector>
10#include "Usage.h"
11
12namespace Atlas {
13namespace Message {
14class Element;
15
16typedef std::map<std::string, Element> MapType;
17}
18}
19
20namespace WFMath { class TimeDiff; }
21
22namespace Eris {
23
24class Entity;
25
26class View;
27
28class Task : public sigc::trackable {
29public:
33 Task(Entity& owner, std::string name);
34
35 virtual ~Task();
36
41 const std::string& name() const;
42
47 double progress() const;
48
53 double progressRate() const;
54
59 bool isComplete() const;
60
61 const std::vector<TaskUsage>& getUsages() const;
62
63 sigc::signal<void> Completed;
64
65 sigc::signal<void> Progressed;
66
67 sigc::signal<void> ProgressRateChanged;
68
69 sigc::signal<void> UsagesChanged;
70
71private:
72 void progressChanged();
73
74 friend class View; // so it can call updateProgress
75 friend class Entity; // for constructor and updateFromAtlas
76
77 void updateFromAtlas(const Atlas::Message::MapType& d);
78
82 void updatePredictedProgress(const WFMath::TimeDiff& dt);
83
84 const std::string m_name;
85 Entity& m_owner;
86 double m_progress;
87
89 double m_progressRate;
90
91 std::vector<TaskUsage> m_usages;
92};
93
94inline const std::string& Task::name() const {
95 return m_name;
96}
97
98inline double Task::progress() const {
99 return m_progress;
100}
101
102inline double Task::progressRate() const {
103 return m_progressRate;
104}
105
106
107inline const std::vector<TaskUsage>& Task::getUsages() const {
108 return m_usages;
109}
110}
111
112#endif
Entity is a concrete (instantiable) class representing one game entity.
Definition: Entity.h:56
double progress() const
Return the current progress of the task. Value will always be in the range [0..1].
Definition: Task.h:98
const std::string & name() const
Gets the name of the task.
Definition: Task.h:94
Task(Entity &owner, std::string name)
Definition: Task.cpp:19
double progressRate() const
Gets the progress rate.
Definition: Task.h:102
bool isComplete() const
Returns true if the task has completed.
Definition: Task.cpp:33
Definition: Account.cpp:33