|
@@ -22,50 +22,47 @@ import com.l2jserver.gameserver.model.L2WorldRegion;
|
|
import com.l2jserver.gameserver.model.actor.L2Character;
|
|
import com.l2jserver.gameserver.model.actor.L2Character;
|
|
import com.l2jserver.gameserver.util.Point3D;
|
|
import com.l2jserver.gameserver.util.Point3D;
|
|
|
|
|
|
-
|
|
|
|
public class ObjectPosition
|
|
public class ObjectPosition
|
|
{
|
|
{
|
|
private static final Logger _log = Logger.getLogger(ObjectPosition.class.getName());
|
|
private static final Logger _log = Logger.getLogger(ObjectPosition.class.getName());
|
|
|
|
|
|
- // =========================================================
|
|
|
|
- // Data Field
|
|
|
|
- private L2Object _activeObject;
|
|
|
|
- private int _heading = 0;
|
|
|
|
|
|
+ private final L2Object _activeObject;
|
|
|
|
+ private int _heading = 0;
|
|
private Point3D _worldPosition;
|
|
private Point3D _worldPosition;
|
|
- private L2WorldRegion _worldRegion; // Object localization : Used for items/chars that are seen in the world
|
|
|
|
|
|
+ private L2WorldRegion _worldRegion; // Object localization : Used for items/chars that are seen in the world
|
|
|
|
|
|
- // =========================================================
|
|
|
|
- // Constructor
|
|
|
|
public ObjectPosition(L2Object activeObject)
|
|
public ObjectPosition(L2Object activeObject)
|
|
{
|
|
{
|
|
_activeObject = activeObject;
|
|
_activeObject = activeObject;
|
|
setWorldRegion(L2World.getInstance().getRegion(getWorldPosition()));
|
|
setWorldRegion(L2World.getInstance().getRegion(getWorldPosition()));
|
|
}
|
|
}
|
|
|
|
|
|
- // =========================================================
|
|
|
|
- // Method - Public
|
|
|
|
/**
|
|
/**
|
|
- * Set the x,y,z position of the L2Object and if necessary modify its _worldRegion.<BR><BR>
|
|
|
|
- *
|
|
|
|
- * <B><U> Assert </U> :</B><BR><BR>
|
|
|
|
- * <li> _worldRegion != null</li><BR><BR>
|
|
|
|
- *
|
|
|
|
- * <B><U> Example of use </U> :</B><BR><BR>
|
|
|
|
- * <li> Update position during and after movement, or after teleport </li><BR>
|
|
|
|
- * @param x
|
|
|
|
- * @param y
|
|
|
|
- * @param z
|
|
|
|
|
|
+ * Set the x,y,z position of the L2Object and if necessary modify its _worldRegion.<BR>
|
|
|
|
+ * <BR>
|
|
|
|
+ * <B><U> Assert </U> :</B><BR>
|
|
|
|
+ * <BR>
|
|
|
|
+ * <li>_worldRegion != null</li><BR>
|
|
|
|
+ * <BR>
|
|
|
|
+ * <B><U> Example of use </U> :</B><BR>
|
|
|
|
+ * <BR>
|
|
|
|
+ * <li>Update position during and after movement, or after teleport</li><BR>
|
|
|
|
+ * @param x
|
|
|
|
+ * @param y
|
|
|
|
+ * @param z
|
|
*/
|
|
*/
|
|
public final void setXYZ(int x, int y, int z)
|
|
public final void setXYZ(int x, int y, int z)
|
|
{
|
|
{
|
|
assert getWorldRegion() != null;
|
|
assert getWorldRegion() != null;
|
|
|
|
|
|
- setWorldPosition(x, y ,z);
|
|
|
|
|
|
+ setWorldPosition(x, y, z);
|
|
|
|
|
|
try
|
|
try
|
|
{
|
|
{
|
|
if (L2World.getInstance().getRegion(getWorldPosition()) != getWorldRegion())
|
|
if (L2World.getInstance().getRegion(getWorldPosition()) != getWorldRegion())
|
|
|
|
+ {
|
|
updateWorldRegion();
|
|
updateWorldRegion();
|
|
|
|
+ }
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
catch (Exception e)
|
|
{
|
|
{
|
|
@@ -75,10 +72,11 @@ public class ObjectPosition
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- * Called on setXYZ exception.<BR><BR>
|
|
|
|
- * <B><U> Overwritten in </U> :</B><BR><BR>
|
|
|
|
- * <li> CharPosition</li>
|
|
|
|
- * <li> PcPosition</li><BR>
|
|
|
|
|
|
+ * Called on setXYZ exception.<BR>
|
|
|
|
+ * <BR>
|
|
|
|
+ * <B><U> Overwritten in </U> :</B><BR>
|
|
|
|
+ * <BR>
|
|
|
|
+ * <li>CharPosition</li> <li>PcPosition</li><BR>
|
|
*/
|
|
*/
|
|
protected void badCoords()
|
|
protected void badCoords()
|
|
{
|
|
{
|
|
@@ -86,30 +84,44 @@ public class ObjectPosition
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- * Set the x,y,z position of the L2Object and make it invisible.<BR><BR>
|
|
|
|
- *
|
|
|
|
- * <B><U> Concept</U> :</B><BR><BR>
|
|
|
|
- * A L2Object is invisble if <B>_hidden</B>=true or <B>_worldregion</B>==null <BR><BR>
|
|
|
|
- *
|
|
|
|
- * <B><U> Assert </U> :</B><BR><BR>
|
|
|
|
- * <li> _worldregion==null <I>(L2Object is invisible)</I></li><BR><BR>
|
|
|
|
- *
|
|
|
|
- * <B><U> Example of use </U> :</B><BR><BR>
|
|
|
|
- * <li> Create a Door</li>
|
|
|
|
- * <li> Restore L2PcInstance</li><BR>
|
|
|
|
- * @param x
|
|
|
|
- * @param y
|
|
|
|
- * @param z
|
|
|
|
|
|
+ * Set the x,y,z position of the L2Object and make it invisible.<BR>
|
|
|
|
+ * <BR>
|
|
|
|
+ * <B><U> Concept</U> :</B><BR>
|
|
|
|
+ * <BR>
|
|
|
|
+ * A L2Object is invisble if <B>_hidden</B>=true or <B>_worldregion</B>==null <BR>
|
|
|
|
+ * <BR>
|
|
|
|
+ * <B><U> Assert </U> :</B><BR>
|
|
|
|
+ * <BR>
|
|
|
|
+ * <li>_worldregion==null <I>(L2Object is invisible)</I></li><BR>
|
|
|
|
+ * <BR>
|
|
|
|
+ * <B><U> Example of use </U> :</B><BR>
|
|
|
|
+ * <BR>
|
|
|
|
+ * <li>Create a Door</li> <li>Restore L2PcInstance</li><BR>
|
|
|
|
+ * @param x
|
|
|
|
+ * @param y
|
|
|
|
+ * @param z
|
|
*/
|
|
*/
|
|
public final void setXYZInvisible(int x, int y, int z)
|
|
public final void setXYZInvisible(int x, int y, int z)
|
|
{
|
|
{
|
|
assert getWorldRegion() == null;
|
|
assert getWorldRegion() == null;
|
|
- 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;
|
|
|
|
|
|
+ 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;
|
|
|
|
+ }
|
|
|
|
|
|
- setWorldPosition(x, y ,z);
|
|
|
|
|
|
+ setWorldPosition(x, y, z);
|
|
getActiveObject().setIsVisible(false);
|
|
getActiveObject().setIsVisible(false);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -118,7 +130,10 @@ public class ObjectPosition
|
|
*/
|
|
*/
|
|
public void updateWorldRegion()
|
|
public void updateWorldRegion()
|
|
{
|
|
{
|
|
- if (!getActiveObject().isVisible()) return;
|
|
|
|
|
|
+ if (!getActiveObject().isVisible())
|
|
|
|
+ {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
|
|
L2WorldRegion newRegion = L2World.getInstance().getRegion(getWorldPosition());
|
|
L2WorldRegion newRegion = L2World.getInstance().getRegion(getWorldPosition());
|
|
if (newRegion != getWorldRegion())
|
|
if (newRegion != getWorldRegion())
|
|
@@ -132,36 +147,59 @@ public class ObjectPosition
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- // =========================================================
|
|
|
|
- // Method - Private
|
|
|
|
-
|
|
|
|
- // =========================================================
|
|
|
|
- // Property - Public
|
|
|
|
public L2Object getActiveObject()
|
|
public L2Object getActiveObject()
|
|
{
|
|
{
|
|
return _activeObject;
|
|
return _activeObject;
|
|
}
|
|
}
|
|
|
|
|
|
- public final int getHeading() { return _heading; }
|
|
|
|
- public final void setHeading(int value) { _heading = value; }
|
|
|
|
|
|
+ public final int getHeading()
|
|
|
|
+ {
|
|
|
|
+ return _heading;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public final void setHeading(int value)
|
|
|
|
+ {
|
|
|
|
+ _heading = value;
|
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
/**
|
|
* @return the x position of the L2Object.
|
|
* @return the x position of the L2Object.
|
|
*/
|
|
*/
|
|
- public final int getX() { return getWorldPosition().getX(); }
|
|
|
|
- public final void setX(int value) { getWorldPosition().setX(value); }
|
|
|
|
|
|
+ public final int getX()
|
|
|
|
+ {
|
|
|
|
+ return getWorldPosition().getX();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public final void setX(int value)
|
|
|
|
+ {
|
|
|
|
+ getWorldPosition().setX(value);
|
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
/**
|
|
* @return the y position of the L2Object.
|
|
* @return the y position of the L2Object.
|
|
*/
|
|
*/
|
|
- public final int getY() { return getWorldPosition().getY(); }
|
|
|
|
- public final void setY(int value) { getWorldPosition().setY(value); }
|
|
|
|
|
|
+ public final int getY()
|
|
|
|
+ {
|
|
|
|
+ return getWorldPosition().getY();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public final void setY(int value)
|
|
|
|
+ {
|
|
|
|
+ getWorldPosition().setY(value);
|
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
/**
|
|
* @return the z position of the L2Object.
|
|
* @return the z position of the L2Object.
|
|
*/
|
|
*/
|
|
- public final int getZ() { return getWorldPosition().getZ(); }
|
|
|
|
- public final void setZ(int value) { getWorldPosition().setZ(value); }
|
|
|
|
|
|
+ public final int getZ()
|
|
|
|
+ {
|
|
|
|
+ return getWorldPosition().getZ();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public final void setZ(int value)
|
|
|
|
+ {
|
|
|
|
+ getWorldPosition().setZ(value);
|
|
|
|
+ }
|
|
|
|
|
|
public final Point3D getWorldPosition()
|
|
public final Point3D getWorldPosition()
|
|
{
|
|
{
|
|
@@ -171,21 +209,34 @@ public class ObjectPosition
|
|
}
|
|
}
|
|
return _worldPosition;
|
|
return _worldPosition;
|
|
}
|
|
}
|
|
|
|
+
|
|
public final void setWorldPosition(int x, int y, int z)
|
|
public final void setWorldPosition(int x, int y, int z)
|
|
{
|
|
{
|
|
- getWorldPosition().setXYZ(x,y,z);
|
|
|
|
|
|
+ getWorldPosition().setXYZ(x, y, z);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public final void setWorldPosition(Point3D newPosition)
|
|
|
|
+ {
|
|
|
|
+ setWorldPosition(newPosition.getX(), newPosition.getY(), newPosition.getZ());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public final L2WorldRegion getWorldRegion()
|
|
|
|
+ {
|
|
|
|
+ return _worldRegion;
|
|
}
|
|
}
|
|
- public final void setWorldPosition(Point3D newPosition) { setWorldPosition(newPosition.getX(), newPosition.getY(), newPosition.getZ()); }
|
|
|
|
|
|
|
|
- public final L2WorldRegion getWorldRegion() { return _worldRegion; }
|
|
|
|
public void setWorldRegion(L2WorldRegion value)
|
|
public void setWorldRegion(L2WorldRegion value)
|
|
{
|
|
{
|
|
- if(_worldRegion != null && getActiveObject() instanceof L2Character) // confirm revalidation of old region's zones
|
|
|
|
|
|
+ if ((_worldRegion != null) && (getActiveObject() instanceof L2Character)) // confirm revalidation of old region's zones
|
|
{
|
|
{
|
|
if (value != null)
|
|
if (value != null)
|
|
- _worldRegion.revalidateZones((L2Character)getActiveObject()); // at world region change
|
|
|
|
|
|
+ {
|
|
|
|
+ _worldRegion.revalidateZones((L2Character) getActiveObject()); // at world region change
|
|
|
|
+ }
|
|
else
|
|
else
|
|
- _worldRegion.removeFromZones((L2Character)getActiveObject()); // at world region change
|
|
|
|
|
|
+ {
|
|
|
|
+ _worldRegion.removeFromZones((L2Character) getActiveObject()); // at world region change
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
_worldRegion = value;
|
|
_worldRegion = value;
|