Пример #1
0
 public void tryFillInExtraneousExternal(WorldMap.CrossExit EX, Exit ox, Room linkFrom) {
   if (EX == null) return;
   Room linkTo = CMLib.map().getRoom(EX.destRoomID);
   if ((linkTo != null) && (linkTo.getGridParent() != null)) linkTo = linkTo.getGridParent();
   if ((linkTo != null) && (linkFrom.rawDoors()[EX.dir] != linkTo)) {
     if (ox == null) ox = CMClass.getExit("Open");
     linkFrom.rawDoors()[EX.dir] = linkTo;
     linkFrom.setRawExit(EX.dir, ox);
   }
 }
Пример #2
0
 protected Room alternativeLink(Room room, Room defaultRoom, int dir) {
   if (room.getGridParent() == this)
     for (int d = 0; d < gridexits.size(); d++) {
       WorldMap.CrossExit EX = (WorldMap.CrossExit) gridexits.elementAt(d);
       try {
         if ((EX.out) && (EX.dir == dir) && (getGridRoomIfExists(EX.x, EX.y) == room)) {
           Room R = CMLib.map().getRoom(EX.destRoomID);
           if (R != null) {
             if (R.getGridParent() != null) return R.getGridParent();
             return R;
           }
         }
       } catch (Exception e) {
       }
     }
   return defaultRoom;
 }
Пример #3
0
 public boolean isMyGridChild(Room loc) {
   if (loc == null) return false;
   if (loc.getGridParent() == this) return true;
   if (loc.getGridParent() != null) return false;
   try {
     return rooms.contains(loc);
   } catch (Exception e) {
   } // optimization
   DVector myRooms = rooms.copyOf();
   for (int i = 0; i < myRooms.size(); i++) if (loc == myRooms.elementAt(i, 1)) return true;
   return false;
 }
Пример #4
0
 public void executeMsg(Environmental myHost, CMMsg msg) {
   if ((msg.targetMinor() == CMMsg.TYP_EXPIRE) && (msg.target() instanceof Room)) {
     Room R = (Room) msg.target();
     if (R.getGridParent() == this) {
       if ((roomID().length() > 0) && (getArea() != null))
         getArea().delProperRoomnumber(getGridChildCode(R));
       DVector thisGridRooms = rooms;
       thisGridRooms.removeElement(R);
       Room R2 = null;
       for (int r = thisGridRooms.size() - 1; r >= 0; r--) {
         R2 = (Room) thisGridRooms.elementAt(r, 1);
         for (int d = Directions.NUM_DIRECTIONS() - 1; d >= 0; d--)
           if (R2.rawDoors()[d] == R) {
             R2.rawDoors()[d] = null;
             R2.setRawExit(d, null);
           }
       }
     }
   }
   super.executeMsg(myHost, msg);
 }
Пример #5
0
  public Room getAltRoomFrom(Room loc, int direction) {
    if ((loc == null) || (direction < 0)) return null;
    int opDirection = Directions.getOpDirectionCode(direction);

    String roomID = CMLib.map().getExtendedRoomID(loc);
    for (int d = 0; d < gridexits.size(); d++) {
      WorldMap.CrossExit EX = (WorldMap.CrossExit) gridexits.elementAt(d);
      if ((!EX.out)
          && (EX.destRoomID.equalsIgnoreCase(roomID))
          && (EX.dir == direction)
          && (EX.x >= 0)
          && (EX.y >= 0)
          && (EX.x < xGridSize())
          && (EX.y < yGridSize())) return getMakeGridRoom(EX.x, EX.y);
    }

    Room oldLoc = loc;
    if (loc.getGridParent() != null) loc = loc.getGridParent();
    if ((oldLoc != loc) && (loc instanceof GridLocale)) {
      int y = ((GridLocale) loc).getGridChildY(oldLoc);
      int x = ((GridLocale) loc).getGridChildX(oldLoc);

      if ((x >= 0) && (y >= 0))
        switch (opDirection) {
          case Directions.EAST:
            if ((((GridLocale) loc).yGridSize() == yGridSize()))
              return getMakeGridRoom(xGridSize() - 1, y);
            break;
          case Directions.WEST:
            if ((((GridLocale) loc).yGridSize() == yGridSize())) return getMakeGridRoom(0, y);
            break;
          case Directions.NORTH:
            if ((((GridLocale) loc).xGridSize() == xGridSize())) return getMakeGridRoom(x, 0);
            break;
          case Directions.NORTHWEST:
            return getMakeGridRoom(0, 0);
          case Directions.SOUTHEAST:
            return getMakeGridRoom(xGridSize() - 1, yGridSize() - 1);
          case Directions.NORTHEAST:
            return getMakeGridRoom(xGridSize() - 1, 0);
          case Directions.SOUTHWEST:
            return getMakeGridRoom(0, yGridSize() - 1);
          case Directions.SOUTH:
            if ((((GridLocale) loc).xGridSize() == xGridSize()))
              return getMakeGridRoom(x, yGridSize() - 1);
            break;
        }
    }
    int x = 0;
    int y = 0;
    switch (opDirection) {
      case Directions.NORTH:
        x = xGridSize() / 2;
        break;
      case Directions.SOUTH:
        x = xGridSize() / 2;
        y = yGridSize() - 1;
        break;
      case Directions.EAST:
        x = xGridSize() - 1;
        y = yGridSize() / 2;
        break;
      case Directions.WEST:
        y = yGridSize() / 2;
        break;
      case Directions.NORTHWEST:
        x = 0;
        y = 0;
        break;
      case Directions.NORTHEAST:
        x = xGridSize() - 1;
        y = 0;
        break;
      case Directions.SOUTHWEST:
        x = 0;
        y = yGridSize() - 1;
        break;
      case Directions.SOUTHEAST:
        x = xGridSize() - 1;
        y = yGridSize() - 1;
        break;
      case Directions.UP:
      case Directions.DOWN:
        x = xGridSize() / 2;
        y = yGridSize() / 2;
        break;
    }
    return getMakeGridRoom(x, y);
  }