Eris  1.3.19
Avatar.h
1 #ifndef ERIS_AVATAR_H
2 #define ERIS_AVATAR_H
3 
4 #include <Eris/Types.h>
5 #include <Eris/EntityRef.h>
6 
7 #include <Atlas/Objects/ObjectsFwd.h>
8 
9 #include <wfmath/point.h>
10 #include <wfmath/vector.h>
11 #include <wfmath/quaternion.h>
12 #include <wfmath/timestamp.h>
13 
14 #include <sigc++/trackable.h>
15 #include <sigc++/signal.h>
16 #include <sigc++/connection.h>
17 
18 #include <vector>
19 
20 namespace Eris
21 {
22 
23 // Forward Declerations
24 class Account;
25 class IGRouter;
26 class View;
27 class Connection;
28 class TransferInfo;
29 
31 class Avatar : virtual public sigc::trackable
32 {
33 public:
34  virtual ~Avatar();
35 
37  const std::string & getId() const;
38 
40  EntityPtr getEntity() const;
41 
42  View* getView() const;
43 
44  Connection* getConnection() const;
45 
47  double getWorldTime();
48 
49  const EntityRef& getWielded() const;
50 
58  void drop(Entity* entity, const WFMath::Point<3>& pos,
59  const WFMath::Quaternion& orientation, const std::string& loc);
60 
67  void drop(Entity* entity, const WFMath::Vector<3>& offset = WFMath::Vector<3>(0, 0, 0),
68  const WFMath::Quaternion& orientation = WFMath::Quaternion());
69 
71  void take(Entity*);
72 
74  void touch(Entity*);
75 
77  void say(const std::string&);
78 
82  void sayTo(const std::string& message, const std::vector<const Entity*>& entities);
83 
85  void emote(const std::string&);
86 
88  void moveToPoint(const WFMath::Point<3>&);
89 
91  void moveInDirection(const WFMath::Vector<3>&);
92 
94  void moveInDirection(const WFMath::Vector<3>&, const WFMath::Quaternion&);
95 
108  void place(Entity* entity, Entity* container, const WFMath::Point<3>& pos,
109  const WFMath::Quaternion& orientation = WFMath::Quaternion());
110 
112  void wield(Entity * entity);
113 
124  void useOn(Entity * entity, const WFMath::Point< 3 > & position, const std::string& op);
125 
130  void attack(Entity* entity);
131 
136  void useStop();
137 
138  void deactivate();
139 
150  void setIsAdmin(bool isAdmin);
151 
162  bool getIsAdmin();
163 
170  sigc::signal<void, Entity*> GotCharacterEntity;
171 
172  // These two signals just transmit the Entity's
173  // AddedMember and RemovedMember signals, but
174  // you're allowed to connect to them as soon as
175  // the Avatar has been created, instead of having to wait
176  // for the Entity to be created.
177 
179  sigc::signal<void,Entity*> InvAdded;
181  sigc::signal<void,Entity*> InvRemoved;
182 
185  sigc::signal<void, Entity*, const Atlas::Objects::Operation::RootOperation&> Hear;
186 
192  sigc::signal<void, const TransferInfo &> TransferRequested;
193 
194 protected:
195  friend class Account;
196 
200  Avatar(Account& pl, const std::string& entId);
201 
202  friend class AccountRouter;
203  friend class IGRouter;
204 
207  void updateWorldTime(double t);
208 
209 protected:
210  void onEntityAppear(Entity* ent);
211  void onCharacterChildAdded(Entity* child);
212  void onCharacterChildRemoved(Entity* child);
213 
214  void onCharacterWield(const Atlas::Message::Element&);
215  void onWieldedChanged();
216 
217  virtual void onTransferRequested(const TransferInfo &transfer);
218 
219  void logoutResponse(const Atlas::Objects::Operation::RootOperation&);
220 
225  void logoutRequested();
226 
233  void logoutRequested(const TransferInfo& transferInfo);
234 
235  Account& m_account;
236 
237  std::string m_entityId;
238  EntityPtr m_entity;
239 
240  WFMath::TimeStamp m_stampAtLastOp;
241  double m_lastOpTime;
242 
243  IGRouter* m_router;
244  View* m_view;
245 
246  EntityRef m_wielded;
247 
248  sigc::connection m_entityAppearanceCon;
249 
250  bool m_isAdmin;
251 };
252 
253 inline const std::string & Avatar::getId() const
254 {
255  return m_entityId;
256 }
257 
259 {
260  return m_entity;
261 }
262 
263 inline View* Avatar::getView() const
264 {
265  return m_view;
266 }
267 
268 inline const EntityRef& Avatar::getWielded() const
269 {
270  return m_wielded;
271 }
272 } // of namespace Eris
273 
274 #endif