Store WorldObject location in a Location object.

This commit is contained in:
MobiusDevelopment 2021-11-23 00:45:29 +00:00
parent 75e8deebad
commit 3227e80226
65 changed files with 872 additions and 1352 deletions

View File

@ -55,22 +55,16 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
private int _objectId;
/** World Region */
private WorldRegion _worldRegion;
/** Location */
private final Location _location = new Location(0, 0, -10000);
/** Instance */
private Instance _instance;
/** Instance type */
private InstanceType _instanceType;
private Map<String, Object> _scripts;
/** X coordinate */
private volatile int _x = 0;
/** Y coordinate */
private volatile int _y = 0;
/** Z coordinate */
private volatile int _z = -10000;
/** Orientation */
private volatile int _heading = 0;
/** Instance id of object. 0 - Global */
private Instance _instance;
private boolean _isSpawned;
private boolean _isInvisible;
private boolean _isTargetable = true;
private Map<String, Object> _scripts;
public WorldObject(int objectId)
{
@ -567,7 +561,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public int getX()
{
return _x;
return _location.getX();
}
/**
@ -577,7 +571,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public int getY()
{
return _y;
return _location.getY();
}
/**
@ -587,7 +581,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public int getZ()
{
return _z;
return _location.getZ();
}
/**
@ -597,7 +591,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public int getHeading()
{
return _heading;
return _location.getHeading();
}
/**
@ -635,7 +629,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public Location getLocation()
{
return new Location(_x, _y, _z, _heading);
return _location;
}
/**
@ -647,9 +641,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public void setXYZ(int newX, int newY, int newZ)
{
_x = newX;
_y = newY;
_z = newZ;
_location.setXYZ(newX, newY, newZ);
if (_isSpawned)
{
@ -684,7 +676,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public void setHeading(int newHeading)
{
_heading = newHeading;
_location.setHeading(newHeading);
}
/**
@ -736,10 +728,8 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public void setLocation(Location loc)
{
_x = loc.getX();
_y = loc.getY();
_z = loc.getZ();
_heading = loc.getHeading();
_location.setXYZ(loc.getX(), loc.getY(), loc.getZ());
_location.setHeading(loc.getHeading());
}
/**
@ -751,7 +741,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
*/
public double calculateDistance2D(int x, int y, int z)
{
return Math.sqrt(Math.pow(x - _x, 2) + Math.pow(y - _y, 2));
return Math.sqrt(Math.pow(x - getX(), 2) + Math.pow(y - getY(), 2));
}
/**
@ -773,7 +763,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
*/
public double calculateDistance3D(int x, int y, int z)
{
return Math.sqrt(Math.pow(x - _x, 2) + Math.pow(y - _y, 2) + Math.pow(z - _z, 2));
return Math.sqrt(Math.pow(x - getX(), 2) + Math.pow(y - getY(), 2) + Math.pow(z - getZ(), 2));
}
/**
@ -795,7 +785,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
*/
public double calculateDistanceSq2D(int x, int y, int z)
{
return Math.pow(x - _x, 2) + Math.pow(y - _y, 2);
return Math.pow(x - getX(), 2) + Math.pow(y - getY(), 2);
}
/**
@ -817,7 +807,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
*/
public double calculateDistanceSq3D(int x, int y, int z)
{
return Math.pow(x - _x, 2) + Math.pow(y - _y, 2) + Math.pow(z - _z, 2);
return Math.pow(x - getX(), 2) + Math.pow(y - getY(), 2) + Math.pow(z - getZ(), 2);
}
/**

View File

@ -55,22 +55,16 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
private int _objectId;
/** World Region */
private WorldRegion _worldRegion;
/** Location */
private final Location _location = new Location(0, 0, -10000);
/** Instance */
private Instance _instance;
/** Instance type */
private InstanceType _instanceType;
private Map<String, Object> _scripts;
/** X coordinate */
private volatile int _x = 0;
/** Y coordinate */
private volatile int _y = 0;
/** Z coordinate */
private volatile int _z = -10000;
/** Orientation */
private volatile int _heading = 0;
/** Instance id of object. 0 - Global */
private Instance _instance;
private boolean _isSpawned;
private boolean _isInvisible;
private boolean _isTargetable = true;
private Map<String, Object> _scripts;
public WorldObject(int objectId)
{
@ -567,7 +561,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public int getX()
{
return _x;
return _location.getX();
}
/**
@ -577,7 +571,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public int getY()
{
return _y;
return _location.getY();
}
/**
@ -587,7 +581,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public int getZ()
{
return _z;
return _location.getZ();
}
/**
@ -597,7 +591,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public int getHeading()
{
return _heading;
return _location.getHeading();
}
/**
@ -635,7 +629,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public Location getLocation()
{
return new Location(_x, _y, _z, _heading);
return _location;
}
/**
@ -647,9 +641,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public void setXYZ(int newX, int newY, int newZ)
{
_x = newX;
_y = newY;
_z = newZ;
_location.setXYZ(newX, newY, newZ);
if (_isSpawned)
{
@ -684,7 +676,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public void setHeading(int newHeading)
{
_heading = newHeading;
_location.setHeading(newHeading);
}
/**
@ -736,10 +728,8 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public void setLocation(Location loc)
{
_x = loc.getX();
_y = loc.getY();
_z = loc.getZ();
_heading = loc.getHeading();
_location.setXYZ(loc.getX(), loc.getY(), loc.getZ());
_location.setHeading(loc.getHeading());
}
/**
@ -751,7 +741,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
*/
public double calculateDistance2D(int x, int y, int z)
{
return Math.sqrt(Math.pow(x - _x, 2) + Math.pow(y - _y, 2));
return Math.sqrt(Math.pow(x - getX(), 2) + Math.pow(y - getY(), 2));
}
/**
@ -773,7 +763,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
*/
public double calculateDistance3D(int x, int y, int z)
{
return Math.sqrt(Math.pow(x - _x, 2) + Math.pow(y - _y, 2) + Math.pow(z - _z, 2));
return Math.sqrt(Math.pow(x - getX(), 2) + Math.pow(y - getY(), 2) + Math.pow(z - getZ(), 2));
}
/**
@ -795,7 +785,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
*/
public double calculateDistanceSq2D(int x, int y, int z)
{
return Math.pow(x - _x, 2) + Math.pow(y - _y, 2);
return Math.pow(x - getX(), 2) + Math.pow(y - getY(), 2);
}
/**
@ -817,7 +807,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
*/
public double calculateDistanceSq3D(int x, int y, int z)
{
return Math.pow(x - _x, 2) + Math.pow(y - _y, 2) + Math.pow(z - _z, 2);
return Math.pow(x - getX(), 2) + Math.pow(y - getY(), 2) + Math.pow(z - getZ(), 2);
}
/**

View File

@ -55,22 +55,16 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
private int _objectId;
/** World Region */
private WorldRegion _worldRegion;
/** Location */
private final Location _location = new Location(0, 0, -10000);
/** Instance */
private Instance _instance;
/** Instance type */
private InstanceType _instanceType;
private Map<String, Object> _scripts;
/** X coordinate */
private volatile int _x = 0;
/** Y coordinate */
private volatile int _y = 0;
/** Z coordinate */
private volatile int _z = -10000;
/** Orientation */
private volatile int _heading = 0;
/** Instance id of object. 0 - Global */
private Instance _instance;
private boolean _isSpawned;
private boolean _isInvisible;
private boolean _isTargetable = true;
private Map<String, Object> _scripts;
public WorldObject(int objectId)
{
@ -567,7 +561,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public int getX()
{
return _x;
return _location.getX();
}
/**
@ -577,7 +571,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public int getY()
{
return _y;
return _location.getY();
}
/**
@ -587,7 +581,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public int getZ()
{
return _z;
return _location.getZ();
}
/**
@ -597,7 +591,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public int getHeading()
{
return _heading;
return _location.getHeading();
}
/**
@ -635,7 +629,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public Location getLocation()
{
return new Location(_x, _y, _z, _heading);
return _location;
}
/**
@ -647,9 +641,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public void setXYZ(int newX, int newY, int newZ)
{
_x = newX;
_y = newY;
_z = newZ;
_location.setXYZ(newX, newY, newZ);
if (_isSpawned)
{
@ -684,7 +676,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public void setHeading(int newHeading)
{
_heading = newHeading;
_location.setHeading(newHeading);
}
/**
@ -736,10 +728,8 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public void setLocation(Location loc)
{
_x = loc.getX();
_y = loc.getY();
_z = loc.getZ();
_heading = loc.getHeading();
_location.setXYZ(loc.getX(), loc.getY(), loc.getZ());
_location.setHeading(loc.getHeading());
}
/**
@ -751,7 +741,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
*/
public double calculateDistance2D(int x, int y, int z)
{
return Math.sqrt(Math.pow(x - _x, 2) + Math.pow(y - _y, 2));
return Math.sqrt(Math.pow(x - getX(), 2) + Math.pow(y - getY(), 2));
}
/**
@ -773,7 +763,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
*/
public double calculateDistance3D(int x, int y, int z)
{
return Math.sqrt(Math.pow(x - _x, 2) + Math.pow(y - _y, 2) + Math.pow(z - _z, 2));
return Math.sqrt(Math.pow(x - getX(), 2) + Math.pow(y - getY(), 2) + Math.pow(z - getZ(), 2));
}
/**
@ -795,7 +785,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
*/
public double calculateDistanceSq2D(int x, int y, int z)
{
return Math.pow(x - _x, 2) + Math.pow(y - _y, 2);
return Math.pow(x - getX(), 2) + Math.pow(y - getY(), 2);
}
/**
@ -817,7 +807,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
*/
public double calculateDistanceSq3D(int x, int y, int z)
{
return Math.pow(x - _x, 2) + Math.pow(y - _y, 2) + Math.pow(z - _z, 2);
return Math.pow(x - getX(), 2) + Math.pow(y - getY(), 2) + Math.pow(z - getZ(), 2);
}
/**

View File

@ -55,22 +55,16 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
private int _objectId;
/** World Region */
private WorldRegion _worldRegion;
/** Location */
private final Location _location = new Location(0, 0, -10000);
/** Instance */
private Instance _instance;
/** Instance type */
private InstanceType _instanceType;
private Map<String, Object> _scripts;
/** X coordinate */
private volatile int _x = 0;
/** Y coordinate */
private volatile int _y = 0;
/** Z coordinate */
private volatile int _z = -10000;
/** Orientation */
private volatile int _heading = 0;
/** Instance id of object. 0 - Global */
private Instance _instance;
private boolean _isSpawned;
private boolean _isInvisible;
private boolean _isTargetable = true;
private Map<String, Object> _scripts;
public WorldObject(int objectId)
{
@ -567,7 +561,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public int getX()
{
return _x;
return _location.getX();
}
/**
@ -577,7 +571,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public int getY()
{
return _y;
return _location.getY();
}
/**
@ -587,7 +581,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public int getZ()
{
return _z;
return _location.getZ();
}
/**
@ -597,7 +591,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public int getHeading()
{
return _heading;
return _location.getHeading();
}
/**
@ -635,7 +629,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public Location getLocation()
{
return new Location(_x, _y, _z, _heading);
return _location;
}
/**
@ -647,9 +641,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public void setXYZ(int newX, int newY, int newZ)
{
_x = newX;
_y = newY;
_z = newZ;
_location.setXYZ(newX, newY, newZ);
if (_isSpawned)
{
@ -684,7 +676,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public void setHeading(int newHeading)
{
_heading = newHeading;
_location.setHeading(newHeading);
}
/**
@ -736,10 +728,8 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public void setLocation(Location loc)
{
_x = loc.getX();
_y = loc.getY();
_z = loc.getZ();
_heading = loc.getHeading();
_location.setXYZ(loc.getX(), loc.getY(), loc.getZ());
_location.setHeading(loc.getHeading());
}
/**
@ -751,7 +741,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
*/
public double calculateDistance2D(int x, int y, int z)
{
return Math.sqrt(Math.pow(x - _x, 2) + Math.pow(y - _y, 2));
return Math.sqrt(Math.pow(x - getX(), 2) + Math.pow(y - getY(), 2));
}
/**
@ -773,7 +763,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
*/
public double calculateDistance3D(int x, int y, int z)
{
return Math.sqrt(Math.pow(x - _x, 2) + Math.pow(y - _y, 2) + Math.pow(z - _z, 2));
return Math.sqrt(Math.pow(x - getX(), 2) + Math.pow(y - getY(), 2) + Math.pow(z - getZ(), 2));
}
/**
@ -795,7 +785,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
*/
public double calculateDistanceSq2D(int x, int y, int z)
{
return Math.pow(x - _x, 2) + Math.pow(y - _y, 2);
return Math.pow(x - getX(), 2) + Math.pow(y - getY(), 2);
}
/**
@ -817,7 +807,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
*/
public double calculateDistanceSq3D(int x, int y, int z)
{
return Math.pow(x - _x, 2) + Math.pow(y - _y, 2) + Math.pow(z - _z, 2);
return Math.pow(x - getX(), 2) + Math.pow(y - getY(), 2) + Math.pow(z - getZ(), 2);
}
/**

View File

@ -55,22 +55,16 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
private int _objectId;
/** World Region */
private WorldRegion _worldRegion;
/** Location */
private final Location _location = new Location(0, 0, -10000);
/** Instance */
private Instance _instance;
/** Instance type */
private InstanceType _instanceType;
private Map<String, Object> _scripts;
/** X coordinate */
private volatile int _x = 0;
/** Y coordinate */
private volatile int _y = 0;
/** Z coordinate */
private volatile int _z = -10000;
/** Orientation */
private volatile int _heading = 0;
/** Instance id of object. 0 - Global */
private Instance _instance;
private boolean _isSpawned;
private boolean _isInvisible;
private boolean _isTargetable = true;
private Map<String, Object> _scripts;
public WorldObject(int objectId)
{
@ -567,7 +561,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public int getX()
{
return _x;
return _location.getX();
}
/**
@ -577,7 +571,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public int getY()
{
return _y;
return _location.getY();
}
/**
@ -587,7 +581,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public int getZ()
{
return _z;
return _location.getZ();
}
/**
@ -597,7 +591,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public int getHeading()
{
return _heading;
return _location.getHeading();
}
/**
@ -635,7 +629,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public Location getLocation()
{
return new Location(_x, _y, _z, _heading);
return _location;
}
/**
@ -647,9 +641,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public void setXYZ(int newX, int newY, int newZ)
{
_x = newX;
_y = newY;
_z = newZ;
_location.setXYZ(newX, newY, newZ);
if (_isSpawned)
{
@ -684,7 +676,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public void setHeading(int newHeading)
{
_heading = newHeading;
_location.setHeading(newHeading);
}
/**
@ -736,10 +728,8 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public void setLocation(Location loc)
{
_x = loc.getX();
_y = loc.getY();
_z = loc.getZ();
_heading = loc.getHeading();
_location.setXYZ(loc.getX(), loc.getY(), loc.getZ());
_location.setHeading(loc.getHeading());
}
/**
@ -751,7 +741,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
*/
public double calculateDistance2D(int x, int y, int z)
{
return Math.sqrt(Math.pow(x - _x, 2) + Math.pow(y - _y, 2));
return Math.sqrt(Math.pow(x - getX(), 2) + Math.pow(y - getY(), 2));
}
/**
@ -773,7 +763,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
*/
public double calculateDistance3D(int x, int y, int z)
{
return Math.sqrt(Math.pow(x - _x, 2) + Math.pow(y - _y, 2) + Math.pow(z - _z, 2));
return Math.sqrt(Math.pow(x - getX(), 2) + Math.pow(y - getY(), 2) + Math.pow(z - getZ(), 2));
}
/**
@ -795,7 +785,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
*/
public double calculateDistanceSq2D(int x, int y, int z)
{
return Math.pow(x - _x, 2) + Math.pow(y - _y, 2);
return Math.pow(x - getX(), 2) + Math.pow(y - getY(), 2);
}
/**
@ -817,7 +807,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
*/
public double calculateDistanceSq3D(int x, int y, int z)
{
return Math.pow(x - _x, 2) + Math.pow(y - _y, 2) + Math.pow(z - _z, 2);
return Math.pow(x - getX(), 2) + Math.pow(y - getY(), 2) + Math.pow(z - getZ(), 2);
}
/**

View File

@ -55,22 +55,16 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
private int _objectId;
/** World Region */
private WorldRegion _worldRegion;
/** Location */
private final Location _location = new Location(0, 0, -10000);
/** Instance */
private Instance _instance;
/** Instance type */
private InstanceType _instanceType;
private Map<String, Object> _scripts;
/** X coordinate */
private volatile int _x = 0;
/** Y coordinate */
private volatile int _y = 0;
/** Z coordinate */
private volatile int _z = -10000;
/** Orientation */
private volatile int _heading = 0;
/** Instance id of object. 0 - Global */
private Instance _instance;
private boolean _isSpawned;
private boolean _isInvisible;
private boolean _isTargetable = true;
private Map<String, Object> _scripts;
public WorldObject(int objectId)
{
@ -567,7 +561,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public int getX()
{
return _x;
return _location.getX();
}
/**
@ -577,7 +571,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public int getY()
{
return _y;
return _location.getY();
}
/**
@ -587,7 +581,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public int getZ()
{
return _z;
return _location.getZ();
}
/**
@ -597,7 +591,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public int getHeading()
{
return _heading;
return _location.getHeading();
}
/**
@ -635,7 +629,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public Location getLocation()
{
return new Location(_x, _y, _z, _heading);
return _location;
}
/**
@ -647,9 +641,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public void setXYZ(int newX, int newY, int newZ)
{
_x = newX;
_y = newY;
_z = newZ;
_location.setXYZ(newX, newY, newZ);
if (_isSpawned)
{
@ -684,7 +676,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public void setHeading(int newHeading)
{
_heading = newHeading;
_location.setHeading(newHeading);
}
/**
@ -736,10 +728,8 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public void setLocation(Location loc)
{
_x = loc.getX();
_y = loc.getY();
_z = loc.getZ();
_heading = loc.getHeading();
_location.setXYZ(loc.getX(), loc.getY(), loc.getZ());
_location.setHeading(loc.getHeading());
}
/**
@ -751,7 +741,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
*/
public double calculateDistance2D(int x, int y, int z)
{
return Math.sqrt(Math.pow(x - _x, 2) + Math.pow(y - _y, 2));
return Math.sqrt(Math.pow(x - getX(), 2) + Math.pow(y - getY(), 2));
}
/**
@ -773,7 +763,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
*/
public double calculateDistance3D(int x, int y, int z)
{
return Math.sqrt(Math.pow(x - _x, 2) + Math.pow(y - _y, 2) + Math.pow(z - _z, 2));
return Math.sqrt(Math.pow(x - getX(), 2) + Math.pow(y - getY(), 2) + Math.pow(z - getZ(), 2));
}
/**
@ -795,7 +785,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
*/
public double calculateDistanceSq2D(int x, int y, int z)
{
return Math.pow(x - _x, 2) + Math.pow(y - _y, 2);
return Math.pow(x - getX(), 2) + Math.pow(y - getY(), 2);
}
/**
@ -817,7 +807,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
*/
public double calculateDistanceSq3D(int x, int y, int z)
{
return Math.pow(x - _x, 2) + Math.pow(y - _y, 2) + Math.pow(z - _z, 2);
return Math.pow(x - getX(), 2) + Math.pow(y - getY(), 2) + Math.pow(z - getZ(), 2);
}
/**

View File

@ -55,22 +55,16 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
private int _objectId;
/** World Region */
private WorldRegion _worldRegion;
/** Location */
private final Location _location = new Location(0, 0, -10000);
/** Instance */
private Instance _instance;
/** Instance type */
private InstanceType _instanceType;
private Map<String, Object> _scripts;
/** X coordinate */
private volatile int _x = 0;
/** Y coordinate */
private volatile int _y = 0;
/** Z coordinate */
private volatile int _z = -10000;
/** Orientation */
private volatile int _heading = 0;
/** Instance id of object. 0 - Global */
private Instance _instance;
private boolean _isSpawned;
private boolean _isInvisible;
private boolean _isTargetable = true;
private Map<String, Object> _scripts;
public WorldObject(int objectId)
{
@ -567,7 +561,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public int getX()
{
return _x;
return _location.getX();
}
/**
@ -577,7 +571,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public int getY()
{
return _y;
return _location.getY();
}
/**
@ -587,7 +581,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public int getZ()
{
return _z;
return _location.getZ();
}
/**
@ -597,7 +591,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public int getHeading()
{
return _heading;
return _location.getHeading();
}
/**
@ -635,7 +629,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public Location getLocation()
{
return new Location(_x, _y, _z, _heading);
return _location;
}
/**
@ -647,9 +641,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public void setXYZ(int newX, int newY, int newZ)
{
_x = newX;
_y = newY;
_z = newZ;
_location.setXYZ(newX, newY, newZ);
if (_isSpawned)
{
@ -684,7 +676,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public void setHeading(int newHeading)
{
_heading = newHeading;
_location.setHeading(newHeading);
}
/**
@ -736,10 +728,8 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public void setLocation(Location loc)
{
_x = loc.getX();
_y = loc.getY();
_z = loc.getZ();
_heading = loc.getHeading();
_location.setXYZ(loc.getX(), loc.getY(), loc.getZ());
_location.setHeading(loc.getHeading());
}
/**
@ -751,7 +741,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
*/
public double calculateDistance2D(int x, int y, int z)
{
return Math.sqrt(Math.pow(x - _x, 2) + Math.pow(y - _y, 2));
return Math.sqrt(Math.pow(x - getX(), 2) + Math.pow(y - getY(), 2));
}
/**
@ -773,7 +763,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
*/
public double calculateDistance3D(int x, int y, int z)
{
return Math.sqrt(Math.pow(x - _x, 2) + Math.pow(y - _y, 2) + Math.pow(z - _z, 2));
return Math.sqrt(Math.pow(x - getX(), 2) + Math.pow(y - getY(), 2) + Math.pow(z - getZ(), 2));
}
/**
@ -795,7 +785,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
*/
public double calculateDistanceSq2D(int x, int y, int z)
{
return Math.pow(x - _x, 2) + Math.pow(y - _y, 2);
return Math.pow(x - getX(), 2) + Math.pow(y - getY(), 2);
}
/**
@ -817,7 +807,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
*/
public double calculateDistanceSq3D(int x, int y, int z)
{
return Math.pow(x - _x, 2) + Math.pow(y - _y, 2) + Math.pow(z - _z, 2);
return Math.pow(x - getX(), 2) + Math.pow(y - getY(), 2) + Math.pow(z - getZ(), 2);
}
/**

View File

@ -55,22 +55,16 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
private int _objectId;
/** World Region */
private WorldRegion _worldRegion;
/** Location */
private final Location _location = new Location(0, 0, -10000);
/** Instance */
private Instance _instance;
/** Instance type */
private InstanceType _instanceType;
private Map<String, Object> _scripts;
/** X coordinate */
private volatile int _x = 0;
/** Y coordinate */
private volatile int _y = 0;
/** Z coordinate */
private volatile int _z = -10000;
/** Orientation */
private volatile int _heading = 0;
/** Instance id of object. 0 - Global */
private Instance _instance;
private boolean _isSpawned;
private boolean _isInvisible;
private boolean _isTargetable = true;
private Map<String, Object> _scripts;
public WorldObject(int objectId)
{
@ -567,7 +561,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public int getX()
{
return _x;
return _location.getX();
}
/**
@ -577,7 +571,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public int getY()
{
return _y;
return _location.getY();
}
/**
@ -587,7 +581,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public int getZ()
{
return _z;
return _location.getZ();
}
/**
@ -597,7 +591,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public int getHeading()
{
return _heading;
return _location.getHeading();
}
/**
@ -635,7 +629,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public Location getLocation()
{
return new Location(_x, _y, _z, _heading);
return _location;
}
/**
@ -647,9 +641,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public void setXYZ(int newX, int newY, int newZ)
{
_x = newX;
_y = newY;
_z = newZ;
_location.setXYZ(newX, newY, newZ);
if (_isSpawned)
{
@ -684,7 +676,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public void setHeading(int newHeading)
{
_heading = newHeading;
_location.setHeading(newHeading);
}
/**
@ -736,10 +728,8 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public void setLocation(Location loc)
{
_x = loc.getX();
_y = loc.getY();
_z = loc.getZ();
_heading = loc.getHeading();
_location.setXYZ(loc.getX(), loc.getY(), loc.getZ());
_location.setHeading(loc.getHeading());
}
/**
@ -751,7 +741,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
*/
public double calculateDistance2D(int x, int y, int z)
{
return Math.sqrt(Math.pow(x - _x, 2) + Math.pow(y - _y, 2));
return Math.sqrt(Math.pow(x - getX(), 2) + Math.pow(y - getY(), 2));
}
/**
@ -773,7 +763,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
*/
public double calculateDistance3D(int x, int y, int z)
{
return Math.sqrt(Math.pow(x - _x, 2) + Math.pow(y - _y, 2) + Math.pow(z - _z, 2));
return Math.sqrt(Math.pow(x - getX(), 2) + Math.pow(y - getY(), 2) + Math.pow(z - getZ(), 2));
}
/**
@ -795,7 +785,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
*/
public double calculateDistanceSq2D(int x, int y, int z)
{
return Math.pow(x - _x, 2) + Math.pow(y - _y, 2);
return Math.pow(x - getX(), 2) + Math.pow(y - getY(), 2);
}
/**
@ -817,7 +807,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
*/
public double calculateDistanceSq3D(int x, int y, int z)
{
return Math.pow(x - _x, 2) + Math.pow(y - _y, 2) + Math.pow(z - _z, 2);
return Math.pow(x - getX(), 2) + Math.pow(y - getY(), 2) + Math.pow(z - getZ(), 2);
}
/**

View File

@ -55,22 +55,16 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
private int _objectId;
/** World Region */
private WorldRegion _worldRegion;
/** Location */
private final Location _location = new Location(0, 0, -10000);
/** Instance */
private Instance _instance;
/** Instance type */
private InstanceType _instanceType;
private Map<String, Object> _scripts;
/** X coordinate */
private volatile int _x = 0;
/** Y coordinate */
private volatile int _y = 0;
/** Z coordinate */
private volatile int _z = -10000;
/** Orientation */
private volatile int _heading = 0;
/** Instance id of object. 0 - Global */
private Instance _instance;
private boolean _isSpawned;
private boolean _isInvisible;
private boolean _isTargetable = true;
private Map<String, Object> _scripts;
public WorldObject(int objectId)
{
@ -567,7 +561,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public int getX()
{
return _x;
return _location.getX();
}
/**
@ -577,7 +571,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public int getY()
{
return _y;
return _location.getY();
}
/**
@ -587,7 +581,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public int getZ()
{
return _z;
return _location.getZ();
}
/**
@ -597,7 +591,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public int getHeading()
{
return _heading;
return _location.getHeading();
}
/**
@ -635,7 +629,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public Location getLocation()
{
return new Location(_x, _y, _z, _heading);
return _location;
}
/**
@ -647,9 +641,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public void setXYZ(int newX, int newY, int newZ)
{
_x = newX;
_y = newY;
_z = newZ;
_location.setXYZ(newX, newY, newZ);
if (_isSpawned)
{
@ -684,7 +676,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public void setHeading(int newHeading)
{
_heading = newHeading;
_location.setHeading(newHeading);
}
/**
@ -736,10 +728,8 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public void setLocation(Location loc)
{
_x = loc.getX();
_y = loc.getY();
_z = loc.getZ();
_heading = loc.getHeading();
_location.setXYZ(loc.getX(), loc.getY(), loc.getZ());
_location.setHeading(loc.getHeading());
}
/**
@ -751,7 +741,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
*/
public double calculateDistance2D(int x, int y, int z)
{
return Math.sqrt(Math.pow(x - _x, 2) + Math.pow(y - _y, 2));
return Math.sqrt(Math.pow(x - getX(), 2) + Math.pow(y - getY(), 2));
}
/**
@ -773,7 +763,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
*/
public double calculateDistance3D(int x, int y, int z)
{
return Math.sqrt(Math.pow(x - _x, 2) + Math.pow(y - _y, 2) + Math.pow(z - _z, 2));
return Math.sqrt(Math.pow(x - getX(), 2) + Math.pow(y - getY(), 2) + Math.pow(z - getZ(), 2));
}
/**
@ -795,7 +785,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
*/
public double calculateDistanceSq2D(int x, int y, int z)
{
return Math.pow(x - _x, 2) + Math.pow(y - _y, 2);
return Math.pow(x - getX(), 2) + Math.pow(y - getY(), 2);
}
/**
@ -817,7 +807,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
*/
public double calculateDistanceSq3D(int x, int y, int z)
{
return Math.pow(x - _x, 2) + Math.pow(y - _y, 2) + Math.pow(z - _z, 2);
return Math.pow(x - getX(), 2) + Math.pow(y - getY(), 2) + Math.pow(z - getZ(), 2);
}
/**

View File

@ -55,22 +55,16 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
private int _objectId;
/** World Region */
private WorldRegion _worldRegion;
/** Location */
private final Location _location = new Location(0, 0, -10000);
/** Instance */
private Instance _instance;
/** Instance type */
private InstanceType _instanceType;
private Map<String, Object> _scripts;
/** X coordinate */
private volatile int _x = 0;
/** Y coordinate */
private volatile int _y = 0;
/** Z coordinate */
private volatile int _z = -10000;
/** Orientation */
private volatile int _heading = 0;
/** Instance id of object. 0 - Global */
private Instance _instance;
private boolean _isSpawned;
private boolean _isInvisible;
private boolean _isTargetable = true;
private Map<String, Object> _scripts;
public WorldObject(int objectId)
{
@ -567,7 +561,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public int getX()
{
return _x;
return _location.getX();
}
/**
@ -577,7 +571,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public int getY()
{
return _y;
return _location.getY();
}
/**
@ -587,7 +581,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public int getZ()
{
return _z;
return _location.getZ();
}
/**
@ -597,7 +591,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public int getHeading()
{
return _heading;
return _location.getHeading();
}
/**
@ -635,7 +629,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public Location getLocation()
{
return new Location(_x, _y, _z, _heading);
return _location;
}
/**
@ -647,9 +641,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public void setXYZ(int newX, int newY, int newZ)
{
_x = newX;
_y = newY;
_z = newZ;
_location.setXYZ(newX, newY, newZ);
if (_isSpawned)
{
@ -684,7 +676,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public void setHeading(int newHeading)
{
_heading = newHeading;
_location.setHeading(newHeading);
}
/**
@ -736,10 +728,8 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public void setLocation(Location loc)
{
_x = loc.getX();
_y = loc.getY();
_z = loc.getZ();
_heading = loc.getHeading();
_location.setXYZ(loc.getX(), loc.getY(), loc.getZ());
_location.setHeading(loc.getHeading());
}
/**
@ -751,7 +741,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
*/
public double calculateDistance2D(int x, int y, int z)
{
return Math.sqrt(Math.pow(x - _x, 2) + Math.pow(y - _y, 2));
return Math.sqrt(Math.pow(x - getX(), 2) + Math.pow(y - getY(), 2));
}
/**
@ -773,7 +763,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
*/
public double calculateDistance3D(int x, int y, int z)
{
return Math.sqrt(Math.pow(x - _x, 2) + Math.pow(y - _y, 2) + Math.pow(z - _z, 2));
return Math.sqrt(Math.pow(x - getX(), 2) + Math.pow(y - getY(), 2) + Math.pow(z - getZ(), 2));
}
/**
@ -795,7 +785,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
*/
public double calculateDistanceSq2D(int x, int y, int z)
{
return Math.pow(x - _x, 2) + Math.pow(y - _y, 2);
return Math.pow(x - getX(), 2) + Math.pow(y - getY(), 2);
}
/**
@ -817,7 +807,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
*/
public double calculateDistanceSq3D(int x, int y, int z)
{
return Math.pow(x - _x, 2) + Math.pow(y - _y, 2) + Math.pow(z - _z, 2);
return Math.pow(x - getX(), 2) + Math.pow(y - getY(), 2) + Math.pow(z - getZ(), 2);
}
/**

View File

@ -55,22 +55,16 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
private int _objectId;
/** World Region */
private WorldRegion _worldRegion;
/** Location */
private final Location _location = new Location(0, 0, -10000);
/** Instance */
private Instance _instance;
/** Instance type */
private InstanceType _instanceType;
private Map<String, Object> _scripts;
/** X coordinate */
private volatile int _x = 0;
/** Y coordinate */
private volatile int _y = 0;
/** Z coordinate */
private volatile int _z = -10000;
/** Orientation */
private volatile int _heading = 0;
/** Instance id of object. 0 - Global */
private Instance _instance;
private boolean _isSpawned;
private boolean _isInvisible;
private boolean _isTargetable = true;
private Map<String, Object> _scripts;
public WorldObject(int objectId)
{
@ -567,7 +561,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public int getX()
{
return _x;
return _location.getX();
}
/**
@ -577,7 +571,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public int getY()
{
return _y;
return _location.getY();
}
/**
@ -587,7 +581,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public int getZ()
{
return _z;
return _location.getZ();
}
/**
@ -597,7 +591,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public int getHeading()
{
return _heading;
return _location.getHeading();
}
/**
@ -635,7 +629,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public Location getLocation()
{
return new Location(_x, _y, _z, _heading);
return _location;
}
/**
@ -647,9 +641,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public void setXYZ(int newX, int newY, int newZ)
{
_x = newX;
_y = newY;
_z = newZ;
_location.setXYZ(newX, newY, newZ);
if (_isSpawned)
{
@ -684,7 +676,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public void setHeading(int newHeading)
{
_heading = newHeading;
_location.setHeading(newHeading);
}
/**
@ -736,10 +728,8 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public void setLocation(Location loc)
{
_x = loc.getX();
_y = loc.getY();
_z = loc.getZ();
_heading = loc.getHeading();
_location.setXYZ(loc.getX(), loc.getY(), loc.getZ());
_location.setHeading(loc.getHeading());
}
/**
@ -751,7 +741,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
*/
public double calculateDistance2D(int x, int y, int z)
{
return Math.sqrt(Math.pow(x - _x, 2) + Math.pow(y - _y, 2));
return Math.sqrt(Math.pow(x - getX(), 2) + Math.pow(y - getY(), 2));
}
/**
@ -773,7 +763,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
*/
public double calculateDistance3D(int x, int y, int z)
{
return Math.sqrt(Math.pow(x - _x, 2) + Math.pow(y - _y, 2) + Math.pow(z - _z, 2));
return Math.sqrt(Math.pow(x - getX(), 2) + Math.pow(y - getY(), 2) + Math.pow(z - getZ(), 2));
}
/**
@ -795,7 +785,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
*/
public double calculateDistanceSq2D(int x, int y, int z)
{
return Math.pow(x - _x, 2) + Math.pow(y - _y, 2);
return Math.pow(x - getX(), 2) + Math.pow(y - getY(), 2);
}
/**
@ -817,7 +807,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
*/
public double calculateDistanceSq3D(int x, int y, int z)
{
return Math.pow(x - _x, 2) + Math.pow(y - _y, 2) + Math.pow(z - _z, 2);
return Math.pow(x - getX(), 2) + Math.pow(y - getY(), 2) + Math.pow(z - getZ(), 2);
}
/**

View File

@ -123,7 +123,7 @@ public class BoatData implements IXmlReader
final CreatureTemplate template = new CreatureTemplate(npcDat);
final Boat boat = new Boat(IdManager.getInstance().getNextId(), template);
boat.getPosition().setHeading(set.getInt("heading"));
boat.getLocation().setHeading(set.getInt("heading"));
boat.setXYZ(set.getInt("spawnX"), set.getInt("spawnY"), set.getInt("spawnZ"));
boat.setPathA(set.getInt("pathIdA"), set.getInt("ticketA"), set.getInt("xTeleNoTicketA"), set.getInt("yTeleNoTicketA"), set.getInt("zTeleNoTicketA"), set.getString("announcerA"), set.getString("message10A"), set.getString("message5A"), set.getString("message1A"), set.getString("message0A"), set.getString("messageBeginA"), paths.get(set.getInt("pathIdA")));
boat.setPathB(set.getInt("pathIdB"), set.getInt("ticketB"), set.getInt("xTeleNoTicketB"), set.getInt("yTeleNoTicketB"), set.getInt("zTeleNoTicketB"), set.getString("announcerB"), set.getString("message10B"), set.getString("message5B"), set.getString("message1B"), set.getString("message0B"), set.getString("messageBeginB"), paths.get(set.getInt("pathIdB")));

View File

@ -127,13 +127,13 @@ public class ItemsOnGroundManager
item.setEnchantLevel(result.getInt(4));
}
item.getPosition().setWorldPosition(result.getInt(5), result.getInt(6), result.getInt(7));
item.getPosition().setWorldRegion(World.getInstance().getRegion(item.getLocation()));
item.getPosition().getWorldRegion().addVisibleObject(item);
item.setXYZ(result.getInt(5), result.getInt(6), result.getInt(7));
item.setWorldRegion(World.getInstance().getRegion(item.getLocation()));
item.getWorldRegion().addVisibleObject(item);
item.setDropTime(result.getLong(8));
item.setProtected(result.getLong(8) == -1);
item.setSpawned(true);
World.getInstance().addVisibleObject(item, item.getPosition().getWorldRegion(), null);
World.getInstance().addVisibleObject(item, item.getWorldRegion(), null);
_items.add(item);
count++;
// add to ItemsAutoDestroy only items not protected

View File

@ -25,16 +25,16 @@ import org.l2jmobius.commons.util.Point2D;
*/
public class Location extends Point2D
{
public static final Location DUMMY_LOC = new Location(0, 0, 0);
protected volatile int _z;
protected volatile int _heading;
protected volatile int _instanceId;
public Location(int x, int y, int z)
{
super(x, y);
_z = z;
_heading = 0;
_instanceId = 0;
}
public Location(int x, int y, int z, int heading)
@ -42,11 +42,12 @@ public class Location extends Point2D
super(x, y);
_z = z;
_heading = heading;
_instanceId = 0;
}
public Location(WorldObject obj)
{
this(obj.getX(), obj.getY(), obj.getZ(), obj.getPosition().getHeading(), obj.getInstanceId());
this(obj.getX(), obj.getY(), obj.getZ(), obj.getHeading(), obj.getInstanceId());
}
public Location(int x, int y, int z, int heading, int instanceId)
@ -54,6 +55,7 @@ public class Location extends Point2D
super(x, y);
_z = z;
_heading = heading;
_instanceId = instanceId;
}
public Location(StatSet set)
@ -61,6 +63,7 @@ public class Location extends Point2D
super(set.getInt("x", 0), set.getInt("y", 0));
_z = set.getInt("z", 0);
_heading = set.getInt("heading", 0);
_instanceId = set.getInt("instanceId", 0);
}
/**
@ -132,12 +135,36 @@ public class Location extends Point2D
_heading = heading;
}
/**
* Get the instance Id.
* @return the instance Id
*/
public int getInstanceId()
{
return _instanceId;
}
/**
* Set the instance Id.
* @param instanceId the instance Id to set
*/
public void setInstanceId(int instanceId)
{
_instanceId = instanceId;
}
public Location getLocation()
{
return this;
}
public void setLocation(Location loc)
{
_x = loc.getX();
_y = loc.getY();
_z = loc.getZ();
_heading = loc.getHeading();
_instanceId = loc.getInstanceId();
}
@Override
@ -145,12 +172,13 @@ public class Location extends Point2D
{
super.clean();
_z = 0;
_instanceId = 0;
}
@Override
public Location clone()
{
return new Location(_x, _y, _z);
return new Location(_x, _y, _z, _heading, _instanceId);
}
@Override
@ -159,31 +187,31 @@ public class Location extends Point2D
return (31 * super.hashCode()) + Objects.hash(_z);
}
@Override
public boolean equals(Object obj)
{
if (obj instanceof Location)
{
final Location loc = (Location) obj;
return (getX() == loc.getX()) && (getY() == loc.getY()) && (getZ() == loc.getZ()) && (getHeading() == loc.getHeading()) && (getInstanceId() == loc.getInstanceId());
}
return false;
}
/**
* @param x : The X coord to test.
* @param y : The Y coord to test.
* @param z : The X coord to test.
* @return True if all coordinates equals this {@link Point2D} coordinates.
* @param z : The Z coord to test.
* @return True if all coordinates equals this {@link Location} coordinates.
*/
public boolean equals(int x, int y, int z)
{
return (_x == x) && (_y == y) && (_z == z);
}
@Override
public boolean equals(Object obj)
{
if (obj instanceof Location)
{
final Location loc = (Location) obj;
return (getX() == loc.getX()) && (getY() == loc.getY()) && (getZ() == loc.getZ()) && (getHeading() == loc.getHeading());
}
return false;
}
@Override
public String toString()
{
return "[" + getClass().getSimpleName() + "] X: " + _x + " Y: " + _y + " Z: " + _z + " Heading: " + _heading;
return "[" + getClass().getSimpleName() + "] X: " + _x + " Y: " + _y + " Z: " + _z + " Heading: " + _heading + " InstanceId: " + _instanceId;
}
}

View File

@ -1,250 +0,0 @@
/*
* This file is part of the L2J Mobius project.
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package org.l2jmobius.gameserver.model;
import java.util.logging.Logger;
import org.l2jmobius.gameserver.model.actor.Creature;
import org.l2jmobius.gameserver.model.actor.Player;
public class ObjectPosition
{
private static final Logger LOGGER = Logger.getLogger(ObjectPosition.class.getName());
private final WorldObject _activeObject;
private int _heading = 0;
private Location _worldPosition;
private WorldRegion _worldRegion; // Object localization : Used for items/chars that are seen in the world
/**
* Instantiates a new object position.
* @param activeObject the active object
*/
public ObjectPosition(WorldObject activeObject)
{
_activeObject = activeObject;
setWorldRegion(World.getInstance().getRegion(getWorldPosition()));
}
/**
* Set the x,y,z position of the WorldObject and if necessary modify its _worldRegion.<br>
* <br>
* <b><u>Assert</u>:</b><br>
* <li>_worldRegion != null</li><br>
* <br>
* <b><u>Example of use</u>:</b><br>
* <li>Update position during and after movement, or after teleport</li><br>
* @param x the x
* @param y the y
* @param z the z
*/
public void setXYZ(int x, int y, int z)
{
setWorldPosition(x, y, z);
try
{
if (World.getInstance().getRegion(getWorldPosition()) != getWorldRegion())
{
updateWorldRegion();
}
}
catch (Exception e)
{
LOGGER.warning("Object Id at bad coords: (x: " + getWorldPosition().getX() + ", y: " + getWorldPosition().getY() + ", z: " + getWorldPosition().getZ() + ").");
if (_activeObject instanceof Player)
{
((Player) _activeObject).teleToLocation(0, 0, 0);
((Player) _activeObject).sendMessage("Error with your coords, Please ask a GM for help!");
}
else if (_activeObject instanceof Creature)
{
_activeObject.decayMe();
}
}
}
/**
* Set the x,y,z position of the WorldObject and make it invisible.<br>
* <br>
* <b><u>Concept</u>:</b><br>
* <br>
* A WorldObject is invisble if <b>_hidden</b>=true or <b>_worldregion</b>==null<br>
* <br>
* <b><u>Assert</u>:</b><br>
* <li>_worldregion==null <i>(WorldObject is invisible)</i></li><br>
* <br>
* <b><u>Example of use</u>:</b><br>
* <li>Create a Door</li>
* <li>Restore Player</li><br>
* @param x the x
* @param y the y
* @param z the z
*/
public void setXYZInvisible(int x, int y, int z)
{
int correctX = x;
if (correctX > World.WORLD_X_MAX)
{
correctX = World.WORLD_X_MAX - 5000;
}
if (correctX < World.WORLD_X_MIN)
{
correctX = World.WORLD_X_MIN + 5000;
}
int correctY = y;
if (correctY > World.WORLD_Y_MAX)
{
correctY = World.WORLD_Y_MAX - 5000;
}
if (correctY < World.WORLD_Y_MIN)
{
correctY = World.WORLD_Y_MIN + 5000;
}
setWorldPosition(correctX, correctY, z);
_activeObject.setSpawned(false);
}
/**
* checks if current object changed its region, if so, update referencies.
*/
public void updateWorldRegion()
{
if (!_activeObject.isSpawned())
{
return;
}
final WorldRegion newRegion = World.getInstance().getRegion(getWorldPosition());
if (newRegion != getWorldRegion())
{
getWorldRegion().removeVisibleObject(_activeObject);
setWorldRegion(newRegion);
// Add the L2Oject spawn to _visibleObjects and if necessary to _allplayers of its WorldRegion
getWorldRegion().addVisibleObject(_activeObject);
}
}
/**
* Gets the active object.
* @return the active object
*/
public WorldObject getActiveObject()
{
return _activeObject;
}
/**
* Gets the heading.
* @return the heading
*/
public int getHeading()
{
return _heading;
}
/**
* Sets the heading.
* @param value the new heading
*/
public void setHeading(int value)
{
_heading = value;
}
/**
* Return the x position of the WorldObject.
* @return the x
*/
public int getX()
{
return getWorldPosition().getX();
}
/**
* Return the y position of the WorldObject.
* @return the y
*/
public int getY()
{
return getWorldPosition().getY();
}
/**
* Return the z position of the WorldObject.
* @return the z
*/
public int getZ()
{
return getWorldPosition().getZ();
}
/**
* Gets the world position.
* @return the world position
*/
public Location getWorldPosition()
{
if (_worldPosition == null)
{
_worldPosition = new Location(0, 0, 0);
}
return _worldPosition;
}
/**
* Sets the world position.
* @param x the x
* @param y the y
* @param z the z
*/
public void setWorldPosition(int x, int y, int z)
{
getWorldPosition().setXYZ(x, y, z);
}
/**
* Sets the world position.
* @param location the new world position
*/
public void setWorldPosition(Location location)
{
setWorldPosition(location.getX(), location.getY(), location.getZ());
}
/**
* Gets the world region.
* @return the world region
*/
public synchronized WorldRegion getWorldRegion()
{
return _worldRegion;
}
/**
* Sets the world region.
* @param value the new world region
*/
public synchronized void setWorldRegion(WorldRegion value)
{
_worldRegion = value;
}
}

View File

@ -46,10 +46,8 @@ public abstract class WorldObject
private WorldObjectKnownList _knownList;
private String _name = "";
private int _objectId;
private ObjectPosition _position;
// Objects can only see objects in same instancezone, instance 0 is normal world -1 the all seeing world
private int _instanceId = 0;
private WorldRegion _worldRegion;
private final Location _location = new Location(0, 0, -10000);
public WorldObject(int objectId)
{
@ -91,30 +89,127 @@ public abstract class WorldObject
{
}
// Position - Should remove to fully move to WorldObjectPosition
public void setXYZ(int x, int y, int z)
/**
* Checks if current object changed its region, if so, update references.
*/
public void updateWorldRegion()
{
getPosition().setXYZ(x, y, z);
if (!isSpawned())
{
return;
}
final WorldRegion newRegion = World.getInstance().getRegion(_location);
if (newRegion != getWorldRegion())
{
getWorldRegion().removeVisibleObject(this);
setWorldRegion(newRegion);
// Add the WorldOject spawn to _visibleObjects and if necessary to _allplayers of its WorldRegion.
getWorldRegion().addVisibleObject(this);
}
}
/**
* Set the x,y,z position of the WorldObject and if necessary modify its _worldRegion.<br>
* <br>
* <b><u>Assert</u>:</b><br>
* <li>_worldRegion != null</li><br>
* <br>
* <b><u>Example of use</u>:</b><br>
* <li>Update position during and after movement, or after teleport</li><br>
* @param x the x
* @param y the y
* @param z the z
*/
public void setXYZ(int x, int y, int z)
{
_location.setXYZ(x, y, z);
try
{
if (World.getInstance().getRegion(_location) != getWorldRegion())
{
updateWorldRegion();
}
}
catch (Exception e)
{
LOGGER.warning("Object Id at bad coords: (x: " + getX() + ", y: " + getY() + ", z: " + getZ() + ").");
if (isPlayer())
{
((Player) this).teleToLocation(0, 0, 0);
((Player) this).sendMessage("Error with your coords, Please ask a GM for help!");
}
else if (isCreature())
{
decayMe();
}
}
}
/**
* Set the x,y,z position of the WorldObject and make it invisible.<br>
* <br>
* <b><u>Concept</u>:</b><br>
* <br>
* A WorldObject is invisble if <b>_hidden</b>=true or <b>_worldregion</b>==null<br>
* <br>
* <b><u>Assert</u>:</b><br>
* <li>_worldregion==null <i>(WorldObject is invisible)</i></li><br>
* <br>
* <b><u>Example of use</u>:</b><br>
* <li>Create a Door</li>
* <li>Restore Player</li><br>
* @param x the x
* @param y the y
* @param z the z
*/
public void setXYZInvisible(int x, int y, int z)
{
getPosition().setXYZInvisible(x, y, z);
int correctX = x;
if (correctX > World.WORLD_X_MAX)
{
correctX = World.WORLD_X_MAX - 5000;
}
if (correctX < World.WORLD_X_MIN)
{
correctX = World.WORLD_X_MIN + 5000;
}
int correctY = y;
if (correctY > World.WORLD_Y_MAX)
{
correctY = World.WORLD_Y_MAX - 5000;
}
if (correctY < World.WORLD_Y_MIN)
{
correctY = World.WORLD_Y_MIN + 5000;
}
_location.setXYZ(correctX, correctY, z);
setSpawned(false);
}
public int getX()
{
return getPosition().getX();
return _location.getX();
}
public int getY()
{
return getPosition().getY();
return _location.getY();
}
public int getZ()
{
return getPosition().getZ();
return _location.getZ();
}
public int getHeading()
{
return _location.getHeading();
}
/**
@ -135,9 +230,9 @@ public abstract class WorldObject
{
// Remove the WorldObject from the world
_isSpawned = false;
World.getInstance().removeVisibleObject(this, getPosition().getWorldRegion());
World.getInstance().removeVisibleObject(this, getWorldRegion());
World.getInstance().removeObject(this);
getPosition().setWorldRegion(null);
setWorldRegion(null);
if (Config.SAVE_DROPPED_ITEM)
{
@ -163,7 +258,7 @@ public abstract class WorldObject
*/
public void pickupMe(Creature creature) // NOTE: Should move this function into Item because it does not apply to Creature
{
final WorldRegion oldregion = getPosition().getWorldRegion();
final WorldRegion oldregion = getWorldRegion();
// Create a server->client GetItem packet to pick up the Item
creature.broadcastPacket(new GetItem((Item) this, creature.getObjectId()));
@ -171,7 +266,7 @@ public abstract class WorldObject
synchronized (this)
{
_isSpawned = false;
getPosition().setWorldRegion(null);
setWorldRegion(null);
}
// if this item is a mercenary ticket, remove the spawns!
@ -219,18 +314,18 @@ public abstract class WorldObject
{
// Set the x,y,z position of the WorldObject spawn and update its _worldregion
_isSpawned = true;
getPosition().setWorldRegion(World.getInstance().getRegion(getPosition().getWorldPosition()));
setWorldRegion(World.getInstance().getRegion(getLocation()));
// Add the WorldObject spawn in the _allobjects of World
World.getInstance().storeObject(this);
// Add the WorldObject spawn to _visibleObjects and if necessary to _allplayers of its WorldRegion
getPosition().getWorldRegion().addVisibleObject(this);
getWorldRegion().addVisibleObject(this);
}
// this can synchronize on others instances, so it's out of synchronized, to avoid deadlocks
// Add the WorldObject spawn in the world as a visible object
World.getInstance().addVisibleObject(this, getPosition().getWorldRegion(), null);
World.getInstance().addVisibleObject(this, getWorldRegion(), null);
onSpawn();
}
@ -261,8 +356,8 @@ public abstract class WorldObject
spawnY = World.WORLD_Y_MIN + 5000;
}
getPosition().setWorldPosition(spawnX, spawnY, z);
getPosition().setWorldRegion(World.getInstance().getRegion(getPosition().getWorldPosition()));
_location.setXYZ(spawnX, spawnY, z);
setWorldRegion(World.getInstance().getRegion(getLocation()));
}
// these can synchronize on others instances, so they're out of synchronized, to avoid deadlocks
@ -270,7 +365,7 @@ public abstract class WorldObject
World.getInstance().storeObject(this);
// Add the WorldObject spawn to _visibleObjects and if necessary to _allplayers of its WorldRegion
final WorldRegion region = getPosition().getWorldRegion();
final WorldRegion region = getWorldRegion();
if (region != null)
{
region.addVisibleObject(this);
@ -302,7 +397,7 @@ public abstract class WorldObject
public boolean isSpawned()
{
return getPosition().getWorldRegion() != null;
return getWorldRegion() != null;
}
public void setSpawned(boolean value)
@ -310,7 +405,7 @@ public abstract class WorldObject
_isSpawned = value;
if (!_isSpawned)
{
getPosition().setWorldRegion(null);
setWorldRegion(null);
}
}
@ -343,26 +438,27 @@ public abstract class WorldObject
return _objectId;
}
public ObjectPosition getPosition()
{
if (_position == null)
{
_position = new ObjectPosition(this);
}
return _position;
}
public Location getLocation()
{
return getPosition().getWorldPosition();
return _location;
}
/**
* @return reference to region this object is in
* Gets the world region.
* @return the world region
*/
public WorldRegion getWorldRegion()
public synchronized WorldRegion getWorldRegion()
{
return getPosition().getWorldRegion();
return _worldRegion;
}
/**
* Sets the world region.
* @param value the new world region
*/
public synchronized void setWorldRegion(WorldRegion value)
{
_worldRegion = value;
}
/**
@ -370,7 +466,7 @@ public abstract class WorldObject
*/
public int getInstanceId()
{
return _instanceId;
return _location.getInstanceId();
}
/**
@ -378,7 +474,7 @@ public abstract class WorldObject
*/
public void setInstanceId(int instanceId)
{
_instanceId = instanceId;
_location.setInstanceId(instanceId);
// If we change it for visible objects, me must clear & revalidates knownlists
if (_isSpawned && (_knownList != null))
@ -575,6 +671,6 @@ public abstract class WorldObject
@Override
public String toString()
{
return "" + _objectId;
return getClass().getSimpleName() + ":" + _name + "[" + _objectId + "]";
}
}

View File

@ -52,7 +52,6 @@ import org.l2jmobius.gameserver.model.ChanceSkillList;
import org.l2jmobius.gameserver.model.Effect;
import org.l2jmobius.gameserver.model.ForceBuff;
import org.l2jmobius.gameserver.model.Location;
import org.l2jmobius.gameserver.model.ObjectPosition;
import org.l2jmobius.gameserver.model.Party;
import org.l2jmobius.gameserver.model.Skill;
import org.l2jmobius.gameserver.model.Skill.SkillTargetType;
@ -72,8 +71,8 @@ import org.l2jmobius.gameserver.model.actor.instance.NpcWalker;
import org.l2jmobius.gameserver.model.actor.instance.Pet;
import org.l2jmobius.gameserver.model.actor.instance.RaidBoss;
import org.l2jmobius.gameserver.model.actor.instance.RiftInvader;
import org.l2jmobius.gameserver.model.actor.instance.SiegeFlag;
import org.l2jmobius.gameserver.model.actor.instance.Servitor;
import org.l2jmobius.gameserver.model.actor.instance.SiegeFlag;
import org.l2jmobius.gameserver.model.actor.knownlist.CreatureKnownList;
import org.l2jmobius.gameserver.model.actor.stat.CreatureStat;
import org.l2jmobius.gameserver.model.actor.status.CreatureStatus;
@ -320,10 +319,10 @@ public abstract class Creature extends WorldObject implements ISkillsHolder
return;
}
final ObjectPosition pos = getPosition();
final Location pos = getLocation();
if (pos != null)
{
spawnMe(getPosition().getX(), getPosition().getY(), getPosition().getZ());
spawnMe(pos.getX(), pos.getY(), pos.getZ());
}
setTeleporting(false);
@ -563,7 +562,7 @@ public abstract class Creature extends WorldObject implements ISkillsHolder
broadcastPacket(new TeleportToLocation(this, x, y, z, getHeading()));
// Set the x,y,z position of the WorldObject and if necessary modify its _worldRegion.
getPosition().setXYZ(x, y, z);
getLocation().setXYZ(x, y, z);
if (!isPlayer())
{
@ -865,7 +864,7 @@ public abstract class Creature extends WorldObject implements ISkillsHolder
// Mobius: Do not move when attack is launched.
if (isMoving())
{
stopMove(getPosition().getWorldPosition());
stopMove(getLocation());
}
// Get the Attack Speed of the Creature (delay (in milliseconds) before next attack)
@ -4221,8 +4220,8 @@ public abstract class Creature extends WorldObject implements ISkillsHolder
* <br>
* <b><u>Concept</u>:</b><br>
* <br>
* A Creature owns a table of Calculators called <b>_calculators</b>. Each Calculator (a calculator per state) own a table of Func object. A Func object is a mathematic function that permit to calculate the modifier of a state (ex : REGENERATE_HP_RATE...). To reduce cache memory use,
* Npcs who don't have skills share the same Calculator set called <b>NPC_STD_CALCULATOR</b>.<br>
* A Creature owns a table of Calculators called <b>_calculators</b>. Each Calculator (a calculator per state) own a table of Func object. A Func object is a mathematic function that permit to calculate the modifier of a state (ex : REGENERATE_HP_RATE...). To reduce cache memory use, Npcs who
* don't have skills share the same Calculator set called <b>NPC_STD_CALCULATOR</b>.<br>
* That's why, if a Npc is under a skill/spell effect that modify one of its state, a copy of the NPC_STD_CALCULATOR must be create in its _calculators before addind new Func object.<br>
* <br>
* <b><u>Actions</u>:</b><br>
@ -4292,8 +4291,8 @@ public abstract class Creature extends WorldObject implements ISkillsHolder
* <br>
* <b><u>Concept</u>:</b><br>
* <br>
* A Creature owns a table of Calculators called <b>_calculators</b>. Each Calculator (a calculator per state) own a table of Func object. A Func object is a mathematic function that permit to calculate the modifier of a state (ex : REGENERATE_HP_RATE...). To reduce cache memory use,
* Npcs who don't have skills share the same Calculator set called <b>NPC_STD_CALCULATOR</b>.<br>
* A Creature owns a table of Calculators called <b>_calculators</b>. Each Calculator (a calculator per state) own a table of Func object. A Func object is a mathematic function that permit to calculate the modifier of a state (ex : REGENERATE_HP_RATE...). To reduce cache memory use, Npcs who
* don't have skills share the same Calculator set called <b>NPC_STD_CALCULATOR</b>.<br>
* That's why, if a Npc is under a skill/spell effect that modify one of its state, a copy of the NPC_STD_CALCULATOR must be create in its _calculators before addind new Func object.<br>
* <br>
* <b><u>Actions</u>:</b><br>
@ -4371,8 +4370,8 @@ public abstract class Creature extends WorldObject implements ISkillsHolder
* <br>
* <b><u>Concept</u>:</b><br>
* <br>
* A Creature owns a table of Calculators called <b>_calculators</b>. Each Calculator (a calculator per state) own a table of Func object. A Func object is a mathematic function that permit to calculate the modifier of a state (ex : REGENERATE_HP_RATE...). To reduce cache memory use,
* Npcs who don't have skills share the same Calculator set called <b>NPC_STD_CALCULATOR</b>.<br>
* A Creature owns a table of Calculators called <b>_calculators</b>. Each Calculator (a calculator per state) own a table of Func object. A Func object is a mathematic function that permit to calculate the modifier of a state (ex : REGENERATE_HP_RATE...). To reduce cache memory use, Npcs who
* don't have skills share the same Calculator set called <b>NPC_STD_CALCULATOR</b>.<br>
* That's why, if a Npc is under a skill/spell effect that modify one of its state, a copy of the NPC_STD_CALCULATOR must be create in its _calculators before addind new Func object.<br>
* <br>
* <b><u>Actions</u>:</b><br>
@ -4567,6 +4566,7 @@ public abstract class Creature extends WorldObject implements ISkillsHolder
* Return the orientation of the Creature.
* @return the heading
*/
@Override
public int getHeading()
{
return _heading;
@ -5050,7 +5050,7 @@ public abstract class Creature extends WorldObject implements ISkillsHolder
// All data are contained in a CharPosition object
if (pos != null)
{
getPosition().setXYZ(pos.getX(), pos.getY(), pos.getZ());
getLocation().setXYZ(pos.getX(), pos.getY(), pos.getZ());
setHeading(pos.getHeading());
if (this instanceof Player)

View File

@ -12128,7 +12128,7 @@ public class Player extends Playable
if (getTrainedBeast() != null)
{
getTrainedBeast().getAI().stopFollow();
getTrainedBeast().teleToLocation(getPosition().getX() + Rnd.get(-100, 100), getPosition().getY() + Rnd.get(-100, 100), getPosition().getZ());
getTrainedBeast().teleToLocation(getLocation().getX() + Rnd.get(-100, 100), getLocation().getY() + Rnd.get(-100, 100), getLocation().getZ());
getTrainedBeast().getAI().startFollow(this);
}

View File

@ -87,7 +87,7 @@ public class Boat extends Creature
final MoveData m = new MoveData();
// Calculate and set the heading of the Creature
getPosition().setHeading((int) (Math.atan2(-sin, -cos) * 10430.378350470452724949566316381) + 32768);
getLocation().setHeading((int) (Math.atan2(-sin, -cos) * 10430.378350470452724949566316381) + 32768);
m._xDestination = x;
m._yDestination = y;
m._zDestination = z; // this is what was requested from client

View File

@ -179,7 +179,7 @@ public class PlayerKnownList extends PlayableKnownList
final Player otherPlayer = (Player) object;
if (otherPlayer.isInBoat())
{
otherPlayer.getPosition().setWorldPosition(otherPlayer.getBoat().getLocation());
otherPlayer.getLocation().setLocation(otherPlayer.getBoat().getLocation());
activeChar.sendPacket(new CharInfo(otherPlayer, activeChar.isGM() && otherPlayer.getAppearance().isInvisible()));
final int relation = otherPlayer.getRelation(activeChar);

View File

@ -80,7 +80,7 @@ public class BoatPathHolder
final double distance = Math.sqrt((dx * dx) + (dy * dy));
final double cos = dx / distance;
final double sin = dy / distance;
boat.getPosition().setHeading((int) (Math.atan2(-sin, -cos) * 10430.378350470452724949566316381) + 32768);
boat.getLocation().setHeading((int) (Math.atan2(-sin, -cos) * 10430.378350470452724949566316381) + 32768);
boat.vd = new VehicleDeparture(boat, path.speed1, path.speed2, path.x, path.y, path.z);
boat.boatSpeed = path.speed1;
boat.moveToLocation(path.x, path.y, path.z, path.speed1);

View File

@ -1056,18 +1056,18 @@ public class Item extends WorldObject
{
// Set the x,y,z position of the Item dropped and update its _worldregion
setSpawned(true);
getPosition().setWorldPosition(x, y, z);
getPosition().setWorldRegion(World.getInstance().getRegion(getPosition().getWorldPosition()));
getLocation().setXYZ(x, y, z);
setWorldRegion(World.getInstance().getRegion(getLocation()));
// Add the Item dropped to _visibleObjects of its WorldRegion
getPosition().getWorldRegion().addVisibleObject(this);
getWorldRegion().addVisibleObject(this);
}
setDropTime(Chronos.currentTimeMillis());
// this can synchronize on others instancies, so it's out of synchronized, to avoid deadlocks
// Add the Item dropped in the world as a visible object
World.getInstance().addVisibleObject(this, getPosition().getWorldRegion(), dropper);
World.getInstance().addVisibleObject(this, getWorldRegion(), dropper);
if (Config.SAVE_DROPPED_ITEM)
{
ItemsOnGroundManager.getInstance().save(this);

View File

@ -48,8 +48,8 @@ import org.l2jmobius.gameserver.model.sevensigns.SevenSigns;
import org.l2jmobius.gameserver.model.sevensigns.SevenSignsFestival;
import org.l2jmobius.gameserver.model.siege.Siege;
import org.l2jmobius.gameserver.model.skill.conditions.ConditionPlayerState;
import org.l2jmobius.gameserver.model.skill.conditions.ConditionUsingItemType;
import org.l2jmobius.gameserver.model.skill.conditions.ConditionPlayerState.CheckPlayerState;
import org.l2jmobius.gameserver.model.skill.conditions.ConditionUsingItemType;
import org.l2jmobius.gameserver.model.skill.effects.EffectTemplate;
import org.l2jmobius.gameserver.model.skill.funcs.Func;
import org.l2jmobius.gameserver.model.zone.ZoneId;
@ -1201,7 +1201,7 @@ public class Formulas
return 0;
}
final Siege siege = SiegeManager.getInstance().getSiege(player.getPosition().getX(), player.getPosition().getY(), player.getPosition().getZ());
final Siege siege = SiegeManager.getInstance().getSiege(player.getX(), player.getY(), player.getZ());
if ((siege == null) || !siege.isInProgress())
{
return 0;

View File

@ -56,7 +56,7 @@ public class CannotMoveAnymoreInVehicle implements IClientIncomingPacket
if (player.isInBoat() && (player.getBoat().getObjectId() == _boatId))
{
player.setBoatPosition(new Location(_x, _y, _z));
player.getPosition().setHeading(_heading);
player.setHeading(_heading);
player.broadcastPacket(new StopMoveInVehicle(player, _boatId));
}
}

View File

@ -57,7 +57,7 @@ public class RequestGetOnVehicle implements IClientIncomingPacket
}
player.setBoatPosition(new Location(_x, _y, _z));
player.setXYZ(boat.getPosition().getX(), boat.getPosition().getY(), boat.getPosition().getZ());
player.setXYZ(boat.getLocation().getX(), boat.getLocation().getY(), boat.getLocation().getZ());
player.broadcastPacket(new GetOnVehicle(player, boat, _x, _y, _z));
player.revalidateZone(true);
}

View File

@ -125,7 +125,7 @@ public class RequestRecordInfo implements IClientIncomingPacket
final Player otherPlayer = (Player) object;
if (otherPlayer.isInBoat())
{
otherPlayer.getPosition().setWorldPosition(otherPlayer.getBoat().getLocation());
otherPlayer.getLocation().setLocation(otherPlayer.getBoat().getLocation());
player.sendPacket(new CharInfo(otherPlayer, player.isGM() && otherPlayer.getAppearance().isInvisible()));
final int relation = otherPlayer.getRelation(player);
if ((otherPlayer.getKnownList().getKnownRelations().get(player.getObjectId()) != null) && (otherPlayer.getKnownList().getKnownRelations().get(player.getObjectId()) != relation))

View File

@ -28,9 +28,9 @@ public class FakePlayerInfo implements IClientOutgoingPacket
public FakePlayerInfo(Npc cha)
{
_activeChar = cha;
_activeChar.setClientX(_activeChar.getPosition().getX());
_activeChar.setClientY(_activeChar.getPosition().getY());
_activeChar.setClientZ(_activeChar.getPosition().getZ());
_activeChar.setClientX(_activeChar.getX());
_activeChar.setClientY(_activeChar.getY());
_activeChar.setClientZ(_activeChar.getZ());
}
@Override

View File

@ -52,7 +52,7 @@ public class OnVehicleCheckLocation implements IClientOutgoingPacket
packet.writeD(_x);
packet.writeD(_y);
packet.writeD(_z);
packet.writeD(_boat.getPosition().getHeading());
packet.writeD(_boat.getHeading());
return true;
}
}

View File

@ -23,6 +23,8 @@ import org.l2jmobius.gameserver.network.OutgoingPackets;
public class PlaySound implements IClientOutgoingPacket
{
private static final Location DUMMY_LOC = new Location(0, 0, 0);
private final int _unknown;
private final String _soundFile;
private final boolean _isObject;
@ -40,7 +42,7 @@ public class PlaySound implements IClientOutgoingPacket
_soundFile = soundFile;
_isObject = false;
_objectId = 0;
_loc = Location.DUMMY_LOC;
_loc = DUMMY_LOC;
_duration = 0;
}
@ -55,7 +57,7 @@ public class PlaySound implements IClientOutgoingPacket
_soundFile = soundFile;
_isObject = false;
_objectId = 0;
_loc = Location.DUMMY_LOC;
_loc = DUMMY_LOC;
_duration = 0;
}

View File

@ -47,7 +47,7 @@ public class StopMoveInVehicle implements IClientOutgoingPacket
packet.writeD(_player.getBoatPosition().getX());
packet.writeD(_player.getBoatPosition().getY());
packet.writeD(_player.getBoatPosition().getZ());
packet.writeD(_player.getPosition().getHeading());
packet.writeD(_player.getHeading());
return true;
}
}

View File

@ -43,7 +43,7 @@ public class VehicleInfo implements IClientOutgoingPacket
packet.writeD(_boat.getX());
packet.writeD(_boat.getY());
packet.writeD(_boat.getZ());
packet.writeD(_boat.getPosition().getHeading());
packet.writeD(_boat.getHeading());
return true;
}
}

