Exemplo n.º 1
0
  /**
   * Remove a L2Object from the world.<br>
   * <br>
   * <B><U> Concept</U> :</B><br>
   * <br>
   * L2Object (including L2PcInstance) are identified in <B>_visibleObjects</B> of his current
   * L2WorldRegion and in <B>_knownObjects</B> of other surrounding L2Characters <br>
   * L2PcInstance are identified in <B>_allPlayers</B> of L2World, in <B>_allPlayers</B> of his
   * current L2WorldRegion and in <B>_knownPlayer</B> of other surrounding L2Characters <br>
   * <br>
   * <B><U> Actions</U> :</B><br>
   * <br>
   * <li>Remove the L2Object object from _allPlayers* of L2World
   * <li>Remove the L2Object object from _visibleObjects and _allPlayers* of L2WorldRegion
   * <li>Remove the L2Object object from _gmList** of GmListTable
   * <li>Remove object from _knownObjects and _knownPlayer* of all surrounding L2WorldRegion
   *     L2Characters<br>
   * <li>If object is a L2Character, remove all L2Object from its _knownObjects and all L2PcInstance
   *     from its _knownPlayer<br>
   *     <br>
   *     <FONT COLOR=#FF0000><B> <U>Caution</U> : This method DOESN'T REMOVE the object from
   *     _allObjects of L2World</B></FONT><br>
   *     <br>
   *     <I>* only if object is a L2PcInstance</I><br>
   *     <I>** only if object is a GM L2PcInstance</I><br>
   *     <br>
   *     <B><U> Example of use </U> :</B><br>
   *     <br>
   * <li>Pickup an Item
   * <li>Decay a L2Character<br>
   *     <br>
   *
   * @param object L2object to remove from the world
   * @param oldRegion L2WorldRegion in wich the object was before removing
   */
  public void removeVisibleObject(L2Object object, L2WorldRegion oldRegion) {
    if (object == null) return;

    if (oldRegion != null) {
      // Remove the object from the L2ObjectHashSet(L2Object) _visibleObjects of L2WorldRegion
      // If object is a L2PcInstance, remove it from the L2ObjectHashSet(L2PcInstance) _allPlayers
      // of this L2WorldRegion
      oldRegion.removeVisibleObject(object);

      // Go through all surrounding L2WorldRegion L2Characters
      for (L2WorldRegion reg : oldRegion.getSurroundingRegions()) {
        Collection<L2Object> vObj = reg.getVisibleObjects().values();

        for (L2Object obj : vObj) {
          if (obj != null) {
            obj.getKnownList().removeKnownObject(object);
            object.getKnownList().removeKnownObject(obj);
          }
        }
      }

      // If object is a L2Character :
      // Remove all L2Object from L2ObjectHashSet(L2Object) containing all L2Object detected by the
      // L2Character
      // Remove all L2PcInstance from L2ObjectHashSet(L2PcInstance) containing all player ingame
      // detected by the L2Character
      object.getKnownList().removeAllKnownObjects();

      // If selected L2Object is a L2PcIntance, remove it from L2ObjectHashSet(L2PcInstance)
      // _allPlayers of L2World
      if (object instanceof L2PcInstance) {
        if (!((L2PcInstance) object).isTeleporting()) removeFromAllPlayers((L2PcInstance) object);
      }
    }
  }