1
0
mirror of https://github.com/Rogiel/l2jserver2 synced 2025-12-08 08:23:11 +00:00

Created CharacterTemplate object for all classes

Signed-off-by: Rogiel <rogiel@rogiel.com>
This commit is contained in:
2011-05-14 16:39:33 -03:00
parent d8d561688b
commit e886165b89
137 changed files with 6472 additions and 97 deletions

View File

@@ -1,5 +1,6 @@
package com.l2jserver.model.id;
import com.google.inject.Inject;
import com.google.inject.assistedinject.Assisted;
/**
@@ -15,6 +16,7 @@ public class AccountID extends ID<String> {
* @param login
* the login
*/
@Inject
public AccountID(@Assisted String login) {
super(login);
}

View File

@@ -8,7 +8,7 @@ import com.l2jserver.model.world.AbstractActor.Race;
import com.l2jserver.model.world.L2Character;
import com.l2jserver.model.world.character.CharacterBaseAttributes;
import com.l2jserver.model.world.character.CharacterClass;
import com.l2jserver.util.Coordinate;
import com.l2jserver.util.dimensional.Point;
/**
* Template for {@link L2Character}
@@ -33,7 +33,7 @@ public abstract class CharacterTemplate extends AbstractTemplate<L2Character> {
/**
* The initial location for the character to be spawned
*/
protected final Coordinate spawnLocation;
protected final Point spawnLocation;
/**
* The base attributes instance
*/
@@ -45,7 +45,7 @@ public abstract class CharacterTemplate extends AbstractTemplate<L2Character> {
int physicalAttack, int magicalAttack, int physicalDefense,
int magicalDefense, int attackSpeed, int castSpeed, int accuracy,
int criticalChance, int evasionChance, int moveSpeed,
int maxWeigth, boolean craft, Coordinate spawnLocation) {
int maxWeigth, boolean craft, Point spawnLocation) {
super(id);
this.race = characterClass.race;
this.characterClass = characterClass;
@@ -64,7 +64,7 @@ public abstract class CharacterTemplate extends AbstractTemplate<L2Character> {
character.setRace(race);
character.setCharacterClass(characterClass);
character.setPosition(spawnLocation);
character.setPoint(spawnLocation);
// character.getBaseAttributes().setIntelligence(intelligence);
// character.getBaseAttributes().setStrength(strength);
@@ -91,9 +91,9 @@ public abstract class CharacterTemplate extends AbstractTemplate<L2Character> {
}
/**
* @return the spawnLocation
* @return the initial spawn location
*/
public Coordinate getSpawnLocation() {
public Point getSpawnLocation() {
return spawnLocation;
}

View File

@@ -8,7 +8,8 @@ import com.l2jserver.model.world.capability.Attacker;
import com.l2jserver.model.world.capability.Castable;
import com.l2jserver.model.world.capability.Equipable;
import com.l2jserver.model.world.capability.Equiper;
import com.l2jserver.util.Coordinate;
import com.l2jserver.util.dimensional.Coordinate;
import com.l2jserver.util.dimensional.Point;
/**
* Abstract {@link Actor} class.
@@ -83,9 +84,9 @@ public abstract class AbstractActor extends AbstractObject implements Actor {
*/
protected int hp;
/**
* The actor coordinate
* The actor coordinate point
*/
protected Coordinate position;
protected Point point;
/**
* The currently effects active on the actor
*/
@@ -138,14 +139,29 @@ public abstract class AbstractActor extends AbstractObject implements Actor {
return false;
}
/**
* @return the coordinate point
*/
public Point getPoint() {
return point;
}
/**
* @param point
* the coordinate point to set
*/
public void setPoint(Point point) {
this.point = point;
}
@Override
public Coordinate getPosition() {
return position;
return point.getCoordinate();
}
@Override
public void setPosition(Coordinate coord) {
this.position = coord;
this.point = new Point(coord, (point != null ? point.getAngle() : 0));
}
/**

View File

@@ -10,7 +10,7 @@ import com.l2jserver.model.world.character.CharacterInventory.InventoryLocation;
import com.l2jserver.model.world.character.CharacterInventory.InventoryPaperdoll;
import com.l2jserver.model.world.item.ItemEvent;
import com.l2jserver.model.world.item.ItemListener;
import com.l2jserver.util.Coordinate;
import com.l2jserver.util.dimensional.Coordinate;
/**
* This class represents an {@link Item} in the Lineage II World. The item can

View File

@@ -3,7 +3,7 @@ package com.l2jserver.model.world;
import com.l2jserver.model.id.object.CharacterID;
import com.l2jserver.model.id.object.ItemID;
import com.l2jserver.model.world.capability.Summonable;
import com.l2jserver.util.Coordinate;
import com.l2jserver.util.dimensional.Coordinate;
/**
* This class represents an Pet in the Lineage II World

View File

@@ -3,7 +3,7 @@ package com.l2jserver.model.world;
import com.l2jserver.model.world.capability.Actor;
import com.l2jserver.model.world.capability.Playable;
import com.l2jserver.model.world.capability.Teleportable;
import com.l2jserver.util.Coordinate;
import com.l2jserver.util.dimensional.Coordinate;
/**
* {@link Player} is any object that can be controlled by the player. The most

View File

@@ -12,7 +12,7 @@ import com.l2jserver.model.world.actor.ActorListener;
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public interface Actor extends Listenable<ActorListener, ActorEvent>,
Spawnable, Positionable, Damagable, Attackable, Attacker, Castable,
Spawnable, Pointable, Damagable, Attackable, Attacker, Castable,
Caster, Levelable, Killable, Equiper, Equipable {
ActorEffects getEffects();
}

View File

@@ -1,7 +1,7 @@
package com.l2jserver.model.world.capability;
import com.l2jserver.model.world.AbstractObject;
import com.l2jserver.util.Coordinate;
import com.l2jserver.util.dimensional.Coordinate;
/**
* Defines an {@link AbstractObject} that can be dropped on the ground.

View File

@@ -0,0 +1,16 @@
package com.l2jserver.model.world.capability;
import com.l2jserver.model.world.AbstractObject;
import com.l2jserver.util.dimensional.Point;
/**
* Defines an {@link AbstractObject} that can be positioned and pointed in the
* world.
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public interface Pointable extends Positionable {
Point getPoint();
void setPoint(Point point);
}

View File

@@ -1,7 +1,7 @@
package com.l2jserver.model.world.capability;
import com.l2jserver.model.world.AbstractObject;
import com.l2jserver.util.Coordinate;
import com.l2jserver.util.dimensional.Coordinate;
/**
* Defines an {@link AbstractObject} that can be positioned in the world.

View File

@@ -1,7 +1,7 @@
package com.l2jserver.model.world.capability;
import com.l2jserver.model.world.AbstractObject;
import com.l2jserver.util.Coordinate;
import com.l2jserver.util.dimensional.Coordinate;
/**
* Represents an {@link AbstractObject} that can be spawned.

View File

@@ -1,7 +1,7 @@
package com.l2jserver.model.world.capability;
import com.l2jserver.model.world.AbstractObject;
import com.l2jserver.util.Coordinate;
import com.l2jserver.util.dimensional.Coordinate;
/**
* Represents an {@link AbstractObject} that can be summoned.

View File

@@ -1,7 +1,7 @@
package com.l2jserver.model.world.capability;
import com.l2jserver.model.world.AbstractObject;
import com.l2jserver.util.Coordinate;
import com.l2jserver.util.dimensional.Coordinate;
/**
* Defines an {@link AbstractObject} that can be teleported by

View File

@@ -1,7 +1,7 @@
package com.l2jserver.model.world.capability;
import com.l2jserver.model.world.AbstractObject;
import com.l2jserver.util.Coordinate;
import com.l2jserver.util.dimensional.Coordinate;
/**
* Defines an {@link AbstractObject} that can teleport {@link Teleportable}

View File

@@ -285,7 +285,7 @@ public enum CharacterClass {
* the class id
* @return the {@link CharacterClass} instance found
*/
public CharacterClass fromID(int id) {
public static CharacterClass fromID(int id) {
for (final CharacterClass c : values()) {
if (c.id == id)
return c;

View File

@@ -1,7 +1,7 @@
package com.l2jserver.model.world.event;
import com.l2jserver.model.world.capability.Spawnable;
import com.l2jserver.util.Coordinate;
import com.l2jserver.util.dimensional.Coordinate;
/**
* Event for objects spawning

View File

@@ -2,7 +2,7 @@ package com.l2jserver.model.world.filter.impl;
import com.l2jserver.model.world.capability.Positionable;
import com.l2jserver.model.world.filter.WorldObjectFilter;
import com.l2jserver.util.Coordinate;
import com.l2jserver.util.dimensional.Coordinate;
/**
* Filter objects that are in the <tt>range</tt> of <tt>coordinate</tt>

View File

@@ -5,7 +5,7 @@ import com.l2jserver.model.world.capability.Actor;
import com.l2jserver.model.world.capability.Listenable;
import com.l2jserver.model.world.capability.Spawnable;
import com.l2jserver.model.world.event.SpawnEvent;
import com.l2jserver.util.Coordinate;
import com.l2jserver.util.dimensional.Coordinate;
/**
* Event dispatcher once an player has spawned in the world

View File

@@ -1,7 +1,7 @@
package com.l2jserver.model.world.player;
import com.l2jserver.model.world.Player;
import com.l2jserver.util.Coordinate;
import com.l2jserver.util.dimensional.Coordinate;
/**
* Event dispatched once an player is teleported.

View File

@@ -1,4 +1,6 @@
package com.l2jserver.util;
package com.l2jserver.util.dimensional;
import org.apache.commons.math.geometry.Vector3D;
/**
* Represents an coordinate in the game world.
@@ -8,18 +10,12 @@ package com.l2jserver.util;
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public class Coordinate {
private static final long serialVersionUID = 1L;
/**
* The X point
* The backing vector of this Coordinate
*/
private final int x;
/**
* The Y point
*/
private final int y;
/**
* The Z point
*/
private final int z;
protected final Vector3D vector;
/**
* Creates a new coordinate
@@ -32,30 +28,19 @@ public class Coordinate {
* the z point
*/
protected Coordinate(int x, int y, int z) {
this.x = x;
this.y = y;
this.z = z;
this.vector = new Vector3D(x, y, z);
}
/**
* @return the x point
*/
public int getX() {
return x;
return (int) vector.getX();
}
/**
* @return the y point
*/
public int getY() {
return y;
return (int) vector.getY();
}
/**
* @return the z point
*/
public int getZ() {
return z;
return (int) vector.getZ();
}
/**
@@ -63,12 +48,11 @@ public class Coordinate {
* <tt>other</tt>
*
* @param other
* the other coodinate
* @return the computed distance
* the other coordinate
* @return the calculated distance
*/
public int getDistance(Coordinate other) {
// TODO calculation
return x + y + z;
public double getDistance(Coordinate other) {
return Vector3D.distance(vector, other.vector);
}
/**

View File

@@ -0,0 +1,142 @@
package com.l2jserver.util.dimensional;
import org.apache.commons.math.geometry.Rotation;
/**
* An point is composed of an Coordinate and an angle. The angle represents the
* facing angle of the point, that is, the direction the point is "looking".
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public class Point {
/**
* The point coordinate
*/
protected final Coordinate coordinate;
/**
* Te point rotation
*/
protected final Rotation rotation;
/**
* Creates a new point
*
* @param coordinate
* the coordinate
* @param angle
* the angle
*/
public Point(Coordinate coordinate, double angle) {
this.coordinate = coordinate;
this.rotation = new Rotation(coordinate.vector, angle);
}
/**
* @return the x
* @see com.l2jserver.util.dimensional.Coordinate#getX()
*/
public int getX() {
return coordinate.getX();
}
/**
* @return the y
* @see com.l2jserver.util.dimensional.Coordinate#getY()
*/
public int getY() {
return coordinate.getY();
}
/**
* @return the z
* @see com.l2jserver.util.dimensional.Coordinate#getZ()
*/
public int getZ() {
return coordinate.getZ();
}
/**
* @param other
* the other coordinate
* @return the distance
* @see com.l2jserver.util.dimensional.Coordinate#getDistance(com.l2jserver.util.dimensional.Coordinate)
*/
public double getDistance(Coordinate other) {
return coordinate.getDistance(other);
}
/**
* @param other
* the other point
* @return the distance
* @see com.l2jserver.util.dimensional.Coordinate#getDistance(com.l2jserver.util.dimensional.Coordinate)
*/
public double getDistance(Point other) {
return coordinate.getDistance(other.coordinate);
}
/**
* @return the angle
* @see org.apache.commons.math.geometry.Rotation#getAngle()
*/
public double getAngle() {
return rotation.getAngle();
}
/**
* @param other
* the other point
* @return the angle difference between the two points
* @see org.apache.commons.math.geometry.Rotation#distance(Rotation,
* Rotation)
*/
public double getAngleDifference(Point other) {
return Rotation.distance(this.rotation, other.rotation);
}
/**
* @return the coordinate
*/
public Coordinate getCoordinate() {
return coordinate;
}
/**
* @return the rotation
*/
public Rotation getRotation() {
return rotation;
}
/**
* Creates a new instance from the 3 points and an angle
*
* @param x
* the x point
* @param y
* the y point
* @param z
* the z point
* @param angle
* the angle
* @return the new {@link Point} object created
*/
public static Point fromXYZA(int x, int y, int z, double angle) {
return new Point(Coordinate.fromXYZ(x, y, z), angle);
}
/**
* Creates a new instance from the 3 points. The angle will be zero.
*
* @param x
* the x point
* @param y
* the y point
* @param z
* the z point
* @return the new {@link Point} object created
*/
public static Point fromXYZ(int x, int y, int z) {
return fromXYZA(x, y, z, 0);
}
}