View File

@ -114,7 +114,7 @@ public class Util
{
return 1000000;
}
return calculateDistance(obj1.getPosition().getX(), obj1.getPosition().getY(), obj1.getPosition().getZ(), obj2.getPosition().getX(), obj2.getPosition().getY(), obj2.getPosition().getZ(), includeZAxis);
return calculateDistance(obj1.getX(), obj1.getY(), obj1.getZ(), obj2.getX(), obj2.getY(), obj2.getZ(), includeZAxis);
}
/**

View File

@ -123,7 +123,7 @@ public class BoatData implements IXmlReader
final CreatureTemplate template = new CreatureTemplate(npcDat);
final Boat boat = new Boat(IdManager.getInstance().getNextId(), template);
boat.getPosition().setHeading(set.getInt("heading"));
boat.getLocation().setHeading(set.getInt("heading"));
boat.setXYZ(set.getInt("spawnX"), set.getInt("spawnY"), set.getInt("spawnZ"));
boat.setPathA(set.getInt("pathIdA"), set.getInt("ticketA"), set.getInt("xTeleNoTicketA"), set.getInt("yTeleNoTicketA"), set.getInt("zTeleNoTicketA"), set.getString("announcerA"), set.getString("message10A"), set.getString("message5A"), set.getString("message1A"), set.getString("message0A"), set.getString("messageBeginA"), paths.get(set.getInt("pathIdA")));
boat.setPathB(set.getInt("pathIdB"), set.getInt("ticketB"), set.getInt("xTeleNoTicketB"), set.getInt("yTeleNoTicketB"), set.getInt("zTeleNoTicketB"), set.getString("announcerB"), set.getString("message10B"), set.getString("message5B"), set.getString("message1B"), set.getString("message0B"), set.getString("messageBeginB"), paths.get(set.getInt("pathIdB")));

View File

@ -127,13 +127,13 @@ public class ItemsOnGroundManager
item.setEnchantLevel(result.getInt(4));
}
item.getPosition().setWorldPosition(result.getInt(5), result.getInt(6), result.getInt(7));
item.getPosition().setWorldRegion(World.getInstance().getRegion(item.getLocation()));
item.getPosition().getWorldRegion().addVisibleObject(item);
item.setXYZ(result.getInt(5), result.getInt(6), result.getInt(7));
item.setWorldRegion(World.getInstance().getRegion(item.getLocation()));
item.getWorldRegion().addVisibleObject(item);
item.setDropTime(result.getLong(8));
item.setProtected(result.getLong(8) == -1);
item.setSpawned(true);
World.getInstance().addVisibleObject(item, item.getPosition().getWorldRegion(), null);
World.getInstance().addVisibleObject(item, item.getWorldRegion(), null);
_items.add(item);
count++;
// add to ItemsAutoDestroy only items not protected

View File

@ -25,16 +25,16 @@ import org.l2jmobius.commons.util.Point2D;
*/
public class Location extends Point2D
{
public static final Location DUMMY_LOC = new Location(0, 0, 0);
protected volatile int _z;
protected volatile int _heading;
protected volatile int _instanceId;
public Location(int x, int y, int z)
{
super(x, y);
_z = z;
_heading = 0;
_instanceId = 0;
}
public Location(int x, int y, int z, int heading)
@ -42,11 +42,12 @@ public class Location extends Point2D
super(x, y);
_z = z;
_heading = heading;
_instanceId = 0;
}
public Location(WorldObject obj)
{
this(obj.getX(), obj.getY(), obj.getZ(), obj.getPosition().getHeading(), obj.getInstanceId());
this(obj.getX(), obj.getY(), obj.getZ(), obj.getHeading(), obj.getInstanceId());
}
public Location(int x, int y, int z, int heading, int instanceId)
@ -54,6 +55,7 @@ public class Location extends Point2D
super(x, y);
_z = z;
_heading = heading;
_instanceId = instanceId;
}
public Location(StatSet set)
@ -61,6 +63,7 @@ public class Location extends Point2D
super(set.getInt("x", 0), set.getInt("y", 0));
_z = set.getInt("z", 0);
_heading = set.getInt("heading", 0);
_instanceId = set.getInt("instanceId", 0);
}
/**
@ -132,12 +135,36 @@ public class Location extends Point2D
_heading = heading;
}
/**
* Get the instance Id.
* @return the instance Id
*/
public int getInstanceId()
{
return _instanceId;
}
/**
* Set the instance Id.
* @param instanceId the instance Id to set
*/
public void setInstanceId(int instanceId)
{
_instanceId = instanceId;
}
public Location getLocation()
{
return this;
}
public void setLocation(Location loc)
{
_x = loc.getX();
_y = loc.getY();
_z = loc.getZ();
_heading = loc.getHeading();
_instanceId = loc.getInstanceId();
}
@Override
@ -145,12 +172,13 @@ public class Location extends Point2D
{
super.clean();
_z = 0;
_instanceId = 0;
}
@Override
public Location clone()
{
return new Location(_x, _y, _z);
return new Location(_x, _y, _z, _heading, _instanceId);
}
@Override
@ -159,31 +187,31 @@ public class Location extends Point2D
return (31 * super.hashCode()) + Objects.hash(_z);
}
@Override
public boolean equals(Object obj)
{
if (obj instanceof Location)
{
final Location loc = (Location) obj;
return (getX() == loc.getX()) && (getY() == loc.getY()) && (getZ() == loc.getZ()) && (getHeading() == loc.getHeading()) && (getInstanceId() == loc.getInstanceId());
}
return false;
}
/**
* @param x : The X coord to test.
* @param y : The Y coord to test.
* @param z : The X coord to test.
* @return True if all coordinates equals this {@link Point2D} coordinates.
* @param z : The Z coord to test.
* @return True if all coordinates equals this {@link Location} coordinates.
*/
public boolean equals(int x, int y, int z)
{
return (_x == x) && (_y == y) && (_z == z);
}
@Override
public boolean equals(Object obj)
{
if (obj instanceof Location)
{
final Location loc = (Location) obj;
return (getX() == loc.getX()) && (getY() == loc.getY()) && (getZ() == loc.getZ()) && (getHeading() == loc.getHeading());
}
return false;
}
@Override
public String toString()
{
return "[" + getClass().getSimpleName() + "] X: " + _x + " Y: " + _y + " Z: " + _z + " Heading: " + _heading;
return "[" + getClass().getSimpleName() + "] X: " + _x + " Y: " + _y + " Z: " + _z + " Heading: " + _heading + " InstanceId: " + _instanceId;
}
}

