From d98c1765857c7c57c8a1fd8c11672bc32507df96 Mon Sep 17 00:00:00 2001 From: Major- Date: Thu, 6 Mar 2014 18:27:43 +0000 Subject: [PATCH] Add extra sector functionality. --- .../apollo/game/model/obj/StaticObject.java | 20 +++---------------- src/org/apollo/game/model/sector/Sector.java | 9 +++++++++ .../game/model/sector/SectorRepository.java | 11 ++++++++++ 3 files changed, 23 insertions(+), 17 deletions(-) diff --git a/src/org/apollo/game/model/obj/StaticObject.java b/src/org/apollo/game/model/obj/StaticObject.java index b196e5fd..35c95d64 100644 --- a/src/org/apollo/game/model/obj/StaticObject.java +++ b/src/org/apollo/game/model/obj/StaticObject.java @@ -18,11 +18,6 @@ public final class StaticObject extends Entity { */ private final ObjectDefinition definition; - /** - * The object's id. - */ - private final int id; - /** * The object's rotation. */ @@ -36,14 +31,13 @@ public final class StaticObject extends Entity { /** * Creates a new static object. * - * @param def The object's id. + * @param id The object's id. * @param position The position. * @param type The type code of the object. * @param rotation The rotation of the object. */ public StaticObject(int id, Position position, int type, int rotation) { super(position); - this.id = id; this.type = type; this.rotation = rotation; definition = ObjectDefinition.lookup(id); @@ -63,15 +57,6 @@ public final class StaticObject extends Entity { return EntityType.STATIC_OBJECT; } - /** - * Gets the id of the object. - * - * @return The object id. - */ - public int getId() { - return id; - } - /** * Gets the object's rotation. * @@ -92,7 +77,8 @@ public final class StaticObject extends Entity { @Override public String toString() { - return StaticObject.class.getName() + " [id=" + id + ", type=" + type + ", rotation=" + rotation + "]"; + return StaticObject.class.getName() + " [id=" + definition.getId() + ", type=" + type + ", rotation=" + + rotation + "]"; } } \ No newline at end of file diff --git a/src/org/apollo/game/model/sector/Sector.java b/src/org/apollo/game/model/sector/Sector.java index 600e1dc8..ca739471 100644 --- a/src/org/apollo/game/model/sector/Sector.java +++ b/src/org/apollo/game/model/sector/Sector.java @@ -75,6 +75,15 @@ public final class Sector { return coordinates; } + /** + * Gets the {@link List} of {@link Entity}s. + * + * @return The list. + */ + public List getEntities() { + return new ArrayList<>(entities); + } + /** * Notifies the listeners registered to this sector that an update has occurred. * diff --git a/src/org/apollo/game/model/sector/SectorRepository.java b/src/org/apollo/game/model/sector/SectorRepository.java index 7ebf30cb..7a18de11 100644 --- a/src/org/apollo/game/model/sector/SectorRepository.java +++ b/src/org/apollo/game/model/sector/SectorRepository.java @@ -1,6 +1,8 @@ package org.apollo.game.model.sector; +import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map; /** @@ -84,6 +86,15 @@ public final class SectorRepository { return sector; } + /** + * Gets the {@link List} of {@link Sector}s. + * + * @return The list. + */ + public List getSectors() { + return new ArrayList<>(sectors.values()); + } + /** * Removes a {@link Sector} from the repository, if permitted. *