SmartFoxServer 3 C++ Client API 3.1.0-beta
Client API for SmartFoxServer 3
Loading...
Searching...
No Matches
sfs3::entities::MMORoom Class Reference

A specialized Room working with proximity lists instead of "regular" user lists. More...

#include <MMORoom.h>

Inheritance diagram for sfs3::entities::MMORoom:
[legend]

Public Member Functions

std::optional< Vec3DgetDefaultAOI () const
 The default Area of Interest (AoI) of this Room, the range around a user within which server and user events are received.
std::optional< Vec3DgetLowerMapLimit () const
 The lower coordinates limit of the virtual environment along the X, Y and Z axes.
std::optional< Vec3DgetHigherMapLimit () const
 The higher coordinates limit of the virtual environment along the X, Y and Z axes.
std::shared_ptr< MMOItemgetMMOItem (int32_t id) const
 Retrieves an MMOItem from its id.
std::vector< std::shared_ptr< MMOItem > > getMMOItems () const
 Retrieves all the MMOItems in this Room that fall within the current user's Area of Interest; an empty list when none does.
std::string toString () const override
Public Member Functions inherited from sfs3::entities::SFSRoom
int32_t getId () const override
std::string getName () const override
 Returns the unique name of this Room.
RoomType getType () const override
std::optional< std::string > getGroupId () const override
 Returns the name of the Group this Room belongs to.
int32_t getUserCount () const override
 Returns the current number of users in this Room.
int32_t getSpectatorCount () const override
int32_t getMaxUsers () const override
 Returns the maximum number of users allowed in this Room.
int32_t getMaxSpectators () const override
 Returns the maximum number of spectators allowed in this Room.
std::vector< std::shared_ptr< User > > getPlayerList () const override
std::vector< std::shared_ptr< User > > getSpectatorList () const override
bool isGame () const override
 Tells if this is a Game Room or not.
bool isHidden () const override
 Tells if this Room is hidden or not.
bool isJoined () const override
 Tells if the client joined this Room or not.
bool isPasswordProtected () const override
 Tells if this Room needs a password to be joined or not.
bool containsUser (std::shared_ptr< entities::User > user) const override
 Tells if the given user is currently inside this Room or not.
std::shared_ptr< UsergetUserById (int32_t id) const override
 Retrieves a user inside this Room from his id.
std::shared_ptr< UsergetUserByName (const std::string &name) const override
 Retrieves a user inside this Room from his name.
std::vector< std::shared_ptr< User > > getUserList () const override
core::RoomManagerroomManager () const override
std::shared_ptr< RoomVariablegetVariable (const std::string &name) const override
 Retrieves a Room Variable from its name.
std::vector< std::shared_ptr< RoomVariable > > getVariables () const override
bool containsVariable (const std::string &name) const override
 Tells if this Room has the given Room Variable set or not.
std::string toString () const override

Static Public Member Functions

static MMORoom * from (Room *room)
 Narrows a Room to an MMORoom.
static const MMORoom * from (const Room *room)
static std::shared_ptr< MMORoom > from (const std::shared_ptr< Room > &room)

Detailed Description

A specialized Room working with proximity lists instead of "regular" user lists.

The MMORoom is meant for huge virtual worlds and MMO games: thousands of users can interact based on their Area of Interest (AoI), the range around a user within which server and user events are received. The AoI is set when the Room is created and is the same for every user who joined it. As a user moves around the virtual environment he updates his position with a requests::SetUserPositionRequest, and keeps receiving event::SFSEvent::PROXIMITY_LIST_UPDATE events about the other users entering and leaving his AoI.

MMORooms can also host any number of MMOItems, non-player objects handled with the same rules of visibility.

NOTE: developers never instantiate an MMORoom manually; this is done by the API internally when the server describes the Room. A Room reaches the consumer as a Room, so reaching the MMO properties means narrowing it first — see from().

if (auto* mmoRoom = entities::MMORoom::from(room.get()))
{
    auto aoi = mmoRoom->getDefaultAOI();
}
See also
requests::MMOSettings
MMOItem
requests::SetUserPositionRequest

Member Function Documentation

◆ from() [1/3]

MMORoom * sfs3::entities::MMORoom::from ( Room * room)
static

Narrows a Room to an MMORoom.

Parameters
roomthe Room to narrow; may be nullptr
Returns
the Room as an MMORoom, or nullptr when it is not one

◆ from() [2/3]

const MMORoom * sfs3::entities::MMORoom::from ( const Room * room)
static

◆ from() [3/3]

std::shared_ptr< MMORoom > sfs3::entities::MMORoom::from ( const std::shared_ptr< Room > & room)
static

◆ getDefaultAOI()

std::optional< Vec3D > sfs3::entities::MMORoom::getDefaultAOI ( ) const
inline

The default Area of Interest (AoI) of this Room, the range around a user within which server and user events are received.

Every MMORoom the server describes carries one; the optional is empty only when the Room description could not be decoded.

◆ getLowerMapLimit()

std::optional< Vec3D > sfs3::entities::MMORoom::getLowerMapLimit ( ) const
inline

The lower coordinates limit of the virtual environment along the X, Y and Z axes.

Empty when no limits were set at Room creation time.

◆ getHigherMapLimit()

std::optional< Vec3D > sfs3::entities::MMORoom::getHigherMapLimit ( ) const
inline

The higher coordinates limit of the virtual environment along the X, Y and Z axes.

Empty when no limits were set at Room creation time.

◆ getMMOItem()

std::shared_ptr< MMOItem > sfs3::entities::MMORoom::getMMOItem ( int32_t id) const

Retrieves an MMOItem from its id.

The item is available to the current user only if it falls within his Area of Interest.

Parameters
idthe id of the item to be retrieved
Returns
the item, or nullptr if it is not in proximity of the current user

◆ toString()

std::string sfs3::entities::MMORoom::toString ( ) const
overridevirtual
Returns
the details of this Room as text, for logging and debugging

Implements sfs3::entities::Room.


The documentation for this class was generated from the following files:
  • entities/MMORoom.h
  • entities/MMORoom.cpp