Exemple #1
0
  /** @param instanceId The id of the instance zone the object is in - id 0 is global */
  public void setInstanceId(int instanceId) {
    if (_instanceId == instanceId) return;

    Instance oldI = InstanceManager.getInstance().getInstance(_instanceId);
    Instance newI = InstanceManager.getInstance().getInstance(instanceId);

    if (newI == null) return;

    if (this instanceof L2PcInstance) {
      if (_instanceId > 0 && oldI != null) {
        oldI.removePlayer(getObjectId());
        if (oldI.isShowTimer()) {
          int startTime = (int) ((System.currentTimeMillis() - oldI.getInstanceStartTime()) / 1000);
          int endTime = (int) ((oldI.getInstanceEndTime() - oldI.getInstanceStartTime()) / 1000);
          if (oldI.isTimerIncrease())
            sendPacket(
                new ExSendUIEvent(this, true, true, startTime, endTime, oldI.getTimerText()));
          else
            sendPacket(
                new ExSendUIEvent(this, true, false, endTime - startTime, 0, oldI.getTimerText()));
        }
      }
      if (instanceId > 0) {
        newI.addPlayer(getObjectId());
        if (newI.isShowTimer()) {
          int startTime = (int) ((System.currentTimeMillis() - newI.getInstanceStartTime()) / 1000);
          int endTime = (int) ((newI.getInstanceEndTime() - newI.getInstanceStartTime()) / 1000);
          if (newI.isTimerIncrease())
            sendPacket(
                new ExSendUIEvent(this, false, true, startTime, endTime, newI.getTimerText()));
          else
            sendPacket(
                new ExSendUIEvent(this, false, false, endTime - startTime, 0, newI.getTimerText()));
        }
      }

      if (((L2PcInstance) this).getPet() != null)
        ((L2PcInstance) this).getPet().setInstanceId(instanceId);
    } else if (this instanceof L2Npc) {
      if (_instanceId > 0 && oldI != null) oldI.removeNpc(((L2Npc) this));
      if (instanceId > 0) newI.addNpc(((L2Npc) this));
    }

    _instanceId = instanceId;

    // If we change it for visible objects, me must clear & revalidates knownlists
    if (_isVisible && _knownList != null) {
      if (this instanceof L2PcInstance) {

        // We don't want some ugly looking disappear/appear effects, so don't update
        // the knownlist here, but players usually enter instancezones through teleporting
        // and the teleport will do the revalidation for us.
      } else {
        decayMe();
        spawnMe();
      }
    }
  }
Exemple #2
0
 public void toggleVisible() {
   if (isVisible()) decayMe();
   else spawnMe();
 }