View File

@ -1,250 +0,0 @@
/*
* This file is part of the L2J Mobius project.
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package org.l2jmobius.gameserver.model;
import java.util.logging.Logger;
import org.l2jmobius.gameserver.model.actor.Creature;
import org.l2jmobius.gameserver.model.actor.Player;
public class ObjectPosition
{
private static final Logger LOGGER = Logger.getLogger(ObjectPosition.class.getName());
private final WorldObject _activeObject;
private int _heading = 0;
private Location _worldPosition;
private WorldRegion _worldRegion; // Object localization : Used for items/chars that are seen in the world
/**
* Instantiates a new object position.
* @param activeObject the active object
*/
public ObjectPosition(WorldObject activeObject)
{
_activeObject = activeObject;
setWorldRegion(World.getInstance().getRegion(getWorldPosition()));
}
/**
* Set the x,y,z position of the WorldObject and if necessary modify its _worldRegion.<br>
* <br>
* <b><u>Assert</u>:</b><br>
* <li>_worldRegion != null</li><br>
* <br>
* <b><u>Example of use</u>:</b><br>
* <li>Update position during and after movement, or after teleport</li><br>
* @param x the x
* @param y the y
* @param z the z
*/
public void setXYZ(int x, int y, int z)
{
setWorldPosition(x, y, z);
try
{
if (World.getInstance().getRegion(getWorldPosition()) != getWorldRegion())
{
updateWorldRegion();
}
}
catch (Exception e)
{
LOGGER.warning("Object Id at bad coords: (x: " + getWorldPosition().getX() + ", y: " + getWorldPosition().getY() + ", z: " + getWorldPosition().getZ() + ").");
if (_activeObject instanceof Player)
{
((Player) _activeObject).teleToLocation(0, 0, 0);
((Player) _activeObject).sendMessage("Error with your coords, Please ask a GM for help!");
}
else if (_activeObject instanceof Creature)
{
_activeObject.decayMe();
}
}
}
/**
* Set the x,y,z position of the WorldObject and make it invisible.<br>
* <br>
* <b><u>Concept</u>:</b><br>
* <br>
* A WorldObject is invisble if <b>_hidden</b>=true or <b>_worldregion</b>==null<br>
* <br>
* <b><u>Assert</u>:</b><br>
* <li>_worldregion==null <i>(WorldObject is invisible)</i></li><br>
* <br>
* <b><u>Example of use</u>:</b><br>
* <li>Create a Door</li>
* <li>Restore Player</li><br>
* @param x the x
* @param y the y
* @param z the z
*/
public void setXYZInvisible(int x, int y, int z)
{
int correctX = x;
if (correctX > World.WORLD_X_MAX)
{
correctX = World.WORLD_X_MAX - 5000;
}
if (correctX < World.WORLD_X_MIN)
{
correctX = World.WORLD_X_MIN + 5000;
}
int correctY = y;
if (correctY > World.WORLD_Y_MAX)
{
correctY = World.WORLD_Y_MAX - 5000;
}
if (correctY < World.WORLD_Y_MIN)
{
correctY = World.WORLD_Y_MIN + 5000;
}
setWorldPosition(correctX, correctY, z);
_activeObject.setSpawned(false);
}
/**
* checks if current object changed its region, if so, update referencies.
*/
public void updateWorldRegion()
{
if (!_activeObject.isSpawned())
{
return;
}
final WorldRegion newRegion = World.getInstance().getRegion(getWorldPosition());
if (newRegion != getWorldRegion())
{
getWorldRegion().removeVisibleObject(_activeObject);
setWorldRegion(newRegion);
// Add the L2Oject spawn to _visibleObjects and if necessary to _allplayers of its WorldRegion
getWorldRegion().addVisibleObject(_activeObject);
}
}
/**
* Gets the active object.
* @return the active object
*/
public WorldObject getActiveObject()
{
return _activeObject;
}
/**
* Gets the heading.
* @return the heading
*/
public int getHeading()
{
return _heading;
}
/**
* Sets the heading.
* @param value the new heading
*/
public void setHeading(int value)
{
_heading = value;
}
/**
* Return the x position of the WorldObject.
* @return the x
*/
public int getX()
{
return getWorldPosition().getX();
}
/**
* Return the y position of the WorldObject.
* @return the y
*/
public int getY()
{
return getWorldPosition().getY();
}
/**
* Return the z position of the WorldObject.
* @return the z
*/
public int getZ()
{
return getWorldPosition().getZ();
}
/**
* Gets the world position.
* @return the world position
*/
public Location getWorldPosition()
{
if (_worldPosition == null)
{
_worldPosition = new Location(0, 0, 0);
}
return _worldPosition;
}
/**
* Sets the world position.
* @param x the x
* @param y the y
* @param z the z
*/
public void setWorldPosition(int x, int y, int z)
{
getWorldPosition().setXYZ(x, y, z);
}
/**
* Sets the world position.
* @param location the new world position
*/
public void setWorldPosition(Location location)
{
setWorldPosition(location.getX(), location.getY(), location.getZ());
}
/**
* Gets the world region.
* @return the world region
*/
public synchronized WorldRegion getWorldRegion()
{
return _worldRegion;
}
/**
* Sets the world region.
* @param value the new world region
*/
public synchronized void setWorldRegion(WorldRegion value)
{
_worldRegion = value;
}
}

