Namek / artemis-odb-entity-tracker

:game_die: Visual Entity Tracker for ECS library: artemis-odb
http://namek.github.io/artemis-odb-entity-tracker/
26 stars 5 forks source link

Tracking of non-primitive component fields #5

Open nanonull opened 8 years ago

nanonull commented 8 years ago

Given: Component with Field1 of non-primitive type

Expected: String.valueOf(Field1) is invoked and this result is displayed (read-only) in Component-Details-View for Field1

Actual: 'reference' text is displayed for Field1 i

desenvolvedorindie commented 7 years ago

I've tested It's possible extract primitive types of classe with:


public class RigidBodyComponent extends Component {

    public final Vector2 velocity = new Vector2();

}

Class cls = RigidBodyComponent.class;
showFields(cls);

public void showFields(Class cls) {
   Field[] fields = cls.getFields();

   for (Field field : fields) {
      String name = String.valueOf(field.getName());

      if (ClassUtils.isPrimitiveOrWrapper(field.getType())) {
         Gdx.app.log("Field", name);
      } else if (!Modifier.isStatic(field.getModifiers())) {
         showFields(field.getType());
      }
   }
}

I'm using for ClassUtils:

compile group: 'org.apache.commons', name: 'commons-lang3', version: '3.1'

Output was x and y

desenvolvedorindie commented 7 years ago
Object[] possibleValues = enumValue.getDeclaringClass().getEnumConstants();

returns all enums values

Namek commented 7 years ago

Hi, thanks for your input. I remember about this issue. However, I've taken the long path to solve it. Instead of serializing just directive primitive fields in components I decided to implement my own serializer that deserializes into general value tree which is to be represtented in GUI. In practice, you should be able to modify any object in your component. No ETA/roadmap, though.

More on this here: https://www.namekdev.net/2017/04/serializing-java-why-i-work-on-new-serializer/ and here: https://www.namekdev.net/2017/03/artemis-entity-tracker-inspecting-your-game-state-through-network/