Eris  1.3.23
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);
216  void onAvatarEntityDeleted();
217 
218 
219  void onCharacterWield(const Atlas::Message::Element&);
220  void onWieldedChanged();
221 
222  virtual void onTransferRequested(const TransferInfo &transfer);
223 
224  void logoutResponse(const Atlas::Objects::Operation::RootOperation&);
225 
230  void logoutRequested();
231 
238  void logoutRequested(const TransferInfo& transferInfo);
239 
240  Account& m_account;
241 
242  std::string m_entityId;
243  EntityPtr m_entity;
244 
245  WFMath::TimeStamp m_stampAtLastOp;
246  double m_lastOpTime;
247 
248  IGRouter* m_router;
249  View* m_view;
250 
251  EntityRef m_wielded;
252 
253  sigc::connection m_entityAppearanceCon;
254 
255  bool m_isAdmin;
256 };
257 
258 inline const std::string & Avatar::getId() const
259 {
260  return m_entityId;
261 }
262 
264 {
265  return m_entity;
266 }
267 
268 inline View* Avatar::getView() const
269 {
270  return m_view;
271 }
272 
273 inline const EntityRef& Avatar::getWielded() const
274 {
275  return m_wielded;
276 }
277 } // of namespace Eris
278 
279 #endif
sigc::signal< void, Entity * > InvAdded
An object was added to the inventory.
Definition: Avatar.h:179
void useOn(Entity *entity, const WFMath::Point< 3 > &position, const std::string &op)
Use the currently wielded entity (tool) on another entity.
Definition: Avatar.cpp:296
Definition: EntityRef.h:14
void moveInDirection(const WFMath::Vector< 3 > &)
Set the character&#39;s velocity.
Definition: Avatar.cpp:196
sigc::signal< void, Entity * > GotCharacterEntity
Emitted when the character entity of this Avatar is valid (and presumably, visible).
Definition: Avatar.h:170
void setIsAdmin(bool isAdmin)
Sets whether the current avatar is an admin character.
Definition: Avatar.cpp:456
void logoutRequested()
Called when a logout of the avatar has been requested by the server.
Definition: Avatar.cpp:445
void onAvatarEntityDeleted()
Called when the avatar entity is deleted.
Definition: Avatar.cpp:363
View encapsulates the set of entities currently visible to an Avatar, as well as those that have rece...
Definition: View.h:33
void emote(const std::string &)
Emote something (in-game)
Definition: Avatar.cpp:167
Definition: IGRouter.h:13
void updateWorldTime(double t)
called by the IG router for each op it sees with a valid &#39;seconds&#39; attribute set. ...
Definition: Avatar.cpp:406
Definition: Account.cpp:35
void place(Entity *entity, Entity *container, const WFMath::Point< 3 > &pos, const WFMath::Quaternion &orientation=WFMath::Quaternion())
Place an entity inside another one.
Definition: Avatar.cpp:246
sigc::signal< void, Entity *, const Atlas::Objects::Operation::RootOperation & > Hear
emitted when this Avatar hears something.
Definition: Avatar.h:185
void drop(Entity *entity, const WFMath::Point< 3 > &pos, const WFMath::Quaternion &orientation, const std::string &loc)
Drop an entity in the Avatar&#39;s inventory at the given location.
Definition: Avatar.cpp:78
void say(const std::string &)
Say something (in-game)
Definition: Avatar.cpp:137
Definition: Account.cpp:33
Underlying Atlas connection, providing a send interface, and receive (dispatch) system.
Definition: Connection.h:37
Avatar(Account &pl, const std::string &entId)
Create a new Avatar object.
Definition: Avatar.cpp:38
void attack(Entity *entity)
Attach the specified entity.
Definition: Avatar.cpp:325
void wield(Entity *entity)
Wield an entity which is inside the Avatar&#39;s inventory.
Definition: Avatar.cpp:277
const std::string & getId() const
Get the Entity id of this Avatar.
Definition: Avatar.h:258
void touch(Entity *)
Touch an entity.
Definition: Avatar.cpp:125
Encapsulates all the state of an Atlas Account, and methods that operation on that state...
Definition: Account.h:44
Entity is a concrete (instantiable) class representing one game entity.
Definition: Entity.h:57
bool getIsAdmin()
Gets whether the current avatar is an admin character.
Definition: Avatar.cpp:461
A TransferInfo object represents the encapsulation of various data required to successfully transfer ...
Definition: TransferInfo.h:16
sigc::signal< void, Entity * > InvRemoved
An object was removed from the inventory.
Definition: Avatar.h:181
EntityPtr getEntity() const
Get the Entity this Avatar refers to.
Definition: Avatar.h:263
void useStop()
Stop the current task, if one is in progress.
Definition: Avatar.cpp:338
void moveToPoint(const WFMath::Point< 3 > &)
Have the character move towards a position.
Definition: Avatar.cpp:182
The player&#39;s avatar representation.
Definition: Avatar.h:31
void take(Entity *)
Move an entity into the Avatar&#39;s inventory.
Definition: Avatar.cpp:108
void sayTo(const std::string &message, const std::vector< const Entity *> &entities)
Say something (in-game), addressing one or many entities.
Definition: Avatar.cpp:149
double getWorldTime()
get the current local approximation of world time.
Definition: Avatar.cpp:400
sigc::signal< void, const TransferInfo & > TransferRequested
Emitted when a character transfer authentication is requested.
Definition: Avatar.h:192