Class MMORoom
- java.lang.Object
-
- sfs2x.client.entities.SFSRoom
-
- sfs2x.client.entities.MMORoom
-
- All Implemented Interfaces:
Room
public class MMORoom extends SFSRoom
The MMORoom object represents a specialized type of Room entity on the client.The MMORoom is ideal for huge virtual worlds and MMO games because it works with proximity lists instead of "regular" users lists. This allows thousands of users to interact with each other based on their Area of Interest (AoI). The AoI represents a range around the user that is affected by server and user events, outside which no other events are received.
The size of the AoI is set at Room creation time and it is the same for all users who joined it. Supposing that the MMORoom hosts a 3D virtual world, setting an AoI of (x=100, y=100, z=40) for the Room tells the server to transmit updates and broadcast events to and from those users that fall within the AoI range around the current user; this means the area within +/- 100 units on the X axis, +/- 100 units on the Y axis and +/- 40 units on the Z axis.
As the user moves around in the virtual environment, he can update his position in the corresponding MMORoom and thus continuously receive events about other users (and items - see below) entering and leaving his AoI. The player will be able to update his position via the SetUserPositionRequest request and receive updates on his current proximity list by means of the SFSEvent.PROXIMITY_LIST_UPDATE event.
Finally, MMORooms can also host any number of "MMOItems" which represent dynamic non-player objects that users can interact with. They are handled by the MMORoom using the same rules of visibility described before.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addMMOItem(IMMOItem item)
API internal usage onlyVec3D
getDefaultAOI()
Returns the default Area of Interest (AoI) of this MMORoom.Vec3D
getHigherMapLimit()
Returns the higher coordinates limit of the virtual environment represented by the MMORoom along the X,Y,Z axes.Vec3D
getLowerMapLimit()
Returns the lower coordinates limit of the virtual environment represented by the MMORoom along the X,Y,Z axes.IMMOItem
getMMOItem(int id)
Retrieves an MMOItem object from its id property.java.util.List<IMMOItem>
getMMOItems()
Retrieves all MMOItem object in the MMORoom that fall within the current user's Area of Interest.void
RemoveItem(int id)
API internal usage onlyvoid
setDefaultAOI(Vec3D defaultAOI)
API internal usage onlyvoid
setHigherMapLimit(Vec3D higherMapLimit)
API internal usage onlyvoid
setLowerMapLimit(Vec3D lowerMapLimit)
API internal usage only-
Methods inherited from class sfs2x.client.entities.SFSRoom
addUser, containsUser, containsVariable, fromSFSArray, getCapacity, getGroupId, getId, getMaxSpectators, getMaxUsers, getName, getPlayerList, getProperties, getRoomManager, getSpectatorCount, getSpectatorList, getUserById, getUserByName, getUserCount, getUserList, getVariable, getVariables, isGame, isHidden, isJoined, isManaged, isPasswordProtected, merge, removeUser, setGame, setHidden, setJoined, setManaged, setMaxSpectators, setMaxUsers, setName, setPasswordProtected, setProperties, setRoomManager, setSpectatorCount, setUserCount, setVariable, setVariables, toString
-
-
-
-
Constructor Detail
-
MMORoom
public MMORoom(int id, java.lang.String name)
Creates a new MMORoom instance.NOTE: developers never instantiate a SFSRoom manually: this is done by the SmartFoxServer 2X API internally.
- Parameters:
id
- The Room id.name
- The Room name.
-
MMORoom
public MMORoom(int id, java.lang.String name, java.lang.String groupId)
Creates a new MMORoom instance.NOTE: developers never instantiate a SFSRoom manually: this is done by the SmartFoxServer 2X API internally.
- Parameters:
id
- The Room id.name
- The Room name.groupId
- The id of the Group to which the Room belongs.
-
-
Method Detail
-
getDefaultAOI
public Vec3D getDefaultAOI()
Returns the default Area of Interest (AoI) of this MMORoom.- Returns:
- the default Area of Interest (AoI) of this MMORoom.
- See Also:
MMORoomSettings.setDefaultAOI(Vec3D)
-
getLowerMapLimit
public Vec3D getLowerMapLimit()
Returns the lower coordinates limit of the virtual environment represented by the MMORoom along the X,Y,Z axes. If null is returned, no limits were set at Room creation time.- Returns:
- the lower map coordinates limit
- See Also:
MMORoomSettings.setMapLimits(sfs2x.client.requests.mmo.MapLimits)
-
getHigherMapLimit
public Vec3D getHigherMapLimit()
Returns the higher coordinates limit of the virtual environment represented by the MMORoom along the X,Y,Z axes. If null is returned, no limits were set at Room creation time.- Returns:
- the higher map coordinates limit
- See Also:
MMORoomSettings.setMapLimits(sfs2x.client.requests.mmo.MapLimits)
-
setDefaultAOI
public void setDefaultAOI(Vec3D defaultAOI)
API internal usage only
-
setLowerMapLimit
public void setLowerMapLimit(Vec3D lowerMapLimit)
API internal usage only
-
setHigherMapLimit
public void setHigherMapLimit(Vec3D higherMapLimit)
API internal usage only
-
getMMOItem
public IMMOItem getMMOItem(int id)
Retrieves an MMOItem object from its id property. The item is available to the current user if it falls within his Area of Interest only.- Parameters:
id
- The id of the item to be retrieved.- Returns:
- An MMOItem object, or null if the item with the passed id is not in proximity of the current user.
- See Also:
MMOItem
-
getMMOItems
public java.util.List<IMMOItem> getMMOItems()
Retrieves all MMOItem object in the MMORoom that fall within the current user's Area of Interest.- Returns:
- A list of MMOItem objects, or an empty list if no item is in proximity of the current user.
- See Also:
MMOItem
-
addMMOItem
public void addMMOItem(IMMOItem item)
API internal usage only
-
RemoveItem
public void RemoveItem(int id)
API internal usage only
-
-