use of de.gurkenlabs.litiengine.entities.MapArea in project litiengine by gurkenlabs.
the class EnvironmentTests method testMapArea.
@Test
void testMapArea() {
MapArea testArea = new MapArea(0, 0, 1, 1);
testArea.setMapId(1);
testArea.setName("test");
this.testEnvironment.add(testArea);
assertNotNull(this.testEnvironment.getArea(1));
assertNotNull(this.testEnvironment.getArea("test"));
assertEquals(1, this.testEnvironment.getEntities(MapArea.class).size());
assertEquals(1, this.testEnvironment.getEntities().size());
this.testEnvironment.remove(testArea);
assertNull(this.testEnvironment.getArea(1));
assertNull(this.testEnvironment.getArea("test"));
assertEquals(0, this.testEnvironment.getEntities(MapArea.class).size());
assertEquals(0, this.testEnvironment.getEntities().size());
}
use of de.gurkenlabs.litiengine.entities.MapArea in project litiengine by gurkenlabs.
the class EnvironmentTests method testThatLocalMapIdIsAssigned.
@Test
void testThatLocalMapIdIsAssigned() {
MapArea entity1 = new MapArea(0, 0, 0, 0);
MapArea entity2 = new MapArea(0, 0, 0, 0);
MapArea entity3 = new MapArea(0, 0, 0, 0);
this.testEnvironment.add(entity1);
this.testEnvironment.add(entity2);
this.testEnvironment.add(entity3);
assertNotEquals(0, entity1.getMapId());
assertNotEquals(0, entity2.getMapId());
assertNotEquals(0, entity3.getMapId());
}
use of de.gurkenlabs.litiengine.entities.MapArea in project litiengine by gurkenlabs.
the class EnvironmentTests method testRemoveById.
@Test
void testRemoveById() {
MapArea testArea = new MapArea(0, 0, 1, 1);
testArea.setMapId(1);
testArea.setName("test");
this.testEnvironment.add(testArea);
this.testEnvironment.remove(1);
this.testEnvironment.remove(2);
assertNull(this.testEnvironment.getArea(1));
assertNull(this.testEnvironment.getArea("test"));
assertEquals(0, this.testEnvironment.getEntities(MapArea.class).size());
assertEquals(0, this.testEnvironment.getEntities().size());
}
use of de.gurkenlabs.litiengine.entities.MapArea in project litiengine by gurkenlabs.
the class EnvironmentTests method testFindEntitiesInShape.
@Test
void testFindEntitiesInShape() {
MapArea entity = new MapArea(0, 0, 10, 10);
MapArea entity2 = new MapArea(10, 10, 10, 10);
this.testEnvironment.add(entity);
this.testEnvironment.add(entity2);
Collection<IEntity> found = this.testEnvironment.findEntities(new Rectangle2D.Double(0, 0, 10, 10));
Collection<IEntity> found2 = this.testEnvironment.findEntities(new Ellipse2D.Double(0, 0, 10, 10));
assertTrue(found.contains(entity));
assertFalse(found.contains(entity2));
assertTrue(found2.contains(entity));
assertFalse(found2.contains(entity2));
}
use of de.gurkenlabs.litiengine.entities.MapArea in project litiengine by gurkenlabs.
the class MapAreaMapObjectLoader method load.
@Override
public Collection<IEntity> load(Environment environment, IMapObject mapObject) {
Collection<IEntity> entities = new ArrayList<>();
if (!this.isMatchingType(mapObject)) {
return entities;
}
MapArea mapArea = this.createMapArea(mapObject);
loadDefaultProperties(mapArea, mapObject);
entities.add(mapArea);
return entities;
}
Aggregations