eris  1.4.0
A WorldForge client library.
Eris::Avatar Class Reference

#include <Avatar.h>

Inheritance diagram for Eris::Avatar:
Collaboration diagram for Eris::Avatar:

Public Member Functions

 Avatar (Account &pl, std::string mindId, std::string entityId)
 
const std::string & getId () const
 Get the Mind id of this Avatar. All interaction with the entity goes through the Mind. More...
 
const std::string & getEntityId () const
 
EntitygetEntity () const
 Get the Entity this Avatar refers to. More...
 
ViewgetView () const
 
ConnectiongetConnection () const
 
AccountgetAccount () const
 
double getWorldTime ()
 
void touch (Entity *, const WFMath::Point< 3 > &pos)
 Touch an entity. More...
 
void wield (Eris::Entity *entity, std::string attachPoint) const
 
void say (const std::string &)
 Say something (in-game) More...
 
void sayTo (const std::string &message, const std::vector< std::string > &entities)
 
void emote (const std::string &)
 Emote something (in-game) More...
 
void moveToPoint (const WFMath::Point< 3 > &, const WFMath::Quaternion &orient)
 Have the character move towards a position. Any non-valid data will not be sent. More...
 
void moveInDirection (const WFMath::Vector< 3 > &, const WFMath::Quaternion &)
 Set the character's velocity and orientation. Any non-valid data will not be sent. More...
 
void place (const Entity *entity, const Entity *container, const WFMath::Point< 3 > &pos=WFMath::Point< 3 >(), const WFMath::Quaternion &orientation=WFMath::Quaternion(), boost::optional< float > offset=boost::none, int amount=1)
 Place an entity inside another one. More...
 
void useStop ()
 Stop the current task, if one is in progress. More...
 
void deactivate ()
 
void setIsAdmin (bool isAdmin)
 Sets whether the current avatar is an admin character. More...
 
bool getIsAdmin () const
 Gets whether the current avatar is an admin character. More...
 
void send (const Atlas::Objects::Operation::RootOperation &op)
 Sends an operation from this Avatar. More...
 
const std::map< std::string, std::unique_ptr< EntityRef > > & getActiveContainers () const
 

Public Attributes

sigc::signal< void, Entity * > GotCharacterEntity
 
sigc::signal< void > CharacterEntityDeleted
 
sigc::signal< void, Entity & > ContainerOpened
 
sigc::signal< void, Entity & > ContainerClosed
 
sigc::signal< void, const TransferInfo & > TransferRequested
 

Protected Member Functions

void updateWorldTime (double t)
 
void onEntityAppear (Entity *ent)
 
void onAvatarEntityDeleted ()
 Called when the avatar entity is deleted. More...
 
virtual void onTransferRequested (const TransferInfo &transfer)
 
void logoutResponse (const Atlas::Objects::Operation::RootOperation &)
 
void logoutRequested ()
 Called when a logout of the avatar has been requested by the server. More...
 
void logoutRequested (const TransferInfo &transferInfo)
 Called when a logout and server transfer of the avatar has been requested by the server. More...
 
void containerActiveChanged (const Atlas::Message::Element &element)
 

Protected Attributes

Accountm_account
 
std::string m_mindId
 
std::string m_entityId
 
Entitym_entity
 
WFMath::TimeStamp m_stampAtLastOp
 
double m_lastOpTime
 
std::unique_ptr< Viewm_view
 
std::unique_ptr< IGRouterm_router
 
sigc::connection m_entityAppearanceCon
 
sigc::connection m_avatarEntityDeletedConnection
 
bool m_isAdmin
 
std::unique_ptr< TimedEventm_logoutTimer
 
std::map< std::string, std::unique_ptr< EntityRef > > m_activeContainers
 
sigc::connection m_entityParentDeletedConnection
 

Friends

class Account
 
class AccountRouter
 
class IGRouter
 

Detailed Description

The player's avatar representation.

Definition at line 39 of file Avatar.h.

Constructor & Destructor Documentation

Eris::Avatar::Avatar ( Account pl,
std::string  mindId,
std::string  entityId 
)

Member Function Documentation

void Eris::Avatar::emote ( const std::string &  em)

Emote something (in-game)

Definition at line 148 of file Avatar.cpp.

References Eris::getNewSerialno(), and Eris::Connection::send().

const std::map< std::string, std::unique_ptr< EntityRef > > & Eris::Avatar::getActiveContainers ( ) const
inline

Gets the current list of opened containers. EntityRefs that aren't valid yet will issue the ContainerOpened signal when they are resolved.

Returns

Definition at line 271 of file Avatar.h.

Entity * Eris::Avatar::getEntity ( ) const
inline

Get the Entity this Avatar refers to.

Definition at line 259 of file Avatar.h.

const std::string & Eris::Avatar::getId ( ) const
inline

Get the Mind id of this Avatar. All interaction with the entity goes through the Mind.

Definition at line 250 of file Avatar.h.

Referenced by Avatar(), Eris::Account::avatarLogoutRequested(), logoutRequested(), touch(), and updateWorldTime().

bool Eris::Avatar::getIsAdmin ( ) const

Gets whether the current avatar is an admin character.

As an "admin" character the avatar has greater ability to alter the state of the server. This is often done by sending Atlas ops to the entity itself, thus bypassing the normal routing rules on the server.