View File

@ -46,10 +46,8 @@ public abstract class WorldObject
private WorldObjectKnownList _knownList;
private String _name = "";
private int _objectId;
private ObjectPosition _position;
// Objects can only see objects in same instancezone, instance 0 is normal world -1 the all seeing world
private int _instanceId = 0;
private WorldRegion _worldRegion;
private final Location _location = new Location(0, 0, -10000);
public WorldObject(int objectId)
{
@ -91,30 +89,127 @@ public abstract class WorldObject
{
}
// Position - Should remove to fully move to WorldObjectPosition
public void setXYZ(int x, int y, int z)
/**
* Checks if current object changed its region, if so, update references.
*/
public void updateWorldRegion()
{
getPosition().setXYZ(x, y, z);
if (!isSpawned())
{
return;
}
final WorldRegion newRegion = World.getInstance().getRegion(_location);
if (newRegion != getWorldRegion())
{
getWorldRegion().removeVisibleObject(this);
setWorldRegion(newRegion);
// Add the WorldOject spawn to _visibleObjects and if necessary to _allplayers of its WorldRegion.
getWorldRegion().addVisibleObject(this);
}
}
/**
* Set the x,y,z position of the WorldObject and if necessary modify its _worldRegion.<br>
* <br>
* <b><u>Assert</u>:</b><br>
* <li>_worldRegion != null</li><br>
* <br>
* <b><u>Example of use</u>:</b><br>
* <li>Update position during and after movement, or after teleport</li><br>
* @param x the x
* @param y the y
* @param z the z
*/
public void setXYZ(int x, int y, int z)
{
_location.setXYZ(x, y, z);
try
{
if (World.getInstance().getRegion(_location) != getWorldRegion())
{
updateWorldRegion();
}
}
catch (Exception e)
{
LOGGER.warning("Object Id at bad coords: (x: " + getX() + ", y: " + getY() + ", z: " + getZ() + ").");
if (isPlayer())
{
((Player) this).teleToLocation(0, 0, 0);
((Player) this).sendMessage("Error with your coords, Please ask a GM for help!");
}
else if (isCreature())
{
decayMe();
}
}
}
/**
* Set the x,y,z position of the WorldObject and make it invisible.<br>
* <br>
* <b><u>Concept</u>:</b><br>
* <br>
* A WorldObject is invisble if <b>_hidden</b>=true or <b>_worldregion</b>==null<br>
* <br>
* <b><u>Assert</u>:</b><br>
* <li>_worldregion==null <i>(WorldObject is invisible)</i></li><br>
* <br>
* <b><u>Example of use</u>:</b><br>
* <li>Create a Door</li>
* <li>Restore Player</li><br>
* @param x the x
* @param y the y
* @param z the z
*/
public void setXYZInvisible(int x, int y, int z)
{
getPosition().setXYZInvisible(x, y, z);
int correctX = x;
if (correctX > World.WORLD_X_MAX)
{
correctX = World.WORLD_X_MAX - 5000;
}
if (correctX < World.WORLD_X_MIN)
{
correctX = World.WORLD_X_MIN + 5000;
}
int correctY = y;
if (correctY > World.WORLD_Y_MAX)
{
correctY = World.WORLD_Y_MAX - 5000;
}
if (correctY < World.WORLD_Y_MIN)
{
correctY = World.WORLD_Y_MIN + 5000;
}
_location.setXYZ(correctX, correctY, z);
setSpawned(false);
}
public int getX()
{
return getPosition().getX();
return _location.getX();
}
public int getY()
{
return getPosition().getY();
return _location.getY();
}
public int getZ()
{
return getPosition().getZ();
return _location.getZ();
}
public int getHeading()
{
return _location.getHeading();
}
/**
@ -135,9 +230,9 @@ public abstract class WorldObject
{
// Remove the WorldObject from the world
_isSpawned = false;
World.getInstance().removeVisibleObject(this, getPosition().getWorldRegion());
World.getInstance().removeVisibleObject(this, getWorldRegion());
World.getInstance().removeObject(this);
getPosition().setWorldRegion(null);
setWorldRegion(null);
if (Config.SAVE_DROPPED_ITEM)
{
@ -163,7 +258,7 @@ public abstract class WorldObject
*/
public void pickupMe(Creature creature) // NOTE: Should move this function into Item because it does not apply to Creature
{
final WorldRegion oldregion = getPosition().getWorldRegion();
final WorldRegion oldregion = getWorldRegion();
// Create a server->client GetItem packet to pick up the Item
creature.broadcastPacket(new GetItem((Item) this, creature.getObjectId()));
@ -171,7 +266,7 @@ public abstract class WorldObject
synchronized (this)
{
_isSpawned = false;
getPosition().setWorldRegion(null);
setWorldRegion(null);
}
// if this item is a mercenary ticket, remove the spawns!
@ -219,18 +314,18 @@ public abstract class WorldObject
{
// Set the x,y,z position of the WorldObject spawn and update its _worldregion
_isSpawned = true;
getPosition().setWorldRegion(World.getInstance().getRegion(getPosition().getWorldPosition()));
setWorldRegion(World.getInstance().getRegion(getLocation()));
// Add the WorldObject spawn in the _allobjects of World
World.getInstance().storeObject(this);
// Add the WorldObject spawn to _visibleObjects and if necessary to _allplayers of its WorldRegion
getPosition().getWorldRegion().addVisibleObject(this);
getWorldRegion().addVisibleObject(this);
}
// this can synchronize on others instances, so it's out of synchronized, to avoid deadlocks
// Add the WorldObject spawn in the world as a visible object
World.getInstance().addVisibleObject(this, getPosition().getWorldRegion(), null);
World.getInstance().addVisibleObject(this, getWorldRegion(), null);
onSpawn();
}
@ -261,8 +356,8 @@ public abstract class WorldObject
spawnY = World.WORLD_Y_MIN + 5000;
}
getPosition().setWorldPosition(spawnX, spawnY, z);
getPosition().setWorldRegion(World.getInstance().getRegion(getPosition().getWorldPosition()));
_location.setXYZ(spawnX, spawnY, z);
setWorldRegion(World.getInstance().getRegion(getLocation()));
}
// these can synchronize on others instances, so they're out of synchronized, to avoid deadlocks
@ -270,7 +365,7 @@ public abstract class WorldObject
World.getInstance().storeObject(this);
// Add the WorldObject spawn to _visibleObjects and if necessary to _allplayers of its WorldRegion
final WorldRegion region = getPosition().getWorldRegion();
final WorldRegion region = getWorldRegion();
if (region != null)
{
region.addVisibleObject(this);
@ -302,7 +397,7 @@ public abstract class WorldObject
public boolean isSpawned()
{
return getPosition().getWorldRegion() != null;
return getWorldRegion() != null;
}
public void setSpawned(boolean value)
@ -310,7 +405,7 @@ public abstract class WorldObject
_isSpawned = value;
if (!_isSpawned)
{
getPosition().setWorldRegion(null);
setWorldRegion(null);
}
}
@ -343,26 +438,27 @@ public abstract class WorldObject
return _objectId;
}
public ObjectPosition getPosition()
{
if (_position == null)
{
_position = new ObjectPosition(this);
}
return _position;
}
public Location getLocation()
{
return getPosition().getWorldPosition();
return _location;
}
/**
* @return reference to region this object is in
* Gets the world region.
* @return the world region
*/
public WorldRegion getWorldRegion()
public synchronized WorldRegion getWorldRegion()
{
return getPosition().getWorldRegion();
return _worldRegion;
}
/**
* Sets the world region.
* @param value the new world region
*/
public synchronized void setWorldRegion(WorldRegion value)
{
_worldRegion = value;
}
/**
@ -370,7 +466,7 @@ public abstract class WorldObject
*/
public int getInstanceId()
{
return _instanceId;
return _location.getInstanceId();
}
/**
@ -378,7 +474,7 @@ public abstract class WorldObject
*/
public void setInstanceId(int instanceId)
{
_instanceId = instanceId;
_location.setInstanceId(instanceId);
// If we change it for visible objects, me must clear & revalidates knownlists
if (_isSpawned && (_knownList != null))
@ -575,6 +671,6 @@ public abstract class WorldObject
@Override
public String toString()
{
return "" + _objectId;
return getClass().getSimpleName() + ":" + _name + "[" + _objectId + "]";
}
}

