feat: properly expose EntityManager

This commit is contained in:
punchready 2021-05-19 18:24:07 +02:00
parent bd442bedfc
commit 7bac3bd46a
2 changed files with 10 additions and 10 deletions

View File

@ -22,7 +22,7 @@ public class EntityManager {
* Takes over all the entities from a different {@link EntityManager}. * Takes over all the entities from a different {@link EntityManager}.
* @param other The entity list to take the data from * @param other The entity list to take the data from
*/ */
public void cloneFrom(EntityManager other) { void cloneFrom(EntityManager other) {
entities.clear(); entities.clear();
for(Entity entity: other.entities) { for(Entity entity: other.entities) {
entities.add(entity.clone()); entities.add(entity.clone());
@ -36,7 +36,7 @@ public class EntityManager {
* Finds an unused {@link Rock} entity id * Finds an unused {@link Rock} entity id
* @return The first free id * @return The first free id
*/ */
public int findFreeRockSlot() { int findFreeRockSlot() {
int i = 0; int i = 0;
while(usedRockSlots.contains(i)) { while(usedRockSlots.contains(i)) {
i++; i++;
@ -47,7 +47,7 @@ public class EntityManager {
/** /**
* Clears the list of entities. * Clears the list of entities.
*/ */
public void clear() { void clear() {
entities.clear(); entities.clear();
usedRockSlots.clear(); usedRockSlots.clear();
} }
@ -56,7 +56,7 @@ public class EntityManager {
* Adds an entity to the list. * Adds an entity to the list.
* @param entity The {@link Entity} to add * @param entity The {@link Entity} to add
*/ */
public void addEntity(Entity entity) { void addEntity(Entity entity) {
if(entity.id.isSameType(EntityType.Rocks)) { if(entity.id.isSameType(EntityType.Rocks)) {
usedRockSlots.add(entity.id.id); usedRockSlots.add(entity.id.id);
} }
@ -67,7 +67,7 @@ public class EntityManager {
* Adds multiple entities to the list. * Adds multiple entities to the list.
* @param entities The entities to add * @param entities The entities to add
*/ */
public void addEntities(Entity... entities) { void addEntities(Entity... entities) {
for(Entity e: entities) { for(Entity e: entities) {
this.addEntity(e); this.addEntity(e);
} }
@ -77,7 +77,7 @@ public class EntityManager {
* Removes an entity from the list. * Removes an entity from the list.
* @param entity The {@link Entity} to remove * @param entity The {@link Entity} to remove
*/ */
public boolean removeEntity(Entity entity) { boolean removeEntity(Entity entity) {
if(entity.id.isSameType(EntityType.Rocks)) { if(entity.id.isSameType(EntityType.Rocks)) {
usedRockSlots.remove(entity.id.id); usedRockSlots.remove(entity.id.id);
} }
@ -88,7 +88,7 @@ public class EntityManager {
* Removes an entity from the list. * Removes an entity from the list.
* @param entityid The {@link EntityID} of the {@link Entity} to remove * @param entityid The {@link EntityID} of the {@link Entity} to remove
*/ */
public boolean removeEntity(EntityID entityid) { boolean removeEntity(EntityID entityid) {
Entity entity = findEntity(entityid); Entity entity = findEntity(entityid);
if(entity != null) { if(entity != null) {
return entities.remove(entity); return entities.remove(entity);
@ -166,7 +166,7 @@ public class EntityManager {
* Exports all entities as an array. * Exports all entities as an array.
* @return An array containing every {@link Entity} * @return An array containing every {@link Entity}
*/ */
public Entity[] export() { Entity[] export() {
return (Entity[])entities.toArray(); return (Entity[])entities.toArray();
} }
} }

View File

@ -25,8 +25,8 @@ public class GameStateView {
return state.mapSize; return state.mapSize;
} }
public Iterator<Entity> getEntities() { public EntityManager getEntities() {
return state.entities.getEntities(); return state.entities;
} }
public int getRoundNumber() { public int getRoundNumber() {