1package com.osroyale.game.world.object;
3import com.osroyale.game.world.World;
4import com.osroyale.game.world.entity.Entity;
5import com.osroyale.game.world.entity.EntityType;
6import com.osroyale.game.world.entity.mob.Mob;
7import com.osroyale.game.world.entity.mob.player.Player;
8import com.osroyale.game.world.pathfinding.TraversalMap;
9import com.osroyale.game.world.position.Position;
10import com.osroyale.game.world.region.Region;
11import com.osroyale.net.packet.out.SendAddObject;
12import com.osroyale.net.packet.out.SendRemoveObject;
13import com.osroyale.util.generic.GenericAttributes;
15import java.util.Objects;
17import static com.osroyale.game.world.object.ObjectDirection.NORTH;
18import static com.osroyale.game.world.object.ObjectDirection.SOUTH;
62public class CustomGameObject
extends Entity implements
GameObject {
79 this.instance = instance;
80 this.direction = direction;
85 this(id,
Mob.DEFAULT_INSTANCE, position, direction, type);
88 public CustomGameObject(
int id,
int instance,
Position position) {
92 public CustomGameObject(
int id,
Position position) {
97 public int getInstancedHeight() {
103 if (genericAttributes ==
null)
105 return genericAttributes;
115 if (direction == NORTH || direction == SOUTH) {
123 if (direction == NORTH || direction == SOUTH) {
130 public int distance() {
131 return definition.getDistance();
146 if (!isRegistered()) {
147 Region region = getRegion();
150 if (region ==
null) {
152 }
else if (!region.containsObject(
getHeight(),
this)) {
162 if (isRegistered()) {
171 return isRegistered();
180 if (other.instance != getInstancedHeight())
194 if (other.instance != getInstancedHeight()) {
204 public void transform(
int id) {
211 public void rotate(ObjectDirection direction) {
213 this.direction = direction;
219 return definition.getName();
228 public int hashCode() {
233 public boolean equals(Object obj) {
234 if (obj instanceof CustomGameObject) {
235 CustomGameObject other = (CustomGameObject) obj;
236 return definition == other.definition &&
getPosition().equals(other.getPosition()) && getInstancedHeight() == other.getInstancedHeight();
242 public String toString() {
243 return String.format(
"CustomGameObject[id=%s, loc=%s, width=%s, len=%s, rot=%s, type=%s]",
getId(),
getPosition(),
width(),
length(),
getDirection(),
getObjectType());
GameObjectDefinition getDefinition()
void addToRegion(Region objectRegion)
GenericAttributes getGenericAttributes()
void removeFromRegion(Region objectRegion)
ObjectType getObjectType()
ObjectDirection getDirection()
static GameObjectDefinition forId(int id)
static void markObject(Region region, GameObject object, boolean add, boolean list)
boolean containsObject(int height, GameObject object)
Region[] getSurroundingRegions(Position position)