View File

@ -54,7 +54,6 @@ import org.l2jmobius.gameserver.model.Duel;
import org.l2jmobius.gameserver.model.Effect;
import org.l2jmobius.gameserver.model.ForceBuff;
import org.l2jmobius.gameserver.model.Location;
import org.l2jmobius.gameserver.model.ObjectPosition;
import org.l2jmobius.gameserver.model.Party;
import org.l2jmobius.gameserver.model.Skill;
import org.l2jmobius.gameserver.model.Skill.SkillTargetType;
@ -74,8 +73,8 @@ import org.l2jmobius.gameserver.model.actor.instance.NpcWalker;
import org.l2jmobius.gameserver.model.actor.instance.Pet;
import org.l2jmobius.gameserver.model.actor.instance.RaidBoss;
import org.l2jmobius.gameserver.model.actor.instance.RiftInvader;
import org.l2jmobius.gameserver.model.actor.instance.SiegeFlag;
import org.l2jmobius.gameserver.model.actor.instance.Servitor;
import org.l2jmobius.gameserver.model.actor.instance.SiegeFlag;
import org.l2jmobius.gameserver.model.actor.knownlist.CreatureKnownList;
import org.l2jmobius.gameserver.model.actor.stat.CreatureStat;
import org.l2jmobius.gameserver.model.actor.status.CreatureStatus;
@ -322,10 +321,10 @@ public abstract class Creature extends WorldObject implements ISkillsHolder
return;
}
final ObjectPosition pos = getPosition();
final Location pos = getLocation();
if (pos != null)
{
spawnMe(getPosition().getX(), getPosition().getY(), getPosition().getZ());
spawnMe(pos.getX(), pos.getY(), pos.getZ());
}
setTeleporting(false);
@ -565,7 +564,7 @@ public abstract class Creature extends WorldObject implements ISkillsHolder
broadcastPacket(new TeleportToLocation(this, x, y, z, getHeading()));
// Set the x,y,z position of the WorldObject and if necessary modify its _worldRegion.
getPosition().setXYZ(x, y, z);
getLocation().setXYZ(x, y, z);
if (!isPlayer())
{
@ -891,7 +890,7 @@ public abstract class Creature extends WorldObject implements ISkillsHolder
// Mobius: Do not move when attack is launched.
if (isMoving())
{
stopMove(getPosition().getWorldPosition());
stopMove(getLocation());
}
// Get the Attack Speed of the Creature (delay (in milliseconds) before next attack)
@ -4267,8 +4266,8 @@ public abstract class Creature extends WorldObject implements ISkillsHolder
* <br>
* <b><u>Concept</u>:</b><br>
* <br>
* A Creature owns a table of Calculators called <b>_calculators</b>. Each Calculator (a calculator per state) own a table of Func object. A Func object is a mathematic function that permit to calculate the modifier of a state (ex : REGENERATE_HP_RATE...). To reduce cache memory use,
* Npcs who don't have skills share the same Calculator set called <b>NPC_STD_CALCULATOR</b>.<br>
* A Creature owns a table of Calculators called <b>_calculators</b>. Each Calculator (a calculator per state) own a table of Func object. A Func object is a mathematic function that permit to calculate the modifier of a state (ex : REGENERATE_HP_RATE...). To reduce cache memory use, Npcs who
* don't have skills share the same Calculator set called <b>NPC_STD_CALCULATOR</b>.<br>
* That's why, if a Npc is under a skill/spell effect that modify one of its state, a copy of the NPC_STD_CALCULATOR must be create in its _calculators before addind new Func object.<br>
* <br>
* <b><u>Actions</u>:</b><br>
@ -4338,8 +4337,8 @@ public abstract class Creature extends WorldObject implements ISkillsHolder
* <br>
* <b><u>Concept</u>:</b><br>
* <br>
* A Creature owns a table of Calculators called <b>_calculators</b>. Each Calculator (a calculator per state) own a table of Func object. A Func object is a mathematic function that permit to calculate the modifier of a state (ex : REGENERATE_HP_RATE...). To reduce cache memory use,
* Npcs who don't have skills share the same Calculator set called <b>NPC_STD_CALCULATOR</b>.<br>
* A Creature owns a table of Calculators called <b>_calculators</b>. Each Calculator (a calculator per state) own a table of Func object. A Func object is a mathematic function that permit to calculate the modifier of a state (ex : REGENERATE_HP_RATE...). To reduce cache memory use, Npcs who
* don't have skills share the same Calculator set called <b>NPC_STD_CALCULATOR</b>.<br>
* That's why, if a Npc is under a skill/spell effect that modify one of its state, a copy of the NPC_STD_CALCULATOR must be create in its _calculators before addind new Func object.<br>
* <br>
* <b><u>Actions</u>:</b><br>
@ -4417,8 +4416,8 @@ public abstract class Creature extends WorldObject implements ISkillsHolder
* <br>
* <b><u>Concept</u>:</b><br>
* <br>
* A Creature owns a table of Calculators called <b>_calculators</b>. Each Calculator (a calculator per state) own a table of Func object. A Func object is a mathematic function that permit to calculate the modifier of a state (ex : REGENERATE_HP_RATE...). To reduce cache memory use,
* Npcs who don't have skills share the same Calculator set called <b>NPC_STD_CALCULATOR</b>.<br>
* A Creature owns a table of Calculators called <b>_calculators</b>. Each Calculator (a calculator per state) own a table of Func object. A Func object is a mathematic function that permit to calculate the modifier of a state (ex : REGENERATE_HP_RATE...). To reduce cache memory use, Npcs who
* don't have skills share the same Calculator set called <b>NPC_STD_CALCULATOR</b>.<br>
* That's why, if a Npc is under a skill/spell effect that modify one of its state, a copy of the NPC_STD_CALCULATOR must be create in its _calculators before addind new Func object.<br>
* <br>
* <b><u>Actions</u>:</b><br>
@ -4613,6 +4612,7 @@ public abstract class Creature extends WorldObject implements ISkillsHolder
* Return the orientation of the Creature.
* @return the heading
*/
@Override
public int getHeading()
{
return _heading;
@ -5096,7 +5096,7 @@ public abstract class Creature extends WorldObject implements ISkillsHolder
// All data are contained in a CharPosition object
if (pos != null)
{
getPosition().setXYZ(pos.getX(), pos.getY(), pos.getZ());
getLocation().setXYZ(pos.getX(), pos.getY(), pos.getZ());
setHeading(pos.getHeading());
if (this instanceof Player)

View File

@ -12433,7 +12433,7 @@ public class Player extends Playable
if (getTrainedBeast() != null)
{
getTrainedBeast().getAI().stopFollow();
getTrainedBeast().teleToLocation(getPosition().getX() + Rnd.get(-100, 100), getPosition().getY() + Rnd.get(-100, 100), getPosition().getZ());
getTrainedBeast().teleToLocation(getLocation().getX() + Rnd.get(-100, 100), getLocation().getY() + Rnd.get(-100, 100), getLocation().getZ());
getTrainedBeast().getAI().startFollow(this);
}

View File

@ -87,7 +87,7 @@ public class Boat extends Creature
final MoveData m = new MoveData();
// Calculate and set the heading of the Creature
getPosition().setHeading((int) (Math.atan2(-sin, -cos) * 10430.378350470452724949566316381) + 32768);
getLocation().setHeading((int) (Math.atan2(-sin, -cos) * 10430.378350470452724949566316381) + 32768);
m._xDestination = x;
m._yDestination = y;
m._zDestination = z; // this is what was requested from client

View File

@ -179,7 +179,7 @@ public class PlayerKnownList extends PlayableKnownList
final Player otherPlayer = (Player) object;
if (otherPlayer.isInBoat())
{
otherPlayer.getPosition().setWorldPosition(otherPlayer.getBoat().getLocation());
otherPlayer.getLocation().setLocation(otherPlayer.getBoat().getLocation());
activeChar.sendPacket(new CharInfo(otherPlayer, activeChar.isGM() && otherPlayer.getAppearance().isInvisible()));
final int relation = otherPlayer.getRelation(activeChar);

View File

@ -80,7 +80,7 @@ public class BoatPathHolder
final double distance = Math.sqrt((dx * dx) + (dy * dy));
final double cos = dx / distance;
final double sin = dy / distance;
boat.getPosition().setHeading((int) (Math.atan2(-sin, -cos) * 10430.378350470452724949566316381) + 32768);
boat.getLocation().setHeading((int) (Math.atan2(-sin, -cos) * 10430.378350470452724949566316381) + 32768);
boat.vd = new VehicleDeparture(boat, path.speed1, path.speed2, path.x, path.y, path.z);
boat.boatSpeed = path.speed1;
boat.moveToLocation(path.x, path.y, path.z, path.speed1);

View File

@ -1117,18 +1117,18 @@ public class Item extends WorldObject
{
// Set the x,y,z position of the Item dropped and update its _worldregion
setSpawned(true);
getPosition().setWorldPosition(x, y, z);
getPosition().setWorldRegion(World.getInstance().getRegion(getPosition().getWorldPosition()));
getLocation().setXYZ(x, y, z);
setWorldRegion(World.getInstance().getRegion(getLocation()));
// Add the Item dropped to _visibleObjects of its WorldRegion
getPosition().getWorldRegion().addVisibleObject(this);
getWorldRegion().addVisibleObject(this);
}
setDropTime(Chronos.currentTimeMillis());
// this can synchronize on others instancies, so it's out of synchronized, to avoid deadlocks
// Add the Item dropped in the world as a visible object
World.getInstance().addVisibleObject(this, getPosition().getWorldRegion(), dropper);
World.getInstance().addVisibleObject(this, getWorldRegion(), dropper);
if (Config.SAVE_DROPPED_ITEM)
{
ItemsOnGroundManager.getInstance().save(this);

View File

@ -48,8 +48,8 @@ import org.l2jmobius.gameserver.model.sevensigns.SevenSigns;
import org.l2jmobius.gameserver.model.sevensigns.SevenSignsFestival;
import org.l2jmobius.gameserver.model.siege.Siege;
import org.l2jmobius.gameserver.model.skill.conditions.ConditionPlayerState;
import org.l2jmobius.gameserver.model.skill.conditions.ConditionUsingItemType;
import org.l2jmobius.gameserver.model.skill.conditions.ConditionPlayerState.CheckPlayerState;
import org.l2jmobius.gameserver.model.skill.conditions.ConditionUsingItemType;
import org.l2jmobius.gameserver.model.skill.effects.EffectTemplate;
import org.l2jmobius.gameserver.model.skill.funcs.Func;
import org.l2jmobius.gameserver.model.zone.ZoneId;
@ -1201,7 +1201,7 @@ public class Formulas
return 0;
}
final Siege siege = SiegeManager.getInstance().getSiege(player.getPosition().getX(), player.getPosition().getY(), player.getPosition().getZ());
final Siege siege = SiegeManager.getInstance().getSiege(player.getX(), player.getY(), player.getZ());
if ((siege == null) || !siege.isInProgress())
{
return 0;

View File

@ -56,7 +56,7 @@ public class CannotMoveAnymoreInVehicle implements IClientIncomingPacket
if (player.isInBoat() && (player.getBoat().getObjectId() == _boatId))
{
player.setBoatPosition(new Location(_x, _y, _z));
player.getPosition().setHeading(_heading);
player.setHeading(_heading);
player.broadcastPacket(new StopMoveInVehicle(player, _boatId));
}
}

View File

@ -57,7 +57,7 @@ public class RequestGetOnVehicle implements IClientIncomingPacket
}
player.setBoatPosition(new Location(_x, _y, _z));
player.setXYZ(boat.getPosition().getX(), boat.getPosition().getY(), boat.getPosition().getZ());
player.setXYZ(boat.getLocation().getX(), boat.getLocation().getY(), boat.getLocation().getZ());
player.broadcastPacket(new GetOnVehicle(player, boat, _x, _y, _z));
player.revalidateZone(true);
}

View File

@ -125,7 +125,7 @@ public class RequestRecordInfo implements IClientIncomingPacket
final Player otherPlayer = (Player) object;
if (otherPlayer.isInBoat())
{
otherPlayer.getPosition().setWorldPosition(otherPlayer.getBoat().getLocation());
otherPlayer.getLocation().setLocation(otherPlayer.getBoat().getLocation());
player.sendPacket(new CharInfo(otherPlayer, player.isGM() && otherPlayer.getAppearance().isInvisible()));
final int relation = otherPlayer.getRelation(player);
if ((otherPlayer.getKnownList().getKnownRelations().get(player.getObjectId()) != null) && (otherPlayer.getKnownList().getKnownRelations().get(player.getObjectId()) != relation))

View File

@ -28,9 +28,9 @@ public class FakePlayerInfo implements IClientOutgoingPacket
public FakePlayerInfo(Npc cha)
{
_activeChar = cha;
_activeChar.setClientX(_activeChar.getPosition().getX());
_activeChar.setClientY(_activeChar.getPosition().getY());
_activeChar.setClientZ(_activeChar.getPosition().getZ());
_activeChar.setClientX(_activeChar.getX());
_activeChar.setClientY(_activeChar.getY());
_activeChar.setClientZ(_activeChar.getZ());
}
@Override

View File

@ -52,7 +52,7 @@ public class OnVehicleCheckLocation implements IClientOutgoingPacket
packet.writeD(_x);
packet.writeD(_y);
packet.writeD(_z);
packet.writeD(_boat.getPosition().getHeading());
packet.writeD(_boat.getHeading());
return true;
}
}

View File

@ -23,6 +23,8 @@ import org.l2jmobius.gameserver.network.OutgoingPackets;
public class PlaySound implements IClientOutgoingPacket
{
private static final Location DUMMY_LOC = new Location(0, 0, 0);
private final int _unknown;
private final String _soundFile;
private final boolean _isObject;
@ -40,7 +42,7 @@ public class PlaySound implements IClientOutgoingPacket
_soundFile = soundFile;
_isObject = false;
_objectId = 0;
_loc = Location.DUMMY_LOC;
_loc = DUMMY_LOC;
_duration = 0;
}
@ -55,7 +57,7 @@ public class PlaySound implements IClientOutgoingPacket
_soundFile = soundFile;
_isObject = false;
_objectId = 0;
_loc = Location.DUMMY_LOC;
_loc = DUMMY_LOC;
_duration = 0;
}

