📄 room.java
字号:
/*
* Light And Shadow. A Persistent Universe based on Robert Jordan's Wheel of Time Books.
* Copyright (C) 2001-2002 WOTLAS Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package wotlas.common.universe;
import wotlas.common.*;
import wotlas.common.router.*;
import wotlas.common.objects.inventories.RoomInventory;
import wotlas.utils.*;
import java.awt.Rectangle;
/** A Room of an interiorMap.
*
* @author Petrus, Aldiss, Elann
* @see wotlas.common.universe.RoomLink
*/
public class Room implements WotlasMap {
/*------------------------------------------------------------------------------------*/
/** ID of the Room (index in the array {@link InteriorMap#rooms InteriorMap.rooms})
*/
private int roomID;
/** Full name of the Room
*/
private String fullName;
/** Short name of the World
*/
private String shortName;
/** Point of insertion (teleportation, arrival)
*/
private ScreenPoint insertionPoint;
/** Number maximum of players
*/
private int maxPlayers;
/** Room links...
*/
private RoomLink[] roomLinks;
/** Map exits...
*/
private MapExit[] mapExits;
/*------------------------------------------------------------------------------------*/
/** Our interiorMap where this room is.
*/
private transient InteriorMap myInteriorMap;
/** Room Location
*/
private transient WotlasLocation thisLocation;
/** Our message router. Owns the list of players of this map.
*/
private transient MessageRouter messageRouter;
/** RoomInventory used to get objects here.<br>
* Transient because there are saved elsewhere.
*/
private transient RoomInventory inventory;
/*------------------------------------------------------------------------------------*/
/** Constructor
*/
public Room() {
}
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
/*
* List of setter and getter used for persistence
*/
public void setRoomID(int myRoomID) {
this.roomID = myRoomID;
}
public int getRoomID() {
return roomID;
}
public void setFullName(String myFullName) {
this.fullName = myFullName;
}
public String getFullName() {
return fullName;
}
public void setShortName(String myShortName) {
this.shortName = myShortName;
}
public String getShortName() {
return shortName;
}
public void setInsertionPoint(ScreenPoint myInsertionPoint) {
this.insertionPoint = myInsertionPoint;
}
public ScreenPoint getInsertionPoint() {
return new ScreenPoint( insertionPoint );
}
public void setMaxPlayers(int myMaxPlayers) {
this.maxPlayers = myMaxPlayers;
}
public int getMaxPlayers() {
return maxPlayers;
}
public void setRoomLinks(RoomLink[] myRoomLinks) {
this.roomLinks = myRoomLinks;
}
public RoomLink[] getRoomLinks() {
return roomLinks;
}
public void setMapExits(MapExit[] myMapExits) {
this.mapExits = myMapExits;
}
public MapExit[] getMapExits() {
return mapExits;
}
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
/** Transient fields getter & setter
*/
public InteriorMap getMyInteriorMap() {
return myInteriorMap;
}
public MessageRouter getMessageRouter() {
return messageRouter;
}
public RoomInventory getInventory() {
return inventory;
}
public void setInventory(RoomInventory inventory) {
this.inventory=inventory;
inventory.setOwnerRoom( this );
}
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
/** Add a new RoomLink object to the array {@link #roomLinks roomLinks}
*
* @return a new RoomLink object
*/
public RoomLink addRoomLink( ScreenRectangle r ) {
RoomLink myRoomLink = new RoomLink(r);
if(roomLinks == null) {
roomLinks = new RoomLink[1];
myRoomLink.setRoomLinkID(RoomLink.getNewRoomLinkID());
roomLinks[0] = myRoomLink;
} else {
RoomLink[] myRoomLinks = new RoomLink[roomLinks.length+1];
myRoomLink.setRoomLinkID(RoomLink.getNewRoomLinkID());
System.arraycopy(roomLinks, 0, myRoomLinks, 0, roomLinks.length);
myRoomLinks[roomLinks.length] = myRoomLink;
roomLinks = myRoomLinks;
}
return myRoomLink;
}
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
/** Add a RoomLink object to the array {@link #roomLinks roomLinks}
*
* @param rl RoomLink object to add
*/
public void addRoomLink( RoomLink rl ) {
if(roomLinks == null) {
roomLinks = new RoomLink[1];
roomLinks[0] = rl;
} else {
RoomLink[] myRoomLinks = new RoomLink[roomLinks.length+1];
System.arraycopy(roomLinks, 0, myRoomLinks, 0, roomLinks.length);
myRoomLinks[roomLinks.length] = rl;
roomLinks = myRoomLinks;
}
}
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
/** Returns a RoomLink from its id.
* @return null if not found...
*/
public RoomLink getRoomLink( int roomLinkID ) {
if( roomLinks==null ) return null;
for( int i=0; i<roomLinks.length; i++ )
if( roomLinks[i].getRoomLinkID()==roomLinkID )
return roomLinks[i];
return null; // not found
}
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
/** Returns a Door from its RoomLink id.
* @return null if not found...
*/
public Door getDoor( int roomLinkID ) {
if( roomLinks==null ) return null;
for( int i=0; i<roomLinks.length; i++ )
if( roomLinks[i].getRoomLinkID()==roomLinkID )
return roomLinks[i].getDoor();
return null; // not found
}
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
/** Add a new MapExit object to the array {@link #mapExits mapExits}
*
* @return a new MapExit object
*/
public MapExit addMapExit(ScreenRectangle r) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -