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

◆ Avatar()

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

Create a new Avatar object.

Parameters
plThe player that owns the Avatar

Definition at line 37 of file Avatar.cpp.

References Eris::Account::getConnection(), and Eris::TypeService::setTypeProviderId().

◆ ~Avatar()

Eris::Avatar::~Avatar ( )
virtual

Definition at line 57 of file Avatar.cpp.

Member Function Documentation

◆ containerActiveChanged()

void Eris::Avatar::containerActiveChanged ( const Atlas::Message::Element &  element)
protected

Definition at line 357 of file Avatar.cpp.

◆ deactivate()

void Eris::Avatar::deactivate ( )

Definition at line 71 of file Avatar.cpp.

◆ emote()

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

Emote something (in-game)

Definition at line 148 of file Avatar.cpp.

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

Referenced by emote().

◆ getAccount()

Account & Eris::Avatar::getAccount ( ) const
inline

Definition at line 267 of file Avatar.h.

◆ getActiveContainers()

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.

◆ getConnection()

Connection & Eris::Avatar::getConnection ( ) const

Definition at line 312 of file Avatar.cpp.

◆ getEntity()

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

Get the Entity this Avatar refers to.

Definition at line 259 of file Avatar.h.

◆ getEntityId()

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

Definition at line 254 of file Avatar.h.

◆ getId()

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 Eris::Account::avatarLogoutRequested(), and logoutRequested().

◆ getIsAdmin()

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 422 of file Avatar.cpp.

Referenced by place().

◆ getView()

View & Eris::Avatar::getView ( ) const
inline

Definition at line 263 of file Avatar.h.

◆ getWorldTime()

double Eris::Avatar::getWorldTime ( )

get the current local approximation of world time.

Definition at line 316 of file Avatar.cpp.

◆ logoutRequested() [1/2]

void Eris::Avatar::logoutRequested ( )
protected

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

Definition at line 409 of file Avatar.cpp.

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

◆ logoutRequested() [2/2]

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 413 of file Avatar.cpp.

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

◆ logoutResponse()

void Eris::Avatar::logoutResponse ( const Atlas::Objects::Operation::RootOperation &  )
protected

Definition at line 326 of file Avatar.cpp.

◆ moveInDirection()

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().

◆ moveToPoint()

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().

◆ onAvatarEntityDeleted()

void Eris::Avatar::onAvatarEntityDeleted ( )
protected

Called when the avatar entity is deleted.

Definition at line 301 of file Avatar.cpp.

References CharacterEntityDeleted.

◆ onEntityAppear()

void Eris::Avatar::onEntityAppear ( Entity ent)
protected

Definition at line 242 of file Avatar.cpp.

◆ onTransferRequested()

void Eris::Avatar::onTransferRequested ( const TransferInfo transfer)
protectedvirtual

Definition at line 308 of file Avatar.cpp.

◆ place()

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().

◆ say()

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

Say something (in-game)

Definition at line 120 of file Avatar.cpp.

References Eris::Connection::send().

◆ sayTo()

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().

◆ 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 426 of file Avatar.cpp.

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

◆ setIsAdmin()

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 418 of file Avatar.cpp.

◆ touch()

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

Touch an entity.

Definition at line 90 of file Avatar.cpp.

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

◆ updateWorldTime()

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 321 of file Avatar.cpp.

◆ useStop()

void Eris::Avatar::useStop ( )

Stop the current task, if one is in progress.

Definition at line 236 of file Avatar.cpp.

References Eris::Connection::send().

◆ wield()

void Eris::Avatar::wield ( Eris::Entity entity,
std::string  attachPoint 
) const

Definition at line 104 of file Avatar.cpp.

Friends And Related Function Documentation

◆ Account

friend class Account
friend

Definition at line 188 of file Avatar.h.

◆ AccountRouter

friend class AccountRouter
friend

Definition at line 190 of file Avatar.h.

◆ IGRouter

friend class IGRouter
friend

Definition at line 192 of file Avatar.h.

Member Data Documentation

◆ CharacterEntityDeleted

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().

◆ ContainerClosed

sigc::signal<void, Entity&> Eris::Avatar::ContainerClosed

Definition at line 178 of file Avatar.h.

◆ ContainerOpened

sigc::signal<void, Entity&> Eris::Avatar::ContainerOpened

Definition at line 177 of file Avatar.h.

◆ GotCharacterEntity

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.

◆ m_account

Account& Eris::Avatar::m_account
protected

Definition at line 226 of file Avatar.h.

◆ m_activeContainers

std::map<std::string, std::unique_ptr<EntityRef> > Eris::Avatar::m_activeContainers
protected

Definition at line 245 of file Avatar.h.

◆ m_avatarEntityDeletedConnection

sigc::connection Eris::Avatar::m_avatarEntityDeletedConnection
protected

Definition at line 239 of file Avatar.h.

◆ m_entity

Entity* Eris::Avatar::m_entity
protected

Definition at line 230 of file Avatar.h.

◆ m_entityAppearanceCon

sigc::connection Eris::Avatar::m_entityAppearanceCon
protected

Definition at line 238 of file Avatar.h.

◆ m_entityId

std::string Eris::Avatar::m_entityId
protected

Definition at line 229 of file Avatar.h.

◆ m_entityParentDeletedConnection

sigc::connection Eris::Avatar::m_entityParentDeletedConnection
protected

Definition at line 247 of file Avatar.h.

◆ m_isAdmin

bool Eris::Avatar::m_isAdmin
protected

Definition at line 241 of file Avatar.h.

◆ m_lastOpTime

double Eris::Avatar::m_lastOpTime
protected

Definition at line 233 of file Avatar.h.

◆ m_logoutTimer

std::unique_ptr<TimedEvent> Eris::Avatar::m_logoutTimer
protected

Definition at line 243 of file Avatar.h.

◆ m_mindId

std::string Eris::Avatar::m_mindId
protected

Definition at line 228 of file Avatar.h.

◆ m_router

std::unique_ptr<IGRouter> Eris::Avatar::m_router
protected

Definition at line 236 of file Avatar.h.

◆ m_stampAtLastOp

WFMath::TimeStamp Eris::Avatar::m_stampAtLastOp
protected

Definition at line 232 of file Avatar.h.

◆ m_view

std::unique_ptr<View> Eris::Avatar::m_view
protected

Definition at line 235 of file Avatar.h.

◆ TransferRequested

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.


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