From 67e12d5867e2cd2bd549b5eda1e06770eff84768 Mon Sep 17 00:00:00 2001 From: Major- Date: Mon, 15 Sep 2014 04:16:52 +0100 Subject: [PATCH] Add method to get every entity in a Sector. --- src/org/apollo/game/model/area/Sector.java | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/org/apollo/game/model/area/Sector.java b/src/org/apollo/game/model/area/Sector.java index 4e46588d..e72fcacb 100644 --- a/src/org/apollo/game/model/area/Sector.java +++ b/src/org/apollo/game/model/area/Sector.java @@ -100,7 +100,19 @@ public final class Sector { } /** - * Gets a shallow copy of the {@link List} of {@link Entity}s. The returned type will be {@link ImmutableList}. + * Gets an {@link ImmutableList} containing every {@link Entity} in this sector. + * + * @return The list. + */ + public List getEntities() { + List combined = new ArrayList<>(); + this.entities.values().forEach(entities -> combined.addAll(entities)); + return ImmutableList.copyOf(combined); + } + + /** + * Gets a shallow copy of the {@link List} of {@link Entity} objects at the specified {@link Position}. The returned + * type will be {@link ImmutableList}. * * @param position The position containing the entities. * @return The list. @@ -155,7 +167,7 @@ public final class Sector { public boolean removeEntity(Entity entity) { Position position = entity.getPosition(); List entities = this.entities.get(position); - + if (entities != null && entities.remove(entity)) { notifyListeners(entity, SectorOperation.REMOVE); return true;