Package net.sf.arianne.marboard.server.entity

Source Code of net.sf.arianne.marboard.server.entity.Entity

package net.sf.arianne.marboard.server.entity;

import java.util.List;

import marauroa.common.game.RPClass;
import marauroa.common.game.RPObject;
import net.sf.arianne.marboard.server.core.engine.MarboardWorld;
import net.sf.arianne.marboard.server.core.engine.MarboardZone;

/**
* The base class for all objects that are stored to database or transferred to the client.
*
* @author hendrik
*/
public abstract class Entity extends RPObject {

  /**
   * creates an Entity
   *
   * @param object RPObject
   */
  public Entity(RPObject object) {
    super(object);
  }
 
  /**
   * creates an Entity
   */
  public Entity() {
    // empty
  }

  /**
   * gets the current zone of this Entity
   *
   * @return MarboardZone
   */
  public MarboardZone getZone() {
    if (!has("id")) {
      return null;
    }
    return MarboardWorld.get().getMarboardZone(getID());
  }

  /**
   * This method set the value of an attribute
   *
   * @param attribute
   *        the attribute to be set.
   * @param value
   *        the value we want to set.
   */
  @Override
  public void put(String attribute, double value) {
    super.put(attribute, value);
    if (getZone() != null) {
      MarboardWorld.get().modify(this);
    }
  }

  /**
   * This method set the value of an attribute
   *
   * @param attribute
   *        the attribute to be set.
   * @param value
   *        the value we want to set.
   */
  @Override
  public void put(String attribute, int value) {
    super.put(attribute, value);
    if (getZone() != null) {
      MarboardWorld.get().modify(this);
    }
  }

  /**
   * This method set the value of an attribute
   *
   * @param attribute
   *        the attribute to be set.
   * @param value
   *        the value we want to set.
   */
  @Override
  public void put(String attribute, List<String> value) {
    super.put(attribute, value);
    if (getZone() != null) {
      MarboardWorld.get().modify(this);
    }
  }

  /**
   * This method set the value of an attribute
   *
   * @param attribute
   *        the attribute to be set.
   * @param value
   *        the value we want to set.
   */
  @Override
  public void put(String attribute, String value) {
    super.put(attribute, value);
    if (getZone() != null) {
      MarboardWorld.get().modify(this);
    }
  }

  /**
   * This methods remove the attribute from the container
   *
   * @param attribute
   *        the attribute we want to remove
   * @return the value of the attribute
   */
  @Override
  public String remove(String attribute) {
    String old = super.remove(attribute);
    if (getZone() != null) {
      MarboardWorld.get().modify(this);
    }
    return old;
  }

  /**
   * generates the class definition for marauroa.
   */
  public static void generateRPClass() {
    /*final RPClass entity =*/ new RPClass("entity");
  }

}
TOP

Related Classes of net.sf.arianne.marboard.server.entity.Entity

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.