Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tracking of non-primitive component fields #5

Open
nanonull opened this issue Jan 3, 2016 · 3 comments
Open

Tracking of non-primitive component fields #5

nanonull opened this issue Jan 3, 2016 · 3 comments

Comments

@nanonull
Copy link

nanonull commented Jan 3, 2016

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
Copy link

desenvolvedorindie commented Jun 1, 2017

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
Copy link

desenvolvedorindie commented Jun 1, 2017

Object[] possibleValues = enumValue.getDeclaringClass().getEnumConstants();

returns all enums values

@Namek
Copy link
Owner

Namek commented Jun 2, 2017

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/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants