public class MMORoom extends SFSRoom
By default the MMORoom does not fire any USER_ENTER or USER_EXIT events when other users enter or leave the Room, instead the client user list is updated via the PROXIMITY_LIST_UPDATE event which provides a delta of the current user list, within the AOI.
In other words the proximity list substitutes the regular user list on the client side, optimizing the number of updates that the User will receive. On the server side, however, the full Room's user list will always be accessible.
When a User joins an MMORoom his position in the world is still undefined and therefore he will be in a state of limbo until the first SetUserPosition request will be received. In order to avoid Users spending too much time in this invisible state each MMORoom can be configured to allow a timeout value after which the User will be removed from the Room.
As mentioned in the overview there are no USER_ENTER/EXIT events fired to other Users, as in regular Rooms. The way in which players are updated about other User changes in their proximity is via the client PROXIMITY_LIST_UPDATE. All other Room events will work similarly, including the USER_COUNT_CHANGE which keeps Users in the same Room group updated about the total number of clients in each Room.
CreateMMORoomSettings
,
Vec3D
,
MMOItem
,
SFSMMOApi
Modifier and Type | Class and Description |
---|---|
static class |
MMORoom.PreviousMMORoomState |
Constructor and Description |
---|
MMORoom(java.lang.String name,
Vec3D aoi,
int updateMillis)
Private constructor
|
Modifier and Type | Method and Description |
---|---|
void |
addUser(User user,
boolean asSpectator)
private
|
boolean |
containsMMOItem(BaseMMOItem item)
Check if the provided MMOItem is managed by this Room
|
boolean |
containsMMOItem(int id)
Check if the provided MMOItem id is managed by this Room
|
void |
destroy()
private
|
com.smartfoxserver.v2.mmo.P3D |
findItemLocation(BaseMMOItem item)
private
|
com.smartfoxserver.v2.mmo.P3D |
findUserLocation(User user)
private
|
java.util.List<BaseMMOItem> |
getAllMMOItems()
Obtain a list of all MMOItems managed by this Room
|
Vec3D |
getDefaultAOI()
Obtain the default Area Of Interest (AOI) of this room.
|
com.smartfoxserver.v2.mmo.IMMOItemManager |
getItemsManager()
private
|
Vec3D |
getMapHigherLimit()
Get the map higher limit
|
Vec3D |
getMapLowerLimit()
Get the map lower limit
|
BaseMMOItem |
getMMOItemById(int itemId)
Obtain an MMOItem managed by this Room via its id
|
java.util.List<User> |
getPlayersList()
For Game Rooms: get all Players in the Room (same as all User without the Spectators)
|
java.util.List<BaseMMOItem> |
getProximityItems(User target)
Get the list of MMOItems falling within the User's AoI
|
java.util.List<BaseMMOItem> |
getProximityItems(User target,
Vec3D aoi)
Get the list of MMOItems falling within a custom AoI
|
java.util.List<BaseMMOItem> |
getProximityItems(Vec3D pos)
Get the list of MMOItems falling within the MMORoom's AoI at a specific location
|
java.util.List<BaseMMOItem> |
getProximityItems(Vec3D pos,
Vec3D aoi)
Get the list of MMOItems at a specific location, falling within a custom AoI
|
java.util.List<User> |
getProximityList(User target)
Returns the List of Users falling within the target's AOI
|
java.util.List<User> |
getProximityList(User target,
Vec3D aoi)
Returns the List of Users falling within the a custom AOI around the target
|
java.util.List<User> |
getProximityList(Vec3D position)
Returns the List of Users falling within the AOI of the target position
|
java.util.List<User> |
getProximityList(Vec3D position,
Vec3D aoi)
Returns the List of Users falling within the custom AOI around the target position
|
int |
getProximityListUpdateMillis()
private
|
com.smartfoxserver.v2.mmo.IProximityManager |
getProximityManager()
private
|
Vec3D |
getSectorSize()
private
|
java.util.List<User> |
getSpectatorsList()
For Game Rooms: get all Spectators in the Room (same as all User without the Players)
|
User |
getUserByPlayerId(int playerId)
Get the User currently having the specified playerId (Game Room only)
|
int |
getUserLimboMaxSeconds()
private
|
boolean |
isGame()
Checks if this is a Game Room
|
boolean |
isSendAOIEntryPoint()
private
|
void |
removeMMOItem(BaseMMOItem item)
private
|
void |
removeUser(User user)
private
|
void |
setGame(boolean game) |
void |
setGame(boolean game,
java.lang.Class<? extends IPlayerIdGenerator> customPlayerIdGeneratorClass) |
void |
setMapLimits(Vec3D lowLimit,
Vec3D highLimit)
Private setter.
|
void |
setSendAOIEntryPoint(boolean sendAOIEntryPoint)
Private setter.
|
void |
setUserLimboMaxSeconds(int userLimboMaxSeconds)
Private setter.
|
ISFSArray |
toSFSArray(boolean globalRoomVarsOnly) |
java.lang.String |
toString() |
void |
updateItem(BaseMMOItem item,
Vec3D pos) |
void |
updateUser(User user)
private
|
addUser, containsProperty, containsUser, containsUser, containsVariable, equals, getAdminHelper, getAutoRemoveMode, getCapacity, getDump, getExtension, getGroupId, getId, getLifeTime, getMaxRoomVariablesAllowed, getMaxSpectators, getMaxUsers, getName, getOwner, getPassword, getPlayerIdGeneratorClassName, getProperties, getProperty, getRoomVariablesData, getSessionList, getSize, getUserById, getUserByName, getUserBySession, getUserList, getUserListData, getUserManager, getVariable, getVariables, getVariablesCount, getVariablesCreatedByUser, getZone, isActive, isAllowOwnerInvitations, isDynamic, isEmpty, isFlagSet, isFull, isHidden, isPasswordProtected, isPublic, isUseWordsFilter, removeProperty, removeVariable, removeVariablesCreatedByUser, removeVariablesCreatedByUser, setActive, setAdminHelper, setAllowOwnerInvitations, setAutoRemoveMode, setCapacity, setDynamic, setExtension, setFlag, setFlags, setGroupId, setHidden, setMaxRoomVariablesAllowed, setMaxSpectators, setMaxUsers, setName, setOwner, setPassword, setProperties, setProperty, setUserManager, setUseWordsFilter, setVariable, setVariable, setVariables, setVariables, setZone, switchPlayerToSpectator, switchSpectatorToPlayer
public MMORoom(java.lang.String name, Vec3D aoi, int updateMillis)
public void addUser(User user, boolean asSpectator) throws SFSJoinRoomException
addUser
in interface Room
addUser
in class SFSRoom
SFSJoinRoomException
public void removeUser(User user)
removeUser
in interface Room
removeUser
in class SFSRoom
public void removeMMOItem(BaseMMOItem item)
public Vec3D getDefaultAOI()
public java.util.List<User> getProximityList(User target)
target
- the target userpublic java.util.List<User> getProximityList(User target, Vec3D aoi)
target
- the target useraoi
- a custom AOI which must less than or equal the default Room's AOIpublic java.util.List<User> getProximityList(Vec3D position)
position
- a 2D/3D position in the virtual worldpublic java.util.List<User> getProximityList(Vec3D position, Vec3D aoi)
position
- a 2D/3D position in the virtual worldaoi
- a custom AOI which must less than or equal the default Room's AOIpublic BaseMMOItem getMMOItemById(int itemId)
itemId
- the id of the MMOItempublic java.util.List<BaseMMOItem> getAllMMOItems()
public boolean containsMMOItem(int id)
id
- the MMOItem idpublic boolean containsMMOItem(BaseMMOItem item)
item
- the MMOItempublic java.util.List<BaseMMOItem> getProximityItems(User target)
target
- A user joined in the same Roompublic java.util.List<BaseMMOItem> getProximityItems(User target, Vec3D aoi)
target
- A user joined in the same Roomaoi
- A custom AoI, must be less than or equal than the default MMORoom AoIpublic java.util.List<BaseMMOItem> getProximityItems(Vec3D pos)
pos
- The location in the MMORoom's "map"public java.util.List<BaseMMOItem> getProximityItems(Vec3D pos, Vec3D aoi)
pos
- The location in the MMORoom's "map"aoi
- A custom AoI, must be less than or equal than the default MMORoom AoIpublic Vec3D getSectorSize()
public com.smartfoxserver.v2.mmo.IProximityManager getProximityManager()
public com.smartfoxserver.v2.mmo.IMMOItemManager getItemsManager()
public com.smartfoxserver.v2.mmo.P3D findUserLocation(User user)
public com.smartfoxserver.v2.mmo.P3D findItemLocation(BaseMMOItem item)
public void updateUser(User user)
public void updateItem(BaseMMOItem item, Vec3D pos)
public Vec3D getMapLowerLimit()
public Vec3D getMapHigherLimit()
public int getUserLimboMaxSeconds()
public void setUserLimboMaxSeconds(int userLimboMaxSeconds)
public void destroy()
public boolean isSendAOIEntryPoint()
public void setSendAOIEntryPoint(boolean sendAOIEntryPoint)
public int getProximityListUpdateMillis()
public User getUserByPlayerId(int playerId)
SFSRoom
getUserByPlayerId
in interface Room
getUserByPlayerId
in class SFSRoom
playerId
- the player idpublic boolean isGame()
SFSRoom
public java.util.List<User> getPlayersList()
SFSRoom
getPlayersList
in interface Room
getPlayersList
in class SFSRoom
public java.util.List<User> getSpectatorsList()
SFSRoom
getSpectatorsList
in interface Room
getSpectatorsList
in class SFSRoom
public void setGame(boolean game)
SFSRoom
public void setGame(boolean game, java.lang.Class<? extends IPlayerIdGenerator> customPlayerIdGeneratorClass)
SFSRoom
public ISFSArray toSFSArray(boolean globalRoomVarsOnly)
toSFSArray
in interface Room
toSFSArray
in class SFSRoom