It's up to the client to determine which avatars are admin, and call setIsAdmin as soon as possible after the Avatar has been created.

Definition at line 411 of file Avatar.cpp.

Referenced by place().

double Eris::Avatar::getWorldTime ( )

get the current local approximation of world time.

Definition at line 305 of file Avatar.cpp.

void Eris::Avatar::logoutRequested ( )
protected

Called when a logout of the avatar has been requested by the server.

Definition at line 398 of file Avatar.cpp.

References Eris::Account::destroyAvatar(), and getId().

void Eris::Avatar::logoutRequested ( const TransferInfo transferInfo)
protected

Called when a logout and server transfer of the avatar has been requested by the server.

Parameters
transferInfoThe transfer info which contains information about the server to transfer to.

Definition at line 402 of file Avatar.cpp.

References Eris::Account::destroyAvatar(), and getId().

void Eris::Avatar::moveInDirection ( const WFMath::Vector< 3 > &  vel,
const WFMath::Quaternion &  orient 
)

Set the character's velocity and orientation. Any non-valid data will not be sent.

Definition at line 181 of file Avatar.cpp.

References Eris::Connection::send().

void Eris::Avatar::moveToPoint ( const WFMath::Point< 3 > &  pos,
const WFMath::Quaternion &  orient 
)

Have the character move towards a position. Any non-valid data will not be sent.

Definition at line 162 of file Avatar.cpp.

References Eris::Entity::getId(), Eris::Entity::getLocation(), and Eris::Connection::send().

void Eris::Avatar::onAvatarEntityDeleted ( )
protected

Called when the avatar entity is deleted.

Definition at line 290 of file Avatar.cpp.

References CharacterEntityDeleted, Eris::Account::getConnection(), and TransferRequested.

Referenced by useStop().

void Eris::Avatar::place ( const Entity entity,
const Entity container,
const WFMath::Point< 3 > &  pos = WFMath::Point<3>(),
const WFMath::Quaternion &  orientation = WFMath::Quaternion(),
boost::optional< float >  offset = boost::none,
int  amount = 1 
)

Place an entity inside another one.

Note
Use this method both when you want to move an entity from one container to another, or just want to update the position or orientation of an entity without changing its container.
Parameters
entityThe entity to place.
containerThe container for the entity.
posThe position of the entity within the container.
orientationAn optional orientation of the entity.

Definition at line 198 of file Avatar.cpp.

References Eris::Entity::getId(), getIsAdmin(), and Eris::Connection::send().

void Eris::Avatar::say ( const std::string &  msg)

Say something (in-game)

Definition at line 120 of file Avatar.cpp.

References Eris::Connection::send().

void Eris::Avatar::sayTo ( const std::string &  message,
const std::vector< std::string > &  entities 
)

Say something (in-game), addressing one or many entities

Parameters
messageThe message, i.e. what is being said.
entitiesA list of ids of entities being addressed.

Definition at line 131 of file Avatar.cpp.

References Eris::Connection::send().

void Eris::Avatar::send ( const Atlas::Objects::Operation::RootOperation &  op)

Sends an operation from this Avatar.

This will set the "to" property to be from this avatar's mind.

Parameters
op

Definition at line 415 of file Avatar.cpp.

References Eris::Account::getConnection(), and Eris::Connection::send().

void Eris::Avatar::setIsAdmin ( bool  isAdmin)

Sets whether the current avatar is an admin character.

As an "admin" character the avatar has greater ability to alter the state of the server. This is often done by sending Atlas ops to the entity itself, thus bypassing the normal routing rules on the server.

It's up to the client to determine which avatars are admin, and set this flag as soon as possible after the Avatar has been created.

Definition at line 407 of file Avatar.cpp.

void Eris::Avatar::touch ( Entity e,
const WFMath::Point< 3 > &  pos 
)

Touch an entity.

Definition at line 90 of file Avatar.cpp.

References getId(), Eris::Entity::getId(), and Eris::Connection::send().

void Eris::Avatar::updateWorldTime ( double  t)
protected

called by the IG router for each op it sees with a valid 'seconds' attribute set. We use this to synchronize the local world time up.

Definition at line 310 of file Avatar.cpp.

References Eris::Account::destroyAvatar(), and getId().

Member Data Documentation

sigc::signal<void> Eris::Avatar::CharacterEntityDeleted

Emitted when the avatar entity for whatever reason is deleted.

Definition at line 175 of file Avatar.h.

Referenced by onAvatarEntityDeleted().

sigc::signal<void, Entity*> Eris::Avatar::GotCharacterEntity

Emitted when the character entity of this Avatar is valid (and presumably, visible). This will happen some time after the InGame signal is emitted. A client might wish to show some kind of 'busy' animation, eg an hour-glass, while waiting for this signal.

Definition at line 170 of file Avatar.h.

Referenced by useStop().

sigc::signal<void, const TransferInfo&> Eris::Avatar::TransferRequested

Emitted when a character transfer authentication is requested. Clients should use the hostname, port number, possess key and entity ID to claim the character on a remote host

Definition at line 185 of file Avatar.h.

Referenced by onAvatarEntityDeleted().


The documentation for this class was generated from the following files: