mirror of
https://github.com/2006-Scape/apollo.git
synced 2026-07-06 08:40:03 +00:00
Add method to get every entity in a Sector.
This commit is contained in:
@@ -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<Entity> getEntities() {
|
||||||
|
List<Entity> 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.
|
* @param position The position containing the entities.
|
||||||
* @return The list.
|
* @return The list.
|
||||||
@@ -155,7 +167,7 @@ public final class Sector {
|
|||||||
public boolean removeEntity(Entity entity) {
|
public boolean removeEntity(Entity entity) {
|
||||||
Position position = entity.getPosition();
|
Position position = entity.getPosition();
|
||||||
List<Entity> entities = this.entities.get(position);
|
List<Entity> entities = this.entities.get(position);
|
||||||
|
|
||||||
if (entities != null && entities.remove(entity)) {
|
if (entities != null && entities.remove(entity)) {
|
||||||
notifyListeners(entity, SectorOperation.REMOVE);
|
notifyListeners(entity, SectorOperation.REMOVE);
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
Reference in New Issue
Block a user