Пример #1
0
  public final void spawnMe(int x, int y, int z) {
    assert getPosition().getWorldRegion() == null;

    synchronized (this) {
      // Set the x,y,z position of the L2Object spawn and update its _worldregion
      _isVisible = true;

      if (x > L2World.MAP_MAX_X) x = L2World.MAP_MAX_X - 5000;
      if (x < L2World.MAP_MIN_X) x = L2World.MAP_MIN_X + 5000;
      if (y > L2World.MAP_MAX_Y) y = L2World.MAP_MAX_Y - 5000;
      if (y < L2World.MAP_MIN_Y) y = L2World.MAP_MIN_Y + 5000;

      getPosition().setWorldPosition(x, y, z);
      getPosition()
          .setWorldRegion(L2World.getInstance().getRegion(getPosition().getWorldPosition()));

      // Add the L2Object spawn in the _allobjects of L2World
    }

    L2World.getInstance().storeObject(this);

    // these can synchronize on others instances, so they're out of
    // synchronized, to avoid deadlocks

    // Add the L2Object spawn to _visibleObjects and if necessary to _allplayers of its
    // L2WorldRegion
    getPosition().getWorldRegion().addVisibleObject(this);

    // Add the L2Object spawn in the world as a visible object
    L2World.getInstance().addVisibleObject(this, getPosition().getWorldRegion());

    onSpawn();
  }
Пример #2
0
  /**
   * Init the position of a L2Object spawn and add it in the world as a visible object.<br>
   * <br>
   * <B><U> Actions</U> :</B><br>
   * <br>
   * <li>Set the x,y,z position of the L2Object spawn and update its _worldregion
   * <li>Add the L2Object spawn in the _allobjects of L2World
   * <li>Add the L2Object spawn to _visibleObjects of its L2WorldRegion
   * <li>Add the L2Object spawn in the world as a <B>visible</B> object<br>
   *     <br>
   *     <B><U> Assert </U> :</B><br>
   *     <br>
   * <li>_worldRegion == null <I>(L2Object is invisible at the beginning)</I><br>
   *     <br>
   *     <B><U> Example of use </U> :</B><br>
   *     <br>
   * <li>Create Door
   * <li>Spawn : Monster, Minion, CTs, Summon...<br>
   */
  public final void spawnMe() {
    assert getPosition().getWorldRegion() == null
        && getPosition().getWorldPosition().getX() != 0
        && getPosition().getWorldPosition().getY() != 0
        && getPosition().getWorldPosition().getZ() != 0;

    synchronized (this) {
      // Set the x,y,z position of the L2Object spawn and update its _worldregion
      _isVisible = true;
      getPosition()
          .setWorldRegion(L2World.getInstance().getRegion(getPosition().getWorldPosition()));

      // Add the L2Object spawn in the _allobjects of L2World
      L2World.getInstance().storeObject(this);

      // Add the L2Object spawn to _visibleObjects and if necessary to _allplayers of its
      // L2WorldRegion
      getPosition().getWorldRegion().addVisibleObject(this);
    }

    // this can synchronize on others instances, so it's out of
    // synchronized, to avoid deadlocks
    // Add the L2Object spawn in the world as a visible object
    L2World.getInstance().addVisibleObject(this, getPosition().getWorldRegion());

    onSpawn();
  }
Пример #3
0
  /**
   * Remove a L2Object from the world.<br>
   * <br>
   * <B><U> Actions</U> :</B><br>
   * <br>
   * <li>Remove the L2Object from the world<br>
   *     <br>
   *     <FONT COLOR=#FF0000><B> <U>Caution</U> : This method DOESN'T REMOVE the object from
   *     _allObjects of L2World </B></FONT><br>
   *     <FONT COLOR=#FF0000><B> <U>Caution</U> : This method DOESN'T SEND Server->Client packets to
   *     players</B></FONT><br>
   *     <br>
   *     <B><U> Assert </U> :</B><br>
   *     <br>
   * <li>_worldRegion != null <I>(L2Object is visible at the beginning)</I><br>
   *     <br>
   *     <B><U> Example of use </U> :</B><br>
   *     <br>
   * <li>Delete NPC/PC or Unsummon<br>
   *     <br>
   */
  public void decayMe() {
    assert getPosition().getWorldRegion() != null;

    L2WorldRegion reg = getPosition().getWorldRegion();

    synchronized (this) {
      _isVisible = false;
      getPosition().setWorldRegion(null);
    }

    // this can synchronize on others instances, so it's out of
    // synchronized, to avoid deadlocks
    // Remove the L2Object from the world
    L2World.getInstance().removeVisibleObject(this, reg);
    L2World.getInstance().removeObject(this);
  }
Пример #4
0
 public void refreshID() {
   L2World.getInstance().removeObject(this);
   IdFactory.getInstance().releaseId(getObjectId());
   _objectId = IdFactory.getInstance().getNextId();
 }