public class MMOItem extends BaseMMOItem
This means that whenever one or more MMOItem falls within the AoI of a Player it will be notified to the User with a client side PROXIMITY_LIST_UPDATE. MMOItems are identified by unique ID and by all of their custom variables.
MMOItems also have Variables that behave just like User Variables, that can be used to attach any custom property to each Item.
Example of use:
// Prepare the variables List<IMMOItemVariables> vars = new LinkedList<IMMOItemVariables>(); vars.add(new MMOItemVariable("type", "1"); // identifies the type of bonus based on our game rules vars.add(new MMOitemVariable("val", 100); // the value of the bonus // Create the item MMOItem bonus = new MMOItem(vars); // Access the MMO API ISFSMMOApi mmoApi = SmartfoxServer.getInstance().getAPIManager().getMMOApi; // Set the Item in the room at specific coordinates mmoApi.setMMOItemPosition(bonus, new Vec3D(10, 20, 5), theMMORoom);
The final line of code assumes we already have an MMORoom object where the Item will be added. It might be an existing room or one that has just been created. After the Item is placed in the MMORoom a PROXIMITY_LIST_UPDATE will be sent to Users that are within range of the object.
MMOItemVariable
,
MMORoom
,
SFSMMOApi
Constructor and Description |
---|
MMOItem()
Creates a new MMOItem
|
MMOItem(java.util.List<IMMOItemVariable> variables)
Creates an MMOItem populated with custom variables
|
Modifier and Type | Method and Description |
---|---|
int |
getId()
The MMOItem ID
|
MMORoom |
getRoom() |
IMMOItemVariable |
getVariable(java.lang.String name)
Obtain a variable from the MMOItem via its name
|
java.util.List<IMMOItemVariable> |
getVariables()
Get a list of all variables attached to the MMOItem
|
void |
removeVariable(java.lang.String varName)
Used internally.
|
void |
setVariable(IMMOItemVariable var)
Used internally.
|
void |
setVariables(java.util.List<IMMOItemVariable> varList)
Used internally.
|
ISFSArray |
toSFSArray()
Used internally
|
java.lang.String |
toString() |
public MMOItem()
public MMOItem(java.util.List<IMMOItemVariable> variables)
variables
- the list of MMOVariablesIMMOItemVariable
public int getId()
public IMMOItemVariable getVariable(java.lang.String name)
name
- the variable namepublic java.util.List<IMMOItemVariable> getVariables()
public void setVariable(IMMOItemVariable var)
public void setVariables(java.util.List<IMMOItemVariable> varList)
public void removeVariable(java.lang.String varName)
public ISFSArray toSFSArray()
public MMORoom getRoom()
getRoom
in class BaseMMOItem
public java.lang.String toString()
toString
in class java.lang.Object