Example #1
0
  /**
   * Called to deserialize entity's state.
   *
   * @param loader
   */
  public final void load(DataLoader loader) {
    if (loader == null) {
      return;
    }

    // load common entity parameters
    boolean topLeftCoordinatesMode =
        loader.getStringValue("coordinatesMode").equalsIgnoreCase("TopLeft");

    m_bb.load("localBounds", loader);
    m_pos.load("position", loader);
    if (topLeftCoordinatesMode) {
      m_pos.m_x += m_bb.getWidth() * 0.5f;
      m_pos.m_y -= m_bb.getHeight() * 0.5f;
    }

    m_facing = loader.getFloatValue("facing");

    updateWorldBounds();

    // load the aspects
    int aspectsCount = m_aspects.size();
    for (int i = 0; i < aspectsCount; ++i) {
      m_aspects.get(i).load(loader);
    }

    // load implementation specific stuff
    onLoad(loader);
  }
Example #2
0
  /**
   * Translates the entity by the specified vector.
   *
   * @param dx
   * @param dy
   * @param dz
   */
  public final void translate(float dx, float dy, float dz) {
    m_pos.m_x += dx;
    m_pos.m_y += dy;
    m_pos.m_z += dz;

    updateWorldBounds();
  }
Example #3
0
  /**
   * Sets the entity's position.
   *
   * @param rhs
   */
  public final void setPosition(Vector3 rhs) {
    m_pos.m_x = rhs.m_x;
    m_pos.m_y = rhs.m_y;
    m_pos.m_z = rhs.m_z;

    updateWorldBounds();
  }
Example #4
0
  /**
   * Sets the entity's position.
   *
   * @param x
   * @param y
   * @param z
   */
  public final void setPosition(float x, float y, float z) {
    m_pos.m_x = x;
    m_pos.m_y = y;
    m_pos.m_z = z;

    updateWorldBounds();
  }
Example #5
0
  /**
   * Called to serialize entity's state.
   *
   * @param saver
   */
  public void save(DataSaver saver) {
    if (saver == null) {
      return;
    }

    // load common entity parameters
    m_bb.save("localBounds", saver);
    m_pos.save("position", saver);
    saver.setFloatValue("facing", m_facing);

    // load the aspects
    int aspectsCount = m_aspects.size();
    for (int i = 0; i < aspectsCount; ++i) {
      m_aspects.get(i).save(saver);
    }

    // save implementation specific stuff
    onSave(saver);
  }
Example #6
0
  /**
   * Translates the entity by the specified vector.
   *
   * @param dx
   * @param dy
   * @param dz
   */
  public final void translate(Vector3 ds) {
    m_pos.add(ds);

    updateWorldBounds();
  }