Class MMOItem

All Implemented Interfaces:
IMMOItem

public class MMOItem extends BaseMMOItem
An MMOItem represents a non-player entity inside an MMORoom. MMOItems can be used as bonuses, triggers, bullets etc... or any other non-player entity that will be handled using the MMORoom's rules of visibility.

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 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);
 
 // Set the Item in the room at specific coordinates 
 getMMOApi().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.

Tutorial

To learn more see this introductory tutorial.
See Also:
  • Constructor Details

    • MMOItem

      public MMOItem()
      Creates a new MMOItem
    • MMOItem

      public MMOItem(List<IMMOItemVariable> variables)
      Creates an MMOItem populated with custom variables
      Parameters:
      variables - the list of MMOVariables
      See Also:
  • Method Details

    • getId

      public int getId()
      Description copied from interface: IMMOItem
      The MMOItem ID
      Returns:
      the unique Item ID
    • getVariable

      public IMMOItemVariable getVariable(String name)
      Description copied from interface: IMMOItem
      Obtain a variable from the MMOItem via its name
      Parameters:
      name - the variable name
      Returns:
      the variable object
    • getVariables

      public List<IMMOItemVariable> getVariables()
      Description copied from interface: IMMOItem
      Get a list of all variables attached to the MMOItem
      Returns:
      all variables attached to the MMOItem
    • setVariable

      public void setVariable(IMMOItemVariable var)
      See Also:
      Internal
    • setVariables

      public void setVariables(List<IMMOItemVariable> varList)
      Internal
    • removeVariable

      public void removeVariable(String varName)
      Internal
    • toSFSArray

      public ISFSArray toSFSArray()
      Internal
    • getRoom

      public MMORoom getRoom()
      Description copied from class: BaseMMOItem
      Get the Room associated with this MMOItem
      Specified by:
      getRoom in class BaseMMOItem
      Returns:
      the Room associated with the MMOItem
    • getLastLocation

      public Vec3D getLastLocation()
    • toString

      public String toString()
      Overrides:
      toString in class Object