mirror of
https://github.com/2006-Scape/apollo.git
synced 2026-07-05 16:49:04 +00:00
Add Npc boundaries.
This commit is contained in:
@@ -11,6 +11,11 @@ import org.apollo.game.sync.block.SynchronizationBlock;
|
|||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
public final class Npc extends Mob {
|
public final class Npc extends Mob {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The positions representing the bounds (i.e. walking limits) of this npc.
|
||||||
|
*/
|
||||||
|
private Position[] boundary;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new npc with the specified id and {@link Position}.
|
* Creates a new npc with the specified id and {@link Position}.
|
||||||
*
|
*
|
||||||
@@ -32,6 +37,20 @@ public final class Npc extends Mob {
|
|||||||
this.definition = definition;
|
this.definition = definition;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the boundary of this npc.
|
||||||
|
*
|
||||||
|
* @return The boundary.
|
||||||
|
*/
|
||||||
|
public Position[] getBoundary() {
|
||||||
|
return boundary;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public EntityType getEntityType() {
|
||||||
|
return EntityType.NPC;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the id of this npc. Shorthand for {@link #getDefinition().getId()}.
|
* Gets the id of this npc. Shorthand for {@link #getDefinition().getId()}.
|
||||||
*
|
*
|
||||||
@@ -41,6 +60,32 @@ public final class Npc extends Mob {
|
|||||||
return definition.getId();
|
return definition.getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Indicates whether or not this npc is bound to a specific set of coordinates.
|
||||||
|
*
|
||||||
|
* @return {@code true} if the npc is bound, otherwise {@code false}.
|
||||||
|
*/
|
||||||
|
public boolean isBound() {
|
||||||
|
return boundary == null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the boundary of this npc.
|
||||||
|
*
|
||||||
|
* @param boundary The boundary.
|
||||||
|
*/
|
||||||
|
public void setBoundary(Position[] boundary) {
|
||||||
|
if (boundary.length != 4) {
|
||||||
|
throw new IllegalArgumentException("Boundary count must be 4.");
|
||||||
|
}
|
||||||
|
this.boundary = boundary;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "[" + Npc.class.getName() + ": id=" + definition.getId() + ", name=" + definition.getName() + "]";
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Transforms this npc into the npc with the specified id.
|
* Transforms this npc into the npc with the specified id.
|
||||||
*
|
*
|
||||||
@@ -54,14 +99,4 @@ public final class Npc extends Mob {
|
|||||||
blockSet.add(SynchronizationBlock.createTransformBlock(id));
|
blockSet.add(SynchronizationBlock.createTransformBlock(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public EntityType getEntityType() {
|
|
||||||
return EntityType.NPC;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "[" + Npc.class.getName() + ": id=" + definition.getId() + ", name=" + definition.getName() + "]";
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user