Class MMOItemVariable

java.lang.Object
com.smartfoxserver.entities.variables.BaseVariable
com.smartfoxserver.entities.variables.SFSUserVariable
com.smartfoxserver.mmo.MMOItemVariable
All Implemented Interfaces:
UserVariable, Variable, IMMOItemVariable, Serializable, Cloneable

public class MMOItemVariable extends SFSUserVariable implements IMMOItemVariable
MMOItem Variables allow to attach custom properties to MMOItems inside an MMORoom. MMOItems can represent bonuses, triggers, bullets or any other non-player entity inside an MMORoom that will be handled with the same Area Of Interest rules.

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: