Eris  1.4.0
Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | Friends | List of all members
Eris::Avatar Class Reference

The player's avatar representation. More...

#include <Avatar.h>

Inheritance diagram for Eris::Avatar:

Public Member Functions

const std::string & getId () const
 Get the Mind id of this Avatar. All interaction with the entity goes through the Mind.
 
const std::string & getEntityId () const
 
EntityPtr getEntity () const
 Get the Entity this Avatar refers to.
 
ViewgetView () const
 
ConnectiongetConnection () const
 
double getWorldTime ()
 get the current local approximation of world time. More...
 
void drop (Entity *entity, const WFMath::Point< 3 > &pos, const WFMath::Quaternion &orientation, const std::string &loc)
 Drop an entity in the Avatar's inventory at the given location. More...
 
void drop (Entity *entity, const WFMath::Vector< 3 > &offset=WFMath::Vector< 3 >(0, 0, 0), const WFMath::Quaternion &orientation=WFMath::Quaternion())
 Drop an entity in the Avatar's inventory at the Avatar's feet (or actually in the parent entity of the Avatar). More...
 
void take (Entity *)
 Move an entity into the Avatar's inventory.
 
void touch (Entity *, const WFMath::Point< 3 > &pos)
 Touch an entity.
 
void say (const std::string &)
 Say something (in-game)
 
void sayTo (const std::string &message, const std::vector< std::string > &entities)
 Say something (in-game), addressing one or many entities. More...
 
void emote (const std::string &)
 Emote something (in-game)
 
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.
 
void moveInDirection (const WFMath::Vector< 3 > &, const WFMath::Quaternion &)
 Set the character's velocity and orientation. Any non-valid data will not be sent.
 
void place (Entity *entity, Entity *container, const WFMath::Point< 3 > &pos, const WFMath::Quaternion &orientation=WFMath::Quaternion(), boost::optional< float > offset=boost::none)
 Place an entity inside another one. More...
 
void attack (Entity *entity)
 Use the currently wielded entity (tool) on another entity. 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 ()
 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...
 

Public Attributes

sigc::signal< void, Entity * > GotCharacterEntity
 Emitted when the character entity of this Avatar is valid (and presumably, visible). More...
 
sigc::signal< void, Entity * > InvAdded
 An object was added to the inventory.
 
sigc::signal< void, Entity * > InvRemoved
 An object was removed from the inventory.
 
sigc::signal< void, Entity *, const Atlas::Objects::Operation::RootOperation & > Hear
 emitted when this Avatar hears something. More...
 
sigc::signal< void, const TransferInfo & > TransferRequested
 Emitted when a character transfer authentication is requested. More...
 

Protected Member Functions

 Avatar (Account &pl, std::string mindId, std::string entityId)
 Create a new Avatar object. More...
 
void updateWorldTime (double t)
 called by the IG router for each op it sees with a valid 'seconds' attribute set. More...
 
void onEntityAppear (Entity *ent)
 
void onCharacterChildAdded (Entity *child)
 
void onCharacterChildRemoved (Entity *child)
 
void onAvatarEntityDeleted ()
 Called when the avatar entity is deleted.
 
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.
 
void logoutRequested (const TransferInfo &transferInfo)
 Called when a logout and server transfer of the avatar has been requested by the server. More...
 

Protected Attributes

Accountm_account
 
std::string m_mindId
 
std::string m_entityId
 
EntityPtr m_entity
 
WFMath::TimeStamp m_stampAtLastOp
 
double m_lastOpTime
 
IGRouterm_router
 
Viewm_view
 
sigc::connection m_entityAppearanceCon
 
bool m_isAdmin
 
TimedEventm_logoutTimer
 

Friends

class Account
 
class AccountRouter
 
class IGRouter
 

Detailed Description

The player's avatar representation.

Constructor & Destructor Documentation

◆ Avatar()

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

Member Function Documentation

◆ attack()

void Eris::Avatar::attack ( Entity entity)

Use the currently wielded entity (tool) on another entity.

Parameters
entityA pointer to the entity you wish to use your tool on.
positionA position where you perform the operation.
opThe operation of the tool to perform, or an empty string to use the default.

If position is invalid the "pos" parameter will not be set on the USE operation.

See also
WFMath::Point< 3 >::Point(), WFMath::Point< 3 >::setValid(), WFMath::Point< 3 >::isValid() Attach the specified entity
Parameters
entityThe entity to be attacked

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

◆ drop() [1/2]

void Eris::Avatar::drop ( Entity entity,
const WFMath::Point< 3 > &  pos,
const WFMath::Quaternion &  orientation,
const std::string &  loc 
)

Drop an entity in the Avatar's inventory at the given location.

Parameters
entityThe entity to drop.
posThe position within the location to place the entity at (if possible by the server).
orientationThe orientation of the new entity. This will only be used if the quaternion sent is valid.
locThe new location, as an entity id.

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

Referenced by drop().

◆ drop() [2/2]

void Eris::Avatar::drop ( Entity entity,
const WFMath::Vector< 3 > &  offset = WFMath::Vector<3>(0, 0, 0),
const WFMath::Quaternion &  orientation = WFMath::Quaternion() 
)

Drop an entity in the Avatar's inventory at the Avatar's feet (or actually in the parent entity of the Avatar).

Parameters
entityThe entity to drop.
posThe position within the location to place the entity at (if possible by the server).
orientationThe orientation of the new entity. This will only be used if the quaternion sent is valid.

References drop(), Eris::Entity::getId(), Eris::Entity::getLocation(), and Eris::Entity::getPosition().

◆ getIsAdmin()

bool Eris::Avatar::getIsAdmin ( )

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.

Referenced by place().

◆ getWorldTime()

double Eris::Avatar::getWorldTime ( )

get the current local approximation of world time.

◆ logoutRequested()

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.

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

◆ place()

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

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.

References Eris::Entity::getId(), getIsAdmin(), and 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.

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

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.

◆ 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.

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

◆ useStop()

void Eris::Avatar::useStop ( )

Stop the current task, if one is in progress.

This could be either a useOn or attack.

References Eris::Entity::getId(), Eris::Entity::getType(), GotCharacterEntity, Eris::TypeInfo::refresh(), and Eris::Connection::send().

Member Data Documentation

◆ 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.

Referenced by useStop().

◆ Hear

sigc::signal<void, Entity*, const Atlas::Objects::Operation::RootOperation&> Eris::Avatar::Hear

emitted when this Avatar hears something.

Passes the source of the sound, and the operation that was heard, for example a Talk.

Referenced by Eris::ViewEntity::onSoundAction(), and Eris::ViewEntity::onTalk().

◆ 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

Referenced by onAvatarEntityDeleted().


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