コード例 #1
0
  @Test
  public void recycled_entities_behave_nicely_with_components() {
    ComponentMapper<ComponentX> mapper = world.getMapper(ComponentX.class);

    Entity e1 = world.createEntity();
    e1.edit().add(new ComponentX());
    assertTrue(mapper.has(e1));

    int id1 = e1.getId();
    e1.deleteFromWorld();

    Entity e2 = world.createEntity();

    assertNotEquals(id1, e2.getId());
    assertFalse("Error:" + mapper.getSafe(e2), mapper.has(e2));
  }
コード例 #2
0
  @Test
  public void should_recycle_entities_after_one_round() {
    ComponentMapper<ComponentX> mapper = world.getMapper(ComponentX.class);

    Entity e1 = world.createEntity();
    e1.edit().add(new ComponentX());
    assertTrue(mapper.has(e1));

    int id1 = e1.getId();
    e1.deleteFromWorld();
    world.process();
    Entity e2 = world.createEntity();

    assertEquals(id1, e2.getId());
    assertFalse("Error:" + mapper.getSafe(e2), mapper.has(e2));
  }
コード例 #3
0
 @Before
 public void init() {
   world = new World();
   packedMapper = world.getMapper(Packed.class);
 }
コード例 #4
0
 public static void setup(World world) {
   scm = world.getMapper(ScriptComponent.class);
 }