View File

@ -47,7 +47,7 @@ public class StopMoveInVehicle implements IClientOutgoingPacket
packet.writeD(_player.getBoatPosition().getX());
packet.writeD(_player.getBoatPosition().getY());
packet.writeD(_player.getBoatPosition().getZ());
packet.writeD(_player.getPosition().getHeading());
packet.writeD(_player.getHeading());
return true;
}
}

View File

@ -43,7 +43,7 @@ public class VehicleInfo implements IClientOutgoingPacket
packet.writeD(_boat.getX());
packet.writeD(_boat.getY());
packet.writeD(_boat.getZ());
packet.writeD(_boat.getPosition().getHeading());
packet.writeD(_boat.getHeading());
return true;
}
}

View File

@ -114,7 +114,7 @@ public class Util
{
return 1000000;
}
return calculateDistance(obj1.getPosition().getX(), obj1.getPosition().getY(), obj1.getPosition().getZ(), obj2.getPosition().getX(), obj2.getPosition().getY(), obj2.getPosition().getZ(), includeZAxis);
return calculateDistance(obj1.getX(), obj1.getY(), obj1.getZ(), obj2.getX(), obj2.getY(), obj2.getZ(), includeZAxis);
}
/**

View File

@ -59,21 +59,13 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
private int _objectId;
/** World Region */
private WorldRegion _worldRegion;
/** Location */
private final Location _location = new Location(0, 0, -10000);
/** Instance type */
private InstanceType _instanceType;
private Map<String, Object> _scripts;
/** X coordinate */
private volatile int _x = 0;
/** Y coordinate */
private volatile int _y = 0;
/** Z coordinate */
private volatile int _z = -10000;
/** Orientation */
private volatile int _heading = 0;
/** Instance id of object. 0 - Global */
private volatile int _instanceId = 0;
private boolean _isSpawned;
private boolean _isInvisible;
private Map<String, Object> _scripts;
public WorldObject(int objectId)
{
@ -578,7 +570,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public int getX()
{
return _x;
return _location.getX();
}
/**
@ -588,7 +580,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public int getY()
{
return _y;
return _location.getY();
}
/**
@ -598,7 +590,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public int getZ()
{
return _z;
return _location.getZ();
}
/**
@ -608,7 +600,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public int getHeading()
{
return _heading;
return _location.getHeading();
}
/**
@ -618,7 +610,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public int getInstanceId()
{
return _instanceId;
return _location.getInstanceId();
}
/**
@ -628,7 +620,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public Location getLocation()
{
return new Location(_x, _y, _z, _heading, _instanceId);
return _location;
}
/**
@ -640,9 +632,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public void setXYZ(int newX, int newY, int newZ)
{
_x = newX;
_y = newY;
_z = newZ;
_location.setXYZ(newX, newY, newZ);
if (_isSpawned)
{
@ -677,7 +667,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public void setHeading(int newHeading)
{
_heading = newHeading;
_location.setHeading(newHeading);
}
/**
@ -688,12 +678,13 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public void setInstanceId(int instanceId)
{
if ((instanceId < 0) || (_instanceId == instanceId))
final int oldInstanceId = getInstanceId();
if ((instanceId < 0) || (oldInstanceId == instanceId))
{
return;
}
final Instance oldI = InstanceManager.getInstance().getInstance(getInstanceId());
final Instance oldI = InstanceManager.getInstance().getInstance(oldInstanceId);
final Instance newI = InstanceManager.getInstance().getInstance(instanceId);
if (newI == null)
{
@ -703,7 +694,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
if (isPlayer())
{
final Player player = getActingPlayer();
if ((_instanceId > 0) && (oldI != null))
if ((oldInstanceId > 0) && (oldI != null))
{
oldI.removePlayer(_objectId);
if (oldI.isShowTimer())
@ -727,7 +718,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
else if (isNpc())
{
final Npc npc = (Npc) this;
if ((_instanceId > 0) && (oldI != null))
if ((oldInstanceId > 0) && (oldI != null))
{
oldI.removeNpc(npc);
}
@ -737,7 +728,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
}
}
_instanceId = instanceId;
_location.setInstanceId(instanceId);
}
/**
@ -766,11 +757,9 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public void setLocation(Location loc)
{
_x = loc.getX();
_y = loc.getY();
_z = loc.getZ();
_heading = loc.getHeading();
_instanceId = loc.getInstanceId();
_location.setXYZ(loc.getX(), loc.getY(), loc.getZ());
_location.setHeading(loc.getHeading());
_location.setInstanceId(loc.getInstanceId());
}
/**
@ -782,7 +771,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
*/
public double calculateDistance2D(int x, int y, int z)
{
return Math.sqrt(Math.pow(x - _x, 2) + Math.pow(y - _y, 2));
return Math.sqrt(Math.pow(x - getX(), 2) + Math.pow(y - getY(), 2));
}
/**
@ -804,7 +793,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
*/
public double calculateDistance3D(int x, int y, int z)
{
return Math.sqrt(Math.pow(x - _x, 2) + Math.pow(y - _y, 2) + Math.pow(z - _z, 2));
return Math.sqrt(Math.pow(x - getX(), 2) + Math.pow(y - getY(), 2) + Math.pow(z - getZ(), 2));
}
/**
@ -826,7 +815,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
*/
public double calculateDistanceSq2D(int x, int y, int z)
{
return Math.pow(x - _x, 2) + Math.pow(y - _y, 2);
return Math.pow(x - getX(), 2) + Math.pow(y - getY(), 2);
}
/**
@ -848,7 +837,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
*/
public double calculateDistanceSq3D(int x, int y, int z)
{
return Math.pow(x - _x, 2) + Math.pow(y - _y, 2) + Math.pow(z - _z, 2);
return Math.pow(x - getX(), 2) + Math.pow(y - getY(), 2) + Math.pow(z - getZ(), 2);
}
/**

View File

@ -59,21 +59,13 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
private int _objectId;
/** World Region */
private WorldRegion _worldRegion;
/** Location */
private final Location _location = new Location(0, 0, -10000);
/** Instance type */
private InstanceType _instanceType;
private Map<String, Object> _scripts;
/** X coordinate */
private volatile int _x = 0;
/** Y coordinate */
private volatile int _y = 0;
/** Z coordinate */
private volatile int _z = -10000;
/** Orientation */
private volatile int _heading = 0;
/** Instance id of object. 0 - Global */
private volatile int _instanceId = 0;
private boolean _isSpawned;
private boolean _isInvisible;
private Map<String, Object> _scripts;
public WorldObject(int objectId)
{
@ -578,7 +570,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public int getX()
{
return _x;
return _location.getX();
}
/**
@ -588,7 +580,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public int getY()
{
return _y;
return _location.getY();
}
/**
@ -598,7 +590,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public int getZ()
{
return _z;
return _location.getZ();
}
/**
@ -608,7 +600,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public int getHeading()
{
return _heading;
return _location.getHeading();
}
/**
@ -618,7 +610,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public int getInstanceId()
{
return _instanceId;
return _location.getInstanceId();
}
/**
@ -628,7 +620,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public Location getLocation()
{
return new Location(_x, _y, _z, _heading, _instanceId);
return _location;
}
/**
@ -640,9 +632,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public void setXYZ(int newX, int newY, int newZ)
{
_x = newX;
_y = newY;
_z = newZ;
_location.setXYZ(newX, newY, newZ);
if (_isSpawned)
{
@ -677,7 +667,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public void setHeading(int newHeading)
{
_heading = newHeading;
_location.setHeading(newHeading);
}
/**
@ -688,12 +678,13 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public void setInstanceId(int instanceId)
{
if ((instanceId < 0) || (_instanceId == instanceId))
final int oldInstanceId = getInstanceId();
if ((instanceId < 0) || (oldInstanceId == instanceId))
{
return;
}
final Instance oldI = InstanceManager.getInstance().getInstance(getInstanceId());
final Instance oldI = InstanceManager.getInstance().getInstance(oldInstanceId);
final Instance newI = InstanceManager.getInstance().getInstance(instanceId);
if (newI == null)
{
@ -703,7 +694,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
if (isPlayer())
{
final Player player = getActingPlayer();
if ((_instanceId > 0) && (oldI != null))
if ((oldInstanceId > 0) && (oldI != null))
{
oldI.removePlayer(_objectId);
if (oldI.isShowTimer())
@ -727,7 +718,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
else if (isNpc())
{
final Npc npc = (Npc) this;
if ((_instanceId > 0) && (oldI != null))
if ((oldInstanceId > 0) && (oldI != null))
{
oldI.removeNpc(npc);
}
@ -737,7 +728,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
}
}
_instanceId = instanceId;
_location.setInstanceId(instanceId);
}
/**
@ -766,11 +757,9 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public void setLocation(Location loc)
{
_x = loc.getX();
_y = loc.getY();
_z = loc.getZ();
_heading = loc.getHeading();
_instanceId = loc.getInstanceId();
_location.setXYZ(loc.getX(), loc.getY(), loc.getZ());
_location.setHeading(loc.getHeading());
_location.setInstanceId(loc.getInstanceId());
}
/**
@ -782,7 +771,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
*/
public double calculateDistance2D(int x, int y, int z)
{
return Math.sqrt(Math.pow(x - _x, 2) + Math.pow(y - _y, 2));
return Math.sqrt(Math.pow(x - getX(), 2) + Math.pow(y - getY(), 2));
}
/**
@ -804,7 +793,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
*/
public double calculateDistance3D(int x, int y, int z)
{
return Math.sqrt(Math.pow(x - _x, 2) + Math.pow(y - _y, 2) + Math.pow(z - _z, 2));
return Math.sqrt(Math.pow(x - getX(), 2) + Math.pow(y - getY(), 2) + Math.pow(z - getZ(), 2));
}
/**
@ -826,7 +815,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
*/
public double calculateDistanceSq2D(int x, int y, int z)
{
return Math.pow(x - _x, 2) + Math.pow(y - _y, 2);
return Math.pow(x - getX(), 2) + Math.pow(y - getY(), 2);
}
/**
@ -848,7 +837,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
*/
public double calculateDistanceSq3D(int x, int y, int z)
{
return Math.pow(x - _x, 2) + Math.pow(y - _y, 2) + Math.pow(z - _z, 2);
return Math.pow(x - getX(), 2) + Math.pow(y - getY(), 2) + Math.pow(z - getZ(), 2);
}
/**

View File

@ -55,22 +55,16 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
private int _objectId;
/** World Region */
private WorldRegion _worldRegion;
/** Location */
private final Location _location = new Location(0, 0, -10000);
/** Instance */
private Instance _instance;
/** Instance type */
private InstanceType _instanceType;
private Map<String, Object> _scripts;
/** X coordinate */
private volatile int _x = 0;
/** Y coordinate */
private volatile int _y = 0;
/** Z coordinate */
private volatile int _z = -10000;
/** Orientation */
private volatile int _heading = 0;
/** Instance id of object. 0 - Global */
private Instance _instance;
private boolean _isSpawned;
private boolean _isInvisible;
private boolean _isTargetable = true;
private Map<String, Object> _scripts;
public WorldObject(int objectId)
{
@ -567,7 +561,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public int getX()
{
return _x;
return _location.getX();
}
/**
@ -577,7 +571,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public int getY()
{
return _y;
return _location.getY();
}
/**
@ -587,7 +581,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public int getZ()
{
return _z;
return _location.getZ();
}
/**
@ -597,7 +591,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public int getHeading()
{
return _heading;
return _location.getHeading();
}
/**
@ -635,7 +629,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public Location getLocation()
{
return new Location(_x, _y, _z, _heading);
return _location;
}
/**
@ -647,9 +641,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public void setXYZ(int newX, int newY, int newZ)
{
_x = newX;
_y = newY;
_z = newZ;
_location.setXYZ(newX, newY, newZ);
if (_isSpawned)
{
@ -684,7 +676,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public void setHeading(int newHeading)
{
_heading = newHeading;
_location.setHeading(newHeading);
}
/**
@ -736,10 +728,8 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public void setLocation(Location loc)
{
_x = loc.getX();
_y = loc.getY();
_z = loc.getZ();
_heading = loc.getHeading();
_location.setXYZ(loc.getX(), loc.getY(), loc.getZ());
_location.setHeading(loc.getHeading());
}
/**
@ -751,7 +741,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
*/
public double calculateDistance2D(int x, int y, int z)
{
return Math.sqrt(Math.pow(x - _x, 2) + Math.pow(y - _y, 2));
return Math.sqrt(Math.pow(x - getX(), 2) + Math.pow(y - getY(), 2));
}
/**
@ -773,7 +763,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
*/
public double calculateDistance3D(int x, int y, int z)
{
return Math.sqrt(Math.pow(x - _x, 2) + Math.pow(y - _y, 2) + Math.pow(z - _z, 2));
return Math.sqrt(Math.pow(x - getX(), 2) + Math.pow(y - getY(), 2) + Math.pow(z - getZ(), 2));
}
/**
@ -795,7 +785,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
*/
public double calculateDistanceSq2D(int x, int y, int z)
{
return Math.pow(x - _x, 2) + Math.pow(y - _y, 2);
return Math.pow(x - getX(), 2) + Math.pow(y - getY(), 2);
}
/**
@ -817,7 +807,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
*/
public double calculateDistanceSq3D(int x, int y, int z)
{
return Math.pow(x - _x, 2) + Math.pow(y - _y, 2) + Math.pow(z - _z, 2);
return Math.pow(x - getX(), 2) + Math.pow(y - getY(), 2) + Math.pow(z - getZ(), 2);
}
/**

View File

@ -55,22 +55,16 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
private int _objectId;
/** World Region */
private WorldRegion _worldRegion;
/** Location */
private final Location _location = new Location(0, 0, -10000);
/** Instance */
private Instance _instance;
/** Instance type */
private InstanceType _instanceType;
private Map<String, Object> _scripts;
/** X coordinate */
private volatile int _x = 0;
/** Y coordinate */
private volatile int _y = 0;
/** Z coordinate */
private volatile int _z = -10000;
/** Orientation */
private volatile int _heading = 0;
/** Instance id of object. 0 - Global */
private Instance _instance;
private boolean _isSpawned;
private boolean _isInvisible;
private boolean _isTargetable = true;
private Map<String, Object> _scripts;
public WorldObject(int objectId)
{
@ -567,7 +561,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public int getX()
{
return _x;
return _location.getX();
}
/**
@ -577,7 +571,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public int getY()
{
return _y;
return _location.getY();
}
/**
@ -587,7 +581,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public int getZ()
{
return _z;
return _location.getZ();
}
/**
@ -597,7 +591,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public int getHeading()
{
return _heading;
return _location.getHeading();
}
/**
@ -635,7 +629,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public Location getLocation()
{
return new Location(_x, _y, _z, _heading);
return _location;
}
/**
@ -647,9 +641,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public void setXYZ(int newX, int newY, int newZ)
{
_x = newX;
_y = newY;
_z = newZ;
_location.setXYZ(newX, newY, newZ);
if (_isSpawned)
{
@ -684,7 +676,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public void setHeading(int newHeading)
{
_heading = newHeading;
_location.setHeading(newHeading);
}
/**
@ -736,10 +728,8 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public void setLocation(Location loc)
{
_x = loc.getX();
_y = loc.getY();
_z = loc.getZ();
_heading = loc.getHeading();
_location.setXYZ(loc.getX(), loc.getY(), loc.getZ());
_location.setHeading(loc.getHeading());
}
/**
@ -751,7 +741,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
*/
public double calculateDistance2D(int x, int y, int z)
{
return Math.sqrt(Math.pow(x - _x, 2) + Math.pow(y - _y, 2));
return Math.sqrt(Math.pow(x - getX(), 2) + Math.pow(y - getY(), 2));
}
/**
@ -773,7 +763,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
*/
public double calculateDistance3D(int x, int y, int z)
{
return Math.sqrt(Math.pow(x - _x, 2) + Math.pow(y - _y, 2) + Math.pow(z - _z, 2));
return Math.sqrt(Math.pow(x - getX(), 2) + Math.pow(y - getY(), 2) + Math.pow(z - getZ(), 2));
}
/**
@ -795,7 +785,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
*/
public double calculateDistanceSq2D(int x, int y, int z)
{
return Math.pow(x - _x, 2) + Math.pow(y - _y, 2);
return Math.pow(x - getX(), 2) + Math.pow(y - getY(), 2);
}
/**
@ -817,7 +807,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
*/
public double calculateDistanceSq3D(int x, int y, int z)
{
return Math.pow(x - _x, 2) + Math.pow(y - _y, 2) + Math.pow(z - _z, 2);
return Math.pow(x - getX(), 2) + Math.pow(y - getY(), 2) + Math.pow(z - getZ(), 2);
}
/**

View File

@ -55,22 +55,16 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
private int _objectId;
/** World Region */
private WorldRegion _worldRegion;
/** Location */
private final Location _location = new Location(0, 0, -10000);
/** Instance */
private Instance _instance;
/** Instance type */
private InstanceType _instanceType;
private Map<String, Object> _scripts;
/** X coordinate */
private volatile int _x = 0;
/** Y coordinate */
private volatile int _y = 0;
/** Z coordinate */
private volatile int _z = -10000;
/** Orientation */
private volatile int _heading = 0;
/** Instance id of object. 0 - Global */
private Instance _instance;
private boolean _isSpawned;
private boolean _isInvisible;
private boolean _isTargetable = true;
private Map<String, Object> _scripts;
public WorldObject(int objectId)
{
@ -567,7 +561,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public int getX()
{
return _x;
return _location.getX();
}
/**
@ -577,7 +571,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public int getY()
{
return _y;
return _location.getY();
}
/**
@ -587,7 +581,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public int getZ()
{
return _z;
return _location.getZ();
}
/**
@ -597,7 +591,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public int getHeading()
{
return _heading;
return _location.getHeading();
}
/**
@ -635,7 +629,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public Location getLocation()
{
return new Location(_x, _y, _z, _heading);
return _location;
}
/**
@ -647,9 +641,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public void setXYZ(int newX, int newY, int newZ)
{
_x = newX;
_y = newY;
_z = newZ;
_location.setXYZ(newX, newY, newZ);
if (_isSpawned)
{
@ -684,7 +676,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public void setHeading(int newHeading)
{
_heading = newHeading;
_location.setHeading(newHeading);
}
/**
@ -736,10 +728,8 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public void setLocation(Location loc)
{
_x = loc.getX();
_y = loc.getY();
_z = loc.getZ();
_heading = loc.getHeading();
_location.setXYZ(loc.getX(), loc.getY(), loc.getZ());
_location.setHeading(loc.getHeading());
}
/**
@ -751,7 +741,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
*/
public double calculateDistance2D(int x, int y, int z)
{
return Math.sqrt(Math.pow(x - _x, 2) + Math.pow(y - _y, 2));
return Math.sqrt(Math.pow(x - getX(), 2) + Math.pow(y - getY(), 2));
}
/**
@ -773,7 +763,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
*/
public double calculateDistance3D(int x, int y, int z)
{
return Math.sqrt(Math.pow(x - _x, 2) + Math.pow(y - _y, 2) + Math.pow(z - _z, 2));
return Math.sqrt(Math.pow(x - getX(), 2) + Math.pow(y - getY(), 2) + Math.pow(z - getZ(), 2));
}
/**
@ -795,7 +785,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
*/
public double calculateDistanceSq2D(int x, int y, int z)
{
return Math.pow(x - _x, 2) + Math.pow(y - _y, 2);
return Math.pow(x - getX(), 2) + Math.pow(y - getY(), 2);
}
/**
@ -817,7 +807,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
*/
public double calculateDistanceSq3D(int x, int y, int z)
{
return Math.pow(x - _x, 2) + Math.pow(y - _y, 2) + Math.pow(z - _z, 2);
return Math.pow(x - getX(), 2) + Math.pow(y - getY(), 2) + Math.pow(z - getZ(), 2);
}
/**

View File

@ -55,22 +55,16 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
private int _objectId;
/** World Region */
private WorldRegion _worldRegion;
/** Location */
private final Location _location = new Location(0, 0, -10000);
/** Instance */
private Instance _instance;
/** Instance type */
private InstanceType _instanceType;
private Map<String, Object> _scripts;
/** X coordinate */
private volatile int _x = 0;
/** Y coordinate */
private volatile int _y = 0;
/** Z coordinate */
private volatile int _z = -10000;
/** Orientation */
private volatile int _heading = 0;
/** Instance id of object. 0 - Global */
private Instance _instance;
private boolean _isSpawned;
private boolean _isInvisible;
private boolean _isTargetable = true;
private Map<String, Object> _scripts;
public WorldObject(int objectId)
{
@ -567,7 +561,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public int getX()
{
return _x;
return _location.getX();
}
/**
@ -577,7 +571,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public int getY()
{
return _y;
return _location.getY();
}
/**
@ -587,7 +581,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public int getZ()
{
return _z;
return _location.getZ();
}
/**
@ -597,7 +591,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public int getHeading()
{
return _heading;
return _location.getHeading();
}
/**
@ -635,7 +629,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public Location getLocation()
{
return new Location(_x, _y, _z, _heading);
return _location;
}
/**
@ -647,9 +641,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public void setXYZ(int newX, int newY, int newZ)
{
_x = newX;
_y = newY;
_z = newZ;
_location.setXYZ(newX, newY, newZ);
if (_isSpawned)
{
@ -684,7 +676,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public void setHeading(int newHeading)
{
_heading = newHeading;
_location.setHeading(newHeading);
}
/**
@ -736,10 +728,8 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public void setLocation(Location loc)
{
_x = loc.getX();
_y = loc.getY();
_z = loc.getZ();
_heading = loc.getHeading();
_location.setXYZ(loc.getX(), loc.getY(), loc.getZ());
_location.setHeading(loc.getHeading());
}
/**
@ -751,7 +741,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
*/
public double calculateDistance2D(int x, int y, int z)
{
return Math.sqrt(Math.pow(x - _x, 2) + Math.pow(y - _y, 2));
return Math.sqrt(Math.pow(x - getX(), 2) + Math.pow(y - getY(), 2));
}
/**
@ -773,7 +763,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
*/
public double calculateDistance3D(int x, int y, int z)
{
return Math.sqrt(Math.pow(x - _x, 2) + Math.pow(y - _y, 2) + Math.pow(z - _z, 2));
return Math.sqrt(Math.pow(x - getX(), 2) + Math.pow(y - getY(), 2) + Math.pow(z - getZ(), 2));
}
/**
@ -795,7 +785,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
*/
public double calculateDistanceSq2D(int x, int y, int z)
{
return Math.pow(x - _x, 2) + Math.pow(y - _y, 2);
return Math.pow(x - getX(), 2) + Math.pow(y - getY(), 2);
}
/**
@ -817,7 +807,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
*/
public double calculateDistanceSq3D(int x, int y, int z)
{
return Math.pow(x - _x, 2) + Math.pow(y - _y, 2) + Math.pow(z - _z, 2);
return Math.pow(x - getX(), 2) + Math.pow(y - getY(), 2) + Math.pow(z - getZ(), 2);
}
/**

View File

@ -55,22 +55,16 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
private int _objectId;
/** World Region */
private WorldRegion _worldRegion;
/** Location */
private final Location _location = new Location(0, 0, -10000);
/** Instance */
private Instance _instance;
/** Instance type */
private InstanceType _instanceType;
private Map<String, Object> _scripts;
/** X coordinate */
private volatile int _x = 0;
/** Y coordinate */
private volatile int _y = 0;
/** Z coordinate */
private volatile int _z = -10000;
/** Orientation */
private volatile int _heading = 0;
/** Instance id of object. 0 - Global */
private Instance _instance;
private boolean _isSpawned;
private boolean _isInvisible;
private boolean _isTargetable = true;
private Map<String, Object> _scripts;
public WorldObject(int objectId)
{
@ -567,7 +561,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public int getX()
{
return _x;
return _location.getX();
}
/**
@ -577,7 +571,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public int getY()
{
return _y;
return _location.getY();
}
/**
@ -587,7 +581,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public int getZ()
{
return _z;
return _location.getZ();
}
/**
@ -597,7 +591,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public int getHeading()
{
return _heading;
return _location.getHeading();
}
/**
@ -635,7 +629,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public Location getLocation()
{
return new Location(_x, _y, _z, _heading);
return _location;
}
/**
@ -647,9 +641,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public void setXYZ(int newX, int newY, int newZ)
{
_x = newX;
_y = newY;
_z = newZ;
_location.setXYZ(newX, newY, newZ);
if (_isSpawned)
{
@ -684,7 +676,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public void setHeading(int newHeading)
{
_heading = newHeading;
_location.setHeading(newHeading);
}
/**
@ -736,10 +728,8 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public void setLocation(Location loc)
{
_x = loc.getX();
_y = loc.getY();
_z = loc.getZ();
_heading = loc.getHeading();
_location.setXYZ(loc.getX(), loc.getY(), loc.getZ());
_location.setHeading(loc.getHeading());
}
/**
@ -751,7 +741,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
*/
public double calculateDistance2D(int x, int y, int z)
{
return Math.sqrt(Math.pow(x - _x, 2) + Math.pow(y - _y, 2));
return Math.sqrt(Math.pow(x - getX(), 2) + Math.pow(y - getY(), 2));
}
/**
@ -773,7 +763,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
*/
public double calculateDistance3D(int x, int y, int z)
{
return Math.sqrt(Math.pow(x - _x, 2) + Math.pow(y - _y, 2) + Math.pow(z - _z, 2));
return Math.sqrt(Math.pow(x - getX(), 2) + Math.pow(y - getY(), 2) + Math.pow(z - getZ(), 2));
}
/**
@ -795,7 +785,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
*/
public double calculateDistanceSq2D(int x, int y, int z)
{
return Math.pow(x - _x, 2) + Math.pow(y - _y, 2);
return Math.pow(x - getX(), 2) + Math.pow(y - getY(), 2);
}
/**
@ -817,7 +807,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
*/
public double calculateDistanceSq3D(int x, int y, int z)
{
return Math.pow(x - _x, 2) + Math.pow(y - _y, 2) + Math.pow(z - _z, 2);
return Math.pow(x - getX(), 2) + Math.pow(y - getY(), 2) + Math.pow(z - getZ(), 2);
}
/**

View File

@ -55,22 +55,16 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
private int _objectId;
/** World Region */
private WorldRegion _worldRegion;
/** Location */
private final Location _location = new Location(0, 0, -10000);
/** Instance */
private Instance _instance;
/** Instance type */
private InstanceType _instanceType;
private Map<String, Object> _scripts;
/** X coordinate */
private volatile int _x = 0;
/** Y coordinate */
private volatile int _y = 0;
/** Z coordinate */
private volatile int _z = -10000;
/** Orientation */
private volatile int _heading = 0;
/** Instance id of object. 0 - Global */
private Instance _instance;
private boolean _isSpawned;
private boolean _isInvisible;
private boolean _isTargetable = true;
private Map<String, Object> _scripts;
public WorldObject(int objectId)
{
@ -567,7 +561,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public int getX()
{
return _x;
return _location.getX();
}
/**
@ -577,7 +571,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public int getY()
{
return _y;
return _location.getY();
}
/**
@ -587,7 +581,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public int getZ()
{
return _z;
return _location.getZ();
}
/**
@ -597,7 +591,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public int getHeading()
{
return _heading;
return _location.getHeading();
}
/**
@ -635,7 +629,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public Location getLocation()
{
return new Location(_x, _y, _z, _heading);
return _location;
}
/**
@ -647,9 +641,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public void setXYZ(int newX, int newY, int newZ)
{
_x = newX;
_y = newY;
_z = newZ;
_location.setXYZ(newX, newY, newZ);
if (_isSpawned)
{
@ -684,7 +676,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public void setHeading(int newHeading)
{
_heading = newHeading;
_location.setHeading(newHeading);
}
/**
@ -736,10 +728,8 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public void setLocation(Location loc)
{
_x = loc.getX();
_y = loc.getY();
_z = loc.getZ();
_heading = loc.getHeading();
_location.setXYZ(loc.getX(), loc.getY(), loc.getZ());
_location.setHeading(loc.getHeading());
}
/**
@ -751,7 +741,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
*/
public double calculateDistance2D(int x, int y, int z)
{
return Math.sqrt(Math.pow(x - _x, 2) + Math.pow(y - _y, 2));
return Math.sqrt(Math.pow(x - getX(), 2) + Math.pow(y - getY(), 2));
}
/**
@ -773,7 +763,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
*/
public double calculateDistance3D(int x, int y, int z)
{
return Math.sqrt(Math.pow(x - _x, 2) + Math.pow(y - _y, 2) + Math.pow(z - _z, 2));
return Math.sqrt(Math.pow(x - getX(), 2) + Math.pow(y - getY(), 2) + Math.pow(z - getZ(), 2));
}
/**
@ -795,7 +785,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
*/
public double calculateDistanceSq2D(int x, int y, int z)
{
return Math.pow(x - _x, 2) + Math.pow(y - _y, 2);
return Math.pow(x - getX(), 2) + Math.pow(y - getY(), 2);
}
/**
@ -817,7 +807,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
*/
public double calculateDistanceSq3D(int x, int y, int z)
{
return Math.pow(x - _x, 2) + Math.pow(y - _y, 2) + Math.pow(z - _z, 2);
return Math.pow(x - getX(), 2) + Math.pow(y - getY(), 2) + Math.pow(z - getZ(), 2);
}
/**

View File

@ -55,22 +55,16 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
private int _objectId;
/** World Region */
private WorldRegion _worldRegion;
/** Location */
private final Location _location = new Location(0, 0, -10000);
/** Instance */
private Instance _instance;
/** Instance type */
private InstanceType _instanceType;
private Map<String, Object> _scripts;
/** X coordinate */
private volatile int _x = 0;
/** Y coordinate */
private volatile int _y = 0;
/** Z coordinate */
private volatile int _z = -10000;
/** Orientation */
private volatile int _heading = 0;
/** Instance id of object. 0 - Global */
private Instance _instance;
private boolean _isSpawned;
private boolean _isInvisible;
private boolean _isTargetable = true;
private Map<String, Object> _scripts;
public WorldObject(int objectId)
{
@ -567,7 +561,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public int getX()
{
return _x;
return _location.getX();
}
/**
@ -577,7 +571,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public int getY()
{
return _y;
return _location.getY();
}
/**
@ -587,7 +581,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public int getZ()
{
return _z;
return _location.getZ();
}
/**
@ -597,7 +591,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public int getHeading()
{
return _heading;
return _location.getHeading();
}
/**
@ -635,7 +629,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public Location getLocation()
{
return new Location(_x, _y, _z, _heading);
return _location;
}
/**
@ -647,9 +641,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public void setXYZ(int newX, int newY, int newZ)
{
_x = newX;
_y = newY;
_z = newZ;
_location.setXYZ(newX, newY, newZ);
if (_isSpawned)
{
@ -684,7 +676,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public void setHeading(int newHeading)
{
_heading = newHeading;
_location.setHeading(newHeading);
}
/**
@ -736,10 +728,8 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public void setLocation(Location loc)
{
_x = loc.getX();
_y = loc.getY();
_z = loc.getZ();
_heading = loc.getHeading();
_location.setXYZ(loc.getX(), loc.getY(), loc.getZ());
_location.setHeading(loc.getHeading());
}
/**
@ -751,7 +741,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
*/
public double calculateDistance2D(int x, int y, int z)
{
return Math.sqrt(Math.pow(x - _x, 2) + Math.pow(y - _y, 2));
return Math.sqrt(Math.pow(x - getX(), 2) + Math.pow(y - getY(), 2));
}
/**
@ -773,7 +763,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
*/
public double calculateDistance3D(int x, int y, int z)
{
return Math.sqrt(Math.pow(x - _x, 2) + Math.pow(y - _y, 2) + Math.pow(z - _z, 2));
return Math.sqrt(Math.pow(x - getX(), 2) + Math.pow(y - getY(), 2) + Math.pow(z - getZ(), 2));
}
/**
@ -795,7 +785,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
*/
public double calculateDistanceSq2D(int x, int y, int z)
{
return Math.pow(x - _x, 2) + Math.pow(y - _y, 2);
return Math.pow(x - getX(), 2) + Math.pow(y - getY(), 2);
}
/**
@ -817,7 +807,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
*/
public double calculateDistanceSq3D(int x, int y, int z)
{
return Math.pow(x - _x, 2) + Math.pow(y - _y, 2) + Math.pow(z - _z, 2);
return Math.pow(x - getX(), 2) + Math.pow(y - getY(), 2) + Math.pow(z - getZ(), 2);
}
/**

View File

@ -55,22 +55,16 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
private int _objectId;
/** World Region */
private WorldRegion _worldRegion;
/** Location */
private final Location _location = new Location(0, 0, -10000);
/** Instance */
private Instance _instance;
/** Instance type */
private InstanceType _instanceType;
private Map<String, Object> _scripts;
/** X coordinate */
private volatile int _x = 0;
/** Y coordinate */
private volatile int _y = 0;
/** Z coordinate */
private volatile int _z = -10000;
/** Orientation */
private volatile int _heading = 0;
/** Instance id of object. 0 - Global */
private Instance _instance;
private boolean _isSpawned;
private boolean _isInvisible;
private boolean _isTargetable = true;
private Map<String, Object> _scripts;
public WorldObject(int objectId)
{
@ -567,7 +561,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public int getX()
{
return _x;
return _location.getX();
}
/**
@ -577,7 +571,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public int getY()
{
return _y;
return _location.getY();
}
/**
@ -587,7 +581,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public int getZ()
{
return _z;
return _location.getZ();
}
/**
@ -597,7 +591,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public int getHeading()
{
return _heading;
return _location.getHeading();
}
/**
@ -635,7 +629,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public Location getLocation()
{
return new Location(_x, _y, _z, _heading);
return _location;
}
/**
@ -647,9 +641,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public void setXYZ(int newX, int newY, int newZ)
{
_x = newX;
_y = newY;
_z = newZ;
_location.setXYZ(newX, newY, newZ);
if (_isSpawned)
{
@ -684,7 +676,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public void setHeading(int newHeading)
{
_heading = newHeading;
_location.setHeading(newHeading);
}
/**
@ -736,10 +728,8 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public void setLocation(Location loc)
{
_x = loc.getX();
_y = loc.getY();
_z = loc.getZ();
_heading = loc.getHeading();
_location.setXYZ(loc.getX(), loc.getY(), loc.getZ());
_location.setHeading(loc.getHeading());
}
/**
@ -751,7 +741,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
*/
public double calculateDistance2D(int x, int y, int z)
{
return Math.sqrt(Math.pow(x - _x, 2) + Math.pow(y - _y, 2));
return Math.sqrt(Math.pow(x - getX(), 2) + Math.pow(y - getY(), 2));
}
/**
@ -773,7 +763,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
*/
public double calculateDistance3D(int x, int y, int z)
{
return Math.sqrt(Math.pow(x - _x, 2) + Math.pow(y - _y, 2) + Math.pow(z - _z, 2));
return Math.sqrt(Math.pow(x - getX(), 2) + Math.pow(y - getY(), 2) + Math.pow(z - getZ(), 2));
}
/**
@ -795,7 +785,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
*/
public double calculateDistanceSq2D(int x, int y, int z)
{
return Math.pow(x - _x, 2) + Math.pow(y - _y, 2);
return Math.pow(x - getX(), 2) + Math.pow(y - getY(), 2);
}
/**
@ -817,7 +807,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
*/
public double calculateDistanceSq3D(int x, int y, int z)
{
return Math.pow(x - _x, 2) + Math.pow(y - _y, 2) + Math.pow(z - _z, 2);
return Math.pow(x - getX(), 2) + Math.pow(y - getY(), 2) + Math.pow(z - getZ(), 2);
}
/**

View File

@ -55,22 +55,16 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
private int _objectId;
/** World Region */
private WorldRegion _worldRegion;
/** Location */
private final Location _location = new Location(0, 0, -10000);
/** Instance */
private Instance _instance;
/** Instance type */
private InstanceType _instanceType;
private Map<String, Object> _scripts;
/** X coordinate */
private volatile int _x = 0;
/** Y coordinate */
private volatile int _y = 0;
/** Z coordinate */
private volatile int _z = -10000;
/** Orientation */
private volatile int _heading = 0;
/** Instance id of object. 0 - Global */
private Instance _instance;
private boolean _isSpawned;
private boolean _isInvisible;
private boolean _isTargetable = true;
private Map<String, Object> _scripts;
public WorldObject(int objectId)
{
@ -567,7 +561,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public int getX()
{
return _x;
return _location.getX();
}
/**
@ -577,7 +571,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public int getY()
{
return _y;
return _location.getY();
}
/**
@ -587,7 +581,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public int getZ()
{
return _z;
return _location.getZ();
}
/**
@ -597,7 +591,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public int getHeading()
{
return _heading;
return _location.getHeading();
}
/**
@ -635,7 +629,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public Location getLocation()
{
return new Location(_x, _y, _z, _heading);
return _location;
}
/**
@ -647,9 +641,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public void setXYZ(int newX, int newY, int newZ)
{
_x = newX;
_y = newY;
_z = newZ;
_location.setXYZ(newX, newY, newZ);
if (_isSpawned)
{
@ -684,7 +676,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public void setHeading(int newHeading)
{
_heading = newHeading;
_location.setHeading(newHeading);
}
/**
@ -736,10 +728,8 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public void setLocation(Location loc)
{
_x = loc.getX();
_y = loc.getY();
_z = loc.getZ();
_heading = loc.getHeading();
_location.setXYZ(loc.getX(), loc.getY(), loc.getZ());
_location.setHeading(loc.getHeading());
}
/**
@ -751,7 +741,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
*/
public double calculateDistance2D(int x, int y, int z)
{
return Math.sqrt(Math.pow(x - _x, 2) + Math.pow(y - _y, 2));
return Math.sqrt(Math.pow(x - getX(), 2) + Math.pow(y - getY(), 2));
}
/**
@ -773,7 +763,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
*/
public double calculateDistance3D(int x, int y, int z)
{
return Math.sqrt(Math.pow(x - _x, 2) + Math.pow(y - _y, 2) + Math.pow(z - _z, 2));
return Math.sqrt(Math.pow(x - getX(), 2) + Math.pow(y - getY(), 2) + Math.pow(z - getZ(), 2));
}
/**
@ -795,7 +785,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
*/
public double calculateDistanceSq2D(int x, int y, int z)
{
return Math.pow(x - _x, 2) + Math.pow(y - _y, 2);
return Math.pow(x - getX(), 2) + Math.pow(y - getY(), 2);
}
/**
@ -817,7 +807,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
*/
public double calculateDistanceSq3D(int x, int y, int z)
{
return Math.pow(x - _x, 2) + Math.pow(y - _y, 2) + Math.pow(z - _z, 2);
return Math.pow(x - getX(), 2) + Math.pow(y - getY(), 2) + Math.pow(z - getZ(), 2);
}
/**

View File

@ -55,22 +55,16 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
private int _objectId;
/** World Region */
private WorldRegion _worldRegion;
/** Location */
private final Location _location = new Location(0, 0, -10000);
/** Instance */
private Instance _instance;
/** Instance type */
private InstanceType _instanceType;
private Map<String, Object> _scripts;
/** X coordinate */
private volatile int _x = 0;
/** Y coordinate */
private volatile int _y = 0;
/** Z coordinate */
private volatile int _z = -10000;
/** Orientation */
private volatile int _heading = 0;
/** Instance id of object. 0 - Global */
private Instance _instance;
private boolean _isSpawned;
private boolean _isInvisible;
private boolean _isTargetable = true;
private Map<String, Object> _scripts;
public WorldObject(int objectId)
{
@ -567,7 +561,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public int getX()
{
return _x;
return _location.getX();
}
/**
@ -577,7 +571,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public int getY()
{
return _y;
return _location.getY();
}
/**
@ -587,7 +581,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public int getZ()
{
return _z;
return _location.getZ();
}
/**
@ -597,7 +591,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public int getHeading()
{
return _heading;
return _location.getHeading();
}
/**
@ -635,7 +629,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public Location getLocation()
{
return new Location(_x, _y, _z, _heading);
return _location;
}
/**
@ -647,9 +641,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public void setXYZ(int newX, int newY, int newZ)
{
_x = newX;
_y = newY;
_z = newZ;
_location.setXYZ(newX, newY, newZ);
if (_isSpawned)
{
@ -684,7 +676,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public void setHeading(int newHeading)
{
_heading = newHeading;
_location.setHeading(newHeading);
}
/**
@ -736,10 +728,8 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
@Override
public void setLocation(Location loc)
{
_x = loc.getX();
_y = loc.getY();
_z = loc.getZ();
_heading = loc.getHeading();
_location.setXYZ(loc.getX(), loc.getY(), loc.getZ());
_location.setHeading(loc.getHeading());
}
/**
@ -751,7 +741,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
*/
public double calculateDistance2D(int x, int y, int z)
{
return Math.sqrt(Math.pow(x - _x, 2) + Math.pow(y - _y, 2));
return Math.sqrt(Math.pow(x - getX(), 2) + Math.pow(y - getY(), 2));
}
/**
@ -773,7 +763,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
*/
public double calculateDistance3D(int x, int y, int z)
{
return Math.sqrt(Math.pow(x - _x, 2) + Math.pow(y - _y, 2) + Math.pow(z - _z, 2));
return Math.sqrt(Math.pow(x - getX(), 2) + Math.pow(y - getY(), 2) + Math.pow(z - getZ(), 2));
}
/**
@ -795,7 +785,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
*/
public double calculateDistanceSq2D(int x, int y, int z)
{
return Math.pow(x - _x, 2) + Math.pow(y - _y, 2);
return Math.pow(x - getX(), 2) + Math.pow(y - getY(), 2);
}
/**
@ -817,7 +807,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
*/
public double calculateDistanceSq3D(int x, int y, int z)
{
return Math.pow(x - _x, 2) + Math.pow(y - _y, 2) + Math.pow(z - _z, 2);
return Math.pow(x - getX(), 2) + Math.pow(y - getY(), 2) + Math.pow(z - getZ(), 2);
}
/**