Exemplo n.º 1
0
  @Test
  public void testVisibility() {
    reset();

    ModelEntity entity = new ModelEntity();
    Visibility visibility = new Visibility();
    visibility.setCondition("(eq $" + variableDef + " i1)");
    entity.getComponents().add(visibility);

    entitiesLoader.toEngineEntity(entity);
    IntMap<Entity> entityIntMap =
        gameLoop.getEntitiesFor(Family.getFamilyFor(VisibilityComponent.class));
    EngineEntity engineEntity = (EngineEntity) entityIntMap.entries().next().value;
    assertTrue(engineEntity.getGroup().isVisible());

    gameLoop.update(1);
    assertFalse(engineEntity.getGroup().isVisible());

    variablesManager.setVarToExpression(variableDef, "i1");
    gameLoop.update(1);
    assertTrue(engineEntity.getGroup().isVisible());

    variablesManager.setVarToExpression(variableDef, "i0");
    gameLoop.update(1);
    assertFalse(engineEntity.getGroup().isVisible());
  }
  @Override
  public void write(Json json, IntMap intMap, Class knownType) {
    json.writeObjectStart();
    json.writeValue(VALUE_SIZE, intMap.size);

    json.writeArrayStart(VALUE_ENTRIES);
    for (IntMap.Entry entry : (IntMap.Entries<?>) intMap.entries()) {
      json.writeValue(String.valueOf(entry.key), entry.value, null);
    }
    json.writeArrayEnd();

    json.writeObjectEnd();
  }