Class MMOItemVariable
- All Implemented Interfaces:
UserVariable,Variable,IMMOItemVariable,Serializable,Cloneable
This means that whenever one or more MMOItem fall 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.
MMOItem Variables behave exactly like User Variables and can be updated or removed via server side code. This allows MMOItems to be highly dynamic within the context of the MMORoom.
Example of use:
// Prepare the variables
List<IMMOItemVariables> vars = new ArrayList<>();
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.
Removing Variables: in order to remove one or more existing variables you will need to set those variables to NULL, using the BaseVariable.setNull() method;
- Since:
- 2.8.x
- See Also:
-
Field Summary
Fields inherited from class com.smartfoxserver.entities.variables.SFSUserVariable
hidden, priv, storableFields inherited from class com.smartfoxserver.entities.variables.BaseVariable
name, type, value -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedMMOItemVariable(String name) protectedMMOItemVariable(String name, VariableType type, String literal) MMOItemVariable(String name, Object value) Construct an MMOVariable with it's name and value.MMOItemVariable(String name, Object value, boolean isHidden) Construct an MMOVariable with it's name and value.protectedMMOItemVariable(String name, String type, String literal) -
Method Summary
Modifier and TypeMethodDescriptionstatic MMOItemVariablenewFromSFSArray(ISFSArray array) static MMOItemVariablenewFromStringLiteral(String name, String type, String literal) static MMOItemVariablenewInstance(String name, Object value) Methods inherited from class com.smartfoxserver.entities.variables.SFSUserVariable
clone, isHidden, isPrivate, isStorable, newPrivateVariable, setHidden, setPrivate, setStorable, toSFSArray, toStringMethods inherited from class com.smartfoxserver.entities.variables.BaseVariable
getBoolValue, getByteValue, getDoubleValue, getFloatValue, getIntValue, getLongValue, getName, getSFSArrayValue, getSFSObjectValue, getShortValue, getStringValue, getType, getValue, getVector2Value, getVector3Value, isNull, populateArrayWithValue, setNull, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValueFromStringLiteralMethods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface com.smartfoxserver.entities.variables.UserVariable
isHidden, isPrivate, isStorable, setHidden, setNull, setPrivate, setStorableMethods inherited from interface com.smartfoxserver.entities.variables.Variable
getBoolValue, getByteValue, getDoubleValue, getFloatValue, getIntValue, getLongValue, getName, getSFSArrayValue, getSFSObjectValue, getShortValue, getStringValue, getType, getValue, getVector2Value, getVector3Value, isNull, toSFSArray
-
Constructor Details
-
MMOItemVariable
Construct an MMOVariable with it's name and value.- Parameters:
name- name of the variablevalue- value of the variables (can be Bool, Int, Double, String, SFSArray, SFSObject)- See Also:
-
MMOItemVariable
Construct an MMOVariable with it's name and value. The hidden flag allows to hide the variable to clients- Parameters:
name- name of the variablevalue- value of the variables (can be Bool, Int, Double, String, SFSArray, SFSObject)isHidden- if true the variable will remain server side only- See Also:
-
MMOItemVariable
-
MMOItemVariable
-
MMOItemVariable
-
-
Method Details
-
newInstance
-
newFromStringLiteral
-
newFromSFSArray
-