예제 #